source: trunk/libs/newlib/src/newlib/libc/sys/linux/inode.c

Last change on this file was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.5 KB
Line 
1/* libc/sys/linux/inode.c - Inode-related system calls */
2
3/* Written 2000 by Werner Almesberger */
4
5
6#include <unistd.h>
7#include <fcntl.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <sys/utime.h>
11#include <dirent.h>
12#include <machine/syscall.h>
13
14#define _LIBC 1
15#include <sys/lock.h>
16
17
18#define __NR___umask __NR_umask
19
20_syscall2(int,link,const char *,oldpath,const char *,newpath)
21_syscall1(int,unlink,const char *,pathname)
22_syscall1(int,chdir,const char *,path)
23_syscall1(int,fchdir,int,fd)
24_syscall2(int,access,const char *,filename,int,mode)
25_syscall2(int,mkdir,const char *,pathname,mode_t,mode)
26_syscall1(int,rmdir,const char *,pathname)
27_syscall1(int,chroot,const char *,path)
28_syscall2(int,stat,const char *,file_name,struct stat *,buf)
29_syscall2(int,statfs,const char *,file_name,struct statfs *,buf)
30_syscall2(int,fstat,int,filedes,struct stat *,buf)
31_syscall2(int,fstatfs,int,filedes,struct statfs *,buf)
32_syscall3(int,getdents,int,fd,struct dirent *,dirp,unsigned int,count)
33
34#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 2
35_syscall2(int,chmod,const char *,path,mode_t,mode)
36_syscall3(int,chown,const char *,path,uid_t,owner,gid_t,group)
37_syscall2(int,fchmod,int,filedes,mode_t,mode)
38_syscall3(int,lchown,const char *,path,uid_t,owner,gid_t,group)
39_syscall2(int,lstat,const char *,file_name,struct stat *,buf)
40_syscall3(int,readlink,const char *,path,char *,buf,size_t,bufsiz)
41_syscall2(int,symlink,const char *,oldpath,const char *,newpath)
42_syscall2(int,utime,const char *,filename,const struct utimbuf *,buf)
43#endif
44
45#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 3
46_syscall1(int,pipe,int *,filedes)
47#endif
48
49#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 4
50_syscall3(int,mknod,const char *,pathname,mode_t,mode,dev_t,dev)
51#endif
52
53weak_alias(__libc_statfs,__statfs)
54weak_alias(__libc_fstatfs,__fstatfs)
55
56static _syscall3(int,fchown32,int,fd,uid_t,owner,gid_t,group)
57
58int
59fchown (int fd, uid_t owner, gid_t group)
60{
61  return __libc_fchown32 (fd, owner, group);
62}
63
64#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 2
65
66__LOCK_INIT(static, umask_lock);
67
68_syscall1(mode_t,__umask,mode_t,mask)
69
70mode_t
71umask (mode_t mask)
72{
73  mode_t old_mask;
74
75  /* we need to lock so as to not interfere with getumask */
76  __lock_acquire(umask_lock);
77  old_mask = __umask (mask);
78  __lock_release(umask_lock);
79
80  return old_mask;
81}
82
83mode_t
84getumask (void)
85{
86  mode_t mask;
87
88  __lock_acquire(umask_lock);
89
90  mask = __umask (0);
91  mask = __umask (mask);
92
93  __lock_release(umask_lock);
94
95  return mask;
96}
97
98#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 2 */
Note: See TracBrowser for help on using the repository browser.