【问题标题】:ls ACL attributes impementationls ACL 属性实现
【发布时间】:2018-12-14 20:30:09
【问题描述】:

我正在编写 ls 的实现。

我已经完成了属性“@”,但我还有另一个问题。 我怎样才能得到文件是否具有属性“+”?可能是tcgetattr,但我不知道如何获取我需要的东西。 人对于这个功能来说太小了,我没有找到如何去做。 如果有属性“+”,我只需要得到 True。

我还找到了结构,它可能有办法做到这一点,但我应该比较什么?

struct termios {
    tcflag_t    c_iflag;    /* input flags */
    tcflag_t    c_oflag;    /* output flags */
    tcflag_t    c_cflag;    /* control flags */
    tcflag_t    c_lflag;    /* local flags */
    cc_t        c_cc[NCCS]; /* control chars */
    speed_t     c_ispeed;   /* input speed */
    speed_t     c_ospeed;   /* output speed */
};

enter image description here

【问题讨论】:

  • 首先,不,tcgetattr 是关于终端(控制台、ssh 的伪程序、终端仿真器、调制解调器等)属性。这根本不是你想要的。也许你应该阅读acl(5)

标签: c linux unix operating-system ls


【解决方案1】:

# include <sys/acl.h> 中找到解决方案,直接使用acl = acl_get_link_np(path, ACL_TYPE_EXTENDED); 函数。如果它不是 NULL - 有属性。别忘了清理内存acl_free(acl;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    相关资源
    最近更新 更多