22#include <unistd.h>
33
44// Implement functions from unistd that are not already defined in other parts
5- // of newlibs libc Or in something we supply
5+ // of newlibs libc or in something we supply
66
77// unsigned alarm (unsigned __secs);
88int chdir (const char * __path ) {
@@ -20,11 +20,18 @@ int chroot(const char *__path) {
2020}
2121
2222// int chmod (const char *__path, mode_t __mode);
23+
2324// int chown (const char *__path, uid_t __owner, gid_t __group);
25+
2426// int close_range (unsigned int __firstfd, unsigned int __lastfd, int
25- // __flags); size_t confstr (int __name, char *__buf, size_t __len); char *
26- // crypt (const char *__key, const char *__salt); char * ctermid (char *__s);
27- // char * cuserid (char *__s);
27+ // __flags);
28+
29+ // size_t confstr (int __name, char *__buf, size_t __len);
30+
31+ // char *crypt (const char *__key, const char *__salt);
32+
33+ // char * ctermid (char *__s); char * cuserid (char *__s);
34+
2835// int daemon (int nochdir, int noclose);
2936
3037// function to duplicate file descriptor to second file number
@@ -60,19 +67,28 @@ int execv(const char *__path, char *const __argv[]) {
6067}
6168// already given in newlib
6269// int execve (const char *__path, char * const __argv[], char * const
63- // __envp[]); int execvp (const char *__file, char * const __argv[]); int
64- // execvpe (const char *__file, char * const __argv[], char * const __envp[]);
70+ // __envp[]);
71+
72+ // int execvp (const char *__file, char * const __argv[]);
73+ // int execvpe (const char *__file, char * const __argv[], char * const
74+ // __envp[]);
75+
6576// #if __ATFILE_VISIBLE
6677// int faccessat (int __dirfd, const char *__path, int __mode, int __flags);
6778// #endif
68- // int fchmod (int __fildes, mode_t __mode);
69- // int fchown (int __fildes, uid_t __owner, gid_t __group);
79+ // int fchmod (int __fildes, mode_t __mode);
80+
81+ // int fchown (int __fildes, uid_t __owner, gid_t __group);
7082// #if __ATFILE_VISIBLE
7183// int fchownat (int __dirfd, const char *__path, uid_t __owner, gid_t __group,
72- // int __flags); #endif int fexecve (int __fd, char * const __argv[], char *
73- // const __envp[]); long fpathconf (int __fd, int __name);
84+ // int __flags);
85+ // #endif
86+ // int fexecve (int __fd, char * const __argv[], char * const __envp[]);
87+ // long fpathconf (int __fd, int __name);
88+
7489int fsync (int __fd ) { return 0 ; }
7590int fdatasync (int __fd ) { return 0 ; }
91+
7692// char * get_current_dir_name (void);
7793char * getcwd (char * __buf , size_t __size ) { return "/" ; }
7894// int getdomainname (char *__name, size_t __len);
@@ -97,27 +113,47 @@ char *getcwd(char *__buf, size_t __size) { return "/"; }
97113// char * getwd (char *__buf);
98114// int lchown (const char *__path, uid_t __owner, gid_t __group);
99115// #if __ATFILE_VISIBLE
100- // int linkat (int __dirfd1, const char *__path1, int __dirfd2, const char
101- // *__path2, int __flags); #endif #if __MISC_VISIBLE || __XSI_VISIBLE int
102- // nice (int __nice_value); #endif #if __MISC_VISIBLE || __XSI_VISIBLE >= 4 int
103- // lockf (int __fd, int __cmd, off_t __len); #endif long pathconf (const char
104- // *__path, int __name); int pause (void); #if __POSIX_VISIBLE >= 199506 int
105- // pthread_atfork (void (*)(void), void (*)(void), void (*)(void)); #endif int
106- // pipe (int __fildes[2]) {
116+ // int linkat (int __dirfd1, const char *__path1, int __dirfd2, const char
117+ // *__path2, int __flags);
118+
119+ // #endif #if __MISC_VISIBLE || __XSI_VISIBLE
120+ // int nice(int __nice_value);
121+ // #endif
122+ // #if __MISC_VISIBLE || __XSI_VISIBLE >= 4
123+ // int lockf(int __fd, int __cmd, off_t __len);
124+ // #endif
125+ // long pathconf (const char *__path, int __name);
126+ // int pause (void);
127+ // #if __POSIX_VISIBLE >= 199506
128+ // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void));
129+ // #endif
130+ // int pipe (int __fildes[2]) {
107131// pipe2(__fileds[2], 0);
108132// }
109133// int pipe2 (int __fildes[2], int flags);
110134// #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500
111135// ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset);
112136// ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t
113- // __offset); #endif _READ_WRITE_RETURN_TYPE read (int __fd, void *__buf, size_t
114- // __nbyte); #if __BSD_VISIBLE int rresvport (int *__alport); int revoke
115- // (char *__path); #endif int rmdir (const char *__path); #if __BSD_VISIBLE
116- // int ruserok (const char *rhost, int superuser, const char *ruser, const char
117- // *luser); #endif #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE <
118- // 200112) void * sbrk (ptrdiff_t __incr); #endif #if __BSD_VISIBLE ||
119- // __POSIX_VISIBLE >= 200112 int setegid (gid_t __gid); int seteuid
120- // (uid_t __uid); #endif int setgid (gid_t __gid);
137+ // __offset);
138+
139+ // #endif _READ_WRITE_RETURN_TYPE
140+ // read (int __fd, void *__buf, size_t __nbyte);
141+ // #if __BSD_VISIBLE
142+ // int rresvport (int *__alport);
143+ // int revoke(char *__path);
144+ // #endif
145+ // int rmdir (const char *__path);
146+ // #if __BSD_VISIBLE
147+ // int ruserok (const char *rhost, int superuser, const char *ruser, const char
148+ // *luser);
149+ // #endif
150+ // #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
151+ // void * sbrk (ptrdiff_t __incr);
152+ // #endif #if __BSD_VISIBLE ||__POSIX_VISIBLE >= 200112
153+ // int setegid (gid_t __gid);
154+ // int seteuid(uid_t __uid);
155+ // #endif
156+ // int setgid(gid_t __gid);
121157int setgroups (int ngroups , const gid_t * grouplist ) {
122158 * __errno () = EPERM ;
123159 return -1 ;
0 commit comments