File stat() vs access() to check permissions on a directory

前端 未结 3 1860
南旧
南旧 2021-01-02 13:55

I have successfully used both stat() & access() separately to determine if a user has either read or read/write access to a directory.

<
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 14:34

    In the simple case, both are functionally equivalent for our matter. Also, access() would not be much faster or so as the same data structure (the inode) much be fetched.

    However, if access control lists (ACL) are used on the system, access will process these while you have no way to check ACLs with the stat data.

提交回复
热议问题