【问题标题】:Sometimes, LD_PRELOAD in HPUX and Solaris cannot take effect有时,HPUX 和 Solaris 中的 LD_PRELOAD 无法生效
【发布时间】:2011-12-26 12:21:58
【问题描述】:

我遇到了一些关于 LD_PRELOAD 的问题。

我在HPUX和Solaris中使用LD_PRELOAD时,发现无法在/usr/bin/touch中附加我的open64/open/creat64/creat函数,但是我的unlink可以在/usr/bin/rm中生效,为什么?

我做了一个简单的测试:

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;
}

当我这样做时,我发现:通常我无法打开文件,但触摸可以做到!

为什么!我为此困惑了很长时间。 谁能帮帮我.thx

最后,对不起我的英语不好

【问题讨论】:

  • 你确定,那个触摸使用了 creat() 函数?
  • 是的。命令truss -o touch.log touch testfile 告诉我,它使用 creat64 函数来创建文件。
  • 确保你正在执行/usr/bin/touch而不是你的shell内置的touch命令。

标签: c solaris hp-ux ld-preload


【解决方案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, ...);

【讨论】:

    猜你喜欢
    • 2012-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 2017-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多