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