浏览代码

add portable lchown (trivial to support and a few ancient things want it..)

Rich Felker 14 年之前
父节点
当前提交
d5ca067c7b
共有 2 个文件被更改,包括 10 次插入0 次删除
  1. 3 0
      include/sys/stat.h
  2. 7 0
      src/stat/lchmod.c

+ 3 - 0
include/sys/stat.h

@@ -86,6 +86,9 @@ int mkdirat(int, const char *, mode_t);
 int mknodat(int, const char *, mode_t, dev_t);
 int mkfifoat(int, const char *, mode_t);
 
+#ifdef _BSD_SOURCE
+int lchmod(const char *, mode_t);
+#endif
 
 #ifdef __cplusplus
 }

+ 7 - 0
src/stat/lchmod.c

@@ -0,0 +1,7 @@
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int lchmod(const char *path, mode_t mode)
+{
+	return fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW);
+}