Browse Source

chown in libc

K. Lange 4 years ago
parent
commit
1ecdb29e51
3 changed files with 12 additions and 1 deletions
  1. 1 0
      base/usr/include/unistd.h
  2. 0 1
      libc/main.c
  3. 11 0
      libc/unistd/chown.c

+ 1 - 0
base/usr/include/unistd.h

@@ -66,6 +66,7 @@ struct utimbuf {
 extern char * ttyname(int fd);
 extern int utime(const char *filename, const struct utimbuf *times);
 extern int rmdir(const char *pathname); /* TODO  rm probably just works */
+extern int chown(const char * pathname, uid_t owner, gid_t group);
 
 #define STDIN_FILENO 0
 #define STDOUT_FILENO 1

+ 0 - 1
libc/main.c

@@ -42,7 +42,6 @@ DEFN_SYSCALL5(mount, SYS_MOUNT, char *, char *, char *, unsigned long, void *);
 DEFN_SYSCALL2(lstat, SYS_LSTAT, char *, void *);
 DEFN_SYSCALL2(fswait, SYS_FSWAIT, int, int *);
 DEFN_SYSCALL3(fswait2, SYS_FSWAIT2, int, int *,int);
-DEFN_SYSCALL3(chown, SYS_CHOWN, char *, int, int);
 
 extern void _init();
 extern void _fini();

+ 11 - 0
libc/unistd/chown.c

@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <errno.h>
+#include <syscall.h>
+#include <syscall_nums.h>
+
+DEFN_SYSCALL3(chown, SYS_CHOWN, char *, int, int);
+
+int chown(const char * pathname, uid_t owner, gid_t group) {
+	__sets_errno(syscall_chown((char*)pathname,owner,group));
+}
+