本帖最后由 hellworl 于 2011-12-20 09:15:52 编辑

解决方案 »

  1.   

    KLOG_READ_CLEAR,
    clear? 你有权限这样做?read我觉得还行。你调dmesg,人家也只是读吧
    再说你这样调你确定是buzybox的,系统好像也有个binary的dmesg
      

  2.   

    多谢提醒啊,是有两个dmesg,都是符号链接,
    一个是toolbox,一个是bosybox的,不知道为什么有两个dmesg?
    不过有点眉目了,继续
      

  3.   

    KLOG_READ_CLEAR,
    clear? 你有权限这样做?read我觉得还行。你调dmesg
      

  4.   


    linux权限的问题,不是很懂,#define KLOG_CLOSE      0
    #define KLOG_OPEN       1
    #define KLOG_READ       2
    #define KLOG_READ_ALL   3
    #define KLOG_READ_CLEAR 4
    #define KLOG_CLEAR      5
    #define KLOG_DISABLE    6
    #define KLOG_ENABLE     7
    #define KLOG_SETLEVEL   8
    #define KLOG_UNREADSIZE 9
    #define KLOG_WRITE      1011个里面,根据这个函数确定是否有权限访问:
    int cap_syslog(int type)
    {
    if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
    return -EPERM;
    return 0;
    }
      

  5.   

    KLOG_READ_CLEAR 如果你的内核编译版本是user版本的,则么有KLOG_READ_CLEAR 这个权限,肯定返回失败的。
    你可以打印下errno看下值的。Operation not permitted
      

  6.   

    还有你的代码中buf后应该加个"\n"