1

I get some problem about LD_PRELOAD.

When I use LD_PRELOAD in HPUX and Solaris, I found that I cannot attach my open64/open/creat64/creat function in /usr/bin/touch, but my unlink can take effect in /usr/bin/rm, why?

I have do a simple test:

int open(int fd, int flag, mode_t mode) 
{
    return -1;
}

int open64(int fd, int flag, mode_t mode) 
{
    return -1;
}

int creat(int fd, mode_t mode)
{
    return -1;
}

int creat64(int fd, mode_t mode)
{
    return -1;
}

when i do this, i found : normally, i cannot open file, but touch can do it!

why!i was puzzled by this for long time. who can help me.thx

at last, sorry for my poor English

4

1 回答 1

1

我认为你的函数签名是错误的。(int 而不是 char *) 在我的系统上,我看到以下签名:

grep -w creat /usr/include/*

/usr/include/fcntl.h:#define    creat64     creat
/usr/include/fcntl.h:extern int creat(const char *, mode_t);

grep -w open /usr/include/*

/usr/include/fcntl.h:#define    open64      open
/usr/include/fcntl.h:extern int open(const char *, int, ...);
于 2011-12-31T11:17:33.327 回答