Diff markup
001 001
002 002
003 003
004 004
005 005
006 006
007 007
008 008
009 009
010 010
011 011
012 012
013 013
014 014
015 015
016 016
017 017
018 018
019 #ifndef _SOS_USER_LIBC_H_ 019 #ifndef _SOS_USER_LIBC_H_
020 #define _SOS_USER_LIBC_H_ 020 #define _SOS_USER_LIBC_H_
021 021
022 #include <types.h> 022 #include <types.h>
023 023
024 024
025 025
026 026
027 027
028 028
029 029
030 030
031 031
032 032
033 void exit (int status) !! 033 void exit (int status);
034 __attribute__((noreturn, alias("_sos_exit <<
035 034
036 035
037 036
038 037
039 038
040 pid_t fork(void) !! 039 pid_t fork(void);
041 __attribute__ ((alias("_sos_fork"))); <<
042 040
043 041
044 042
045 043
046 044
047 045
048 int exec(const char *progname) !! 046 int exec(const char *progname);
049 __attribute__ ((alias("_sos_exec"))); <<
050 047
051 048
052 int nanosleep(unsigned long int sec, 049 int nanosleep(unsigned long int sec,
053 unsigned long int nanosec) !! 050 unsigned long int nanosec);
054 __attribute__ ((alias("_sos_nanosleep"))) !! 051
>> 052
>> 053 int sleep(unsigned int seconds);
>> 054
055 055
056 056
057 057
058 058
059 059
060 #define PROT_NONE 0 060 #define PROT_NONE 0
061 #define PROT_READ (1<<0) 061 #define PROT_READ (1<<0)
062 #define PROT_WRITE (1<<1) 062 #define PROT_WRITE (1<<1)
063 #define PROT_EXEC (1<<2) 063 #define PROT_EXEC (1<<2)
064 064
065 #define MAP_SHARED (1 << 0) 065 #define MAP_SHARED (1 << 0)
066 #define MAP_FIXED (1 << 31) 066 #define MAP_FIXED (1 << 31)
067 067
068 <<
069 <<
070 <<
071 <<
072 <<
073 <<
074 void * fakemmap(void *start, size_t length, in <<
075 const char *path, loff_t offse <<
076 <<
077 068
078 069
079 070
080 071
081 int munmap(void * start, size_t length) !! 072 int munmap(void * start, size_t length);
082 __attribute__ ((alias("_sos_munmap"))); <<
083 073
084 074
085 075
086 076
087 077
088 int mprotect(const void *addr, size_t len, int !! 078 int mprotect(const void *addr, size_t len, int prot);
089 __attribute__ ((alias("_sos_mprotect"))); <<
090 <<
091 079
092 080
093 081
094 082
095 083
096 #define MREMAP_MAYMOVE (1 << 30) 084 #define MREMAP_MAYMOVE (1 << 30)
097 085
098 086
099 087
100 088
101 void * mremap(void * old_addr, size_t old_len, 089 void * mremap(void * old_addr, size_t old_len,
102 size_t new_len, 090 size_t new_len,
103 unsigned long flags); 091 unsigned long flags);
104 092
105 093
106 094
107 095
108 096
109 097
110 098
111 int brk(void *end_data_seg); 099 int brk(void *end_data_seg);
112 100
113 101
114 void *sbrk(ptrdiff_t increment); 102 void *sbrk(ptrdiff_t increment);
115 103
116 104
117 void * calloc (size_t nmemb, size_t size); 105 void * calloc (size_t nmemb, size_t size);
118 106
119 107
120 void * malloc (size_t size); 108 void * malloc (size_t size);
121 109
122 110
123 void free(void *ptr); 111 void free(void *ptr);
124 112
125 113
126 114
127 115
128 116
129 117
130 int mount(const char *source, const char *targ 118 int mount(const char *source, const char *target,
131 const char *filesystemtype, unsigned 119 const char *filesystemtype, unsigned long mountflags,
132 const char *data) !! 120 const char *data);
133 __attribute__ ((alias("_sos_mount"))); !! 121
134 int umount(const char *target) !! 122
135 __attribute__ ((alias("_sos_umount"))); !! 123 int umount(const char *target);
136 void sync(void) !! 124
137 __attribute__ ((alias("_sos_sync"))); !! 125
>> 126 void sync(void);
>> 127
138 128
139 struct statvfs 129 struct statvfs
140 { 130 {
>> 131 unsigned int f_rdev_major;
>> 132 unsigned int f_rdev_minor;
141 size_t f_sz_total; 133 size_t f_sz_total;
142 size_t f_sz_free; 134 size_t f_sz_free;
143 unsigned int f_node_total; 135 unsigned int f_node_total;
144 unsigned int f_node_avail; 136 unsigned int f_node_avail;
145 unsigned int f_flags; 137 unsigned int f_flags;
146 }; 138 };
147 139
148 int statvfs(const char *path, struct statvfs * !! 140 int statvfs(const char *path, struct statvfs *buf);
149 __attribute__ ((alias("_sos_statvfs"))); !! 141
150 142
151 #define O_EXCL (1 << 0) 143 #define O_EXCL (1 << 0)
152 #define O_CREAT (1 << 1) 144 #define O_CREAT (1 << 1)
153 #define O_NOFOLLOW (1 << 2) !! 145 #define O_TRUNC (1 << 2)
154 #define O_DIRECTORY (1 << 3) !! 146 #define O_NOFOLLOW (1 << 3)
155 #define O_SYNC (1 << 4) !! 147 #define O_DIRECTORY (1 << 4)
>> 148 #define O_SYNC (1 << 5)
156 149
157 #define O_RDONLY (1 << 16) 150 #define O_RDONLY (1 << 16)
158 #define O_WRONLY (1 << 17) 151 #define O_WRONLY (1 << 17)
159 #define O_RDWR (O_RDONLY | O_WRONLY) 152 #define O_RDWR (O_RDONLY | O_WRONLY)
160 153
161 154
162 155
163 156
164 #define S_IRUSR 00400 157 #define S_IRUSR 00400
165 #define S_IWUSR 00200 158 #define S_IWUSR 00200
166 #define S_IXUSR 00100 159 #define S_IXUSR 00100
167 #define S_IRWXALL 07777 160 #define S_IRWXALL 07777
168 161
169 int open(const char *pathname, int flags, 162 int open(const char *pathname, int flags, ...);
170 163
171 int close(int fd) !! 164 int close(int fd);
172 __attribute__ ((alias("_sos_close"))); !! 165
173 166
174 int read(int fd, char * buf, size_t len); 167 int read(int fd, char * buf, size_t len);
175 int write(int fd, const char * buf, size_t len 168 int write(int fd, const char * buf, size_t len);
176 169
177 170
178 #define SEEK_SET 42 171 #define SEEK_SET 42
179 #define SEEK_CUR 24 172 #define SEEK_CUR 24
180 #define SEEK_END 84 173 #define SEEK_END 84
181 off_t lseek(int fd, off_t offset, int whence); 174 off_t lseek(int fd, off_t offset, int whence);
182 loff_t lseek64(int fd, loff_t offset, int when 175 loff_t lseek64(int fd, loff_t offset, int whence);
183 void * mmap(void *start, size_t length, int pr 176 void * mmap(void *start, size_t length, int prot , int flags,
184 int fd, loff_t offset); 177 int fd, loff_t offset);
185 int ftruncate(int fd, off_t length); 178 int ftruncate(int fd, off_t length);
186 int ftruncate64(int fd, loff_t length) !! 179 int ftruncate64(int fd, loff_t length);
187 __attribute__ ((alias("_sos_ftruncate64") !! 180 int fcntl(int fd, int cmd, int arg);
188 int fcntl(int fd, int cmd, int arg) !! 181 int ioctl(int fd, int cmd, int arg);
189 __attribute__ ((alias("_sos_fcntl"))); !! 182
190 !! 183 int creat(const char *pathname, mode_t mode);
191 int creat(const char *pathname, mode_t mode) !! 184 int link (const char *oldpath, const char *newpath);
192 __attribute__ ((alias("_sos_creat"))); !! 185 int unlink(const char *pathname);
193 int link (const char *oldpath, const char *new !! 186 int rename(const char *oldpath, const char *newpath);
194 __attribute__ ((alias("_sos_link"))); !! 187 int symlink(const char *target, const char *path);
195 int unlink(const char *pathname) !! 188
196 __attribute__ ((alias("_sos_unlink"))); !! 189
197 int rename(const char *oldpath, const char *ne !! 190 #define S_IFREG 0x42
198 __attribute__ ((alias("_sos_rename"))); !! 191 #define S_IFDIR 0x24
199 int symlink(const char *target, const char *pa !! 192 #define S_IFLNK 0x84
200 __attribute__ ((alias("_sos_symlink"))); !! 193 #define S_IFCHR 0x48
201 !! 194 int mknod(const char *pathname, mode_t mode,
202 int mkdir(const char *pathname, mode_t mode) !! 195 int type,
203 __attribute__ ((alias("_sos_mkdir"))); !! 196 unsigned int major, unsigned minor);
204 int rmdir(const char *pathname) !! 197
205 __attribute__ ((alias("_sos_rmdir"))); !! 198
>> 199 int mkdir(const char *pathname, mode_t mode);
>> 200
>> 201
>> 202 int rmdir(const char *pathname);
>> 203
>> 204
>> 205 int chmod(const char *path, mode_t mode);
206 206
207 int chmod(const char *path, mode_t mode) <<
208 __attribute__ ((alias("_sos_chmod"))); <<
209 207
210 struct dirent 208 struct dirent
211 { 209 {
212 unsigned long long int storage_location; 210 unsigned long long int storage_location;
213 unsigned long long int offset_in_dirfile; 211 unsigned long long int offset_in_dirfile;
214 <<
215 <<
216 #define S_IFREG 0x42 <<
217 #define S_IFDIR 0x24 <<
218 #define S_IFLNK 0x84 <<
219 unsigned int type; 212 unsigned int type;
220 unsigned short namelen; 213 unsigned short namelen;
221 214
222 #define SOS_FS_DIRENT_NAME_MAXLEN 128 215 #define SOS_FS_DIRENT_NAME_MAXLEN 128
223 char name[SOS_FS_DIRENT_NAME_MAXLEN]; 216 char name[SOS_FS_DIRENT_NAME_MAXLEN];
224 }; 217 };
225 218
226 219
227 struct sos_DIR_struct; 220 struct sos_DIR_struct;
228 #define DIR struct sos_DIR_struct 221 #define DIR struct sos_DIR_struct
229 222
230 DIR *opendir(const char *name); 223 DIR *opendir(const char *name);
231 int dirfd(const DIR * dir); 224 int dirfd(const DIR * dir);
232 struct dirent *readdir(DIR *dir); 225 struct dirent *readdir(DIR *dir);
233 int closedir(DIR *dir); 226 int closedir(DIR *dir);
234 227
235 struct stat 228 struct stat
236 { 229 {
>> 230 unsigned int st_rdev_major;
>> 231 unsigned int st_rdev_minor;
237 int st_type; 232 int st_type;
238 unsigned long long int st_storage_location; 233 unsigned long long int st_storage_location;
239 int st_access_rights; 234 int st_access_rights;
240 unsigned int st_nlink; 235 unsigned int st_nlink;
241 signed long long int st_size; 236 signed long long int st_size;
242 }; 237 };
243 238
244 int stat(const char *file_name, struct stat *b 239 int stat(const char *file_name, struct stat *buf);
245 int lstat(const char *file_name, struct stat * 240 int lstat(const char *file_name, struct stat *buf);
>> 241 int chroot(const char *path);
>> 242 int chdir(const char *path);
>> 243 int fchdir(int fd);
246 244
247 int chroot(const char *path) !! 245 int printf(const char *, ...);
248 __attribute__ ((alias("_sos_chroot"))); <<
249 int chdir(const char *path) <<
250 __attribute__ ((alias("_sos_chdir"))); <<
251 int fchdir(int fd) <<
252 __attribute__ ((alias("_sos_fchdir"))); <<
253 <<
254 <<
255 246
256 #endif 247 #endif