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