SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

001 /* Copyright (C) 2005 David Decotigny
002    Copyright (C) 2003 Thomas Petazzoni
003 
004    This program is free software; you can redistribute it and/or
005    modify it under the terms of the GNU General Public License
006    as published by the Free Software Foundation; either version 2
007    of the License, or (at your option) any later version.
008    
009    This program is distributed in the hope that it will be useful,
010    but WITHOUT ANY WARRANTY; without even the implied warranty of
011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012    GNU General Public License for more details.
013    
014    You should have received a copy of the GNU General Public License
015    along with this program; if not, write to the Free Software
016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
017    USA. 
018 */
019 #ifndef _SOS_USER_LIBC_H_
020 #define _SOS_USER_LIBC_H_
021 
022 #include <types.h>
023 
024 /**
025  * @file libc.h
026  *
027  * The basic user C library for user programs
028  */
029 
030 /**
031  * The most important function of a C program ! ;)
032  */
033 void exit (int status);
034 
035 
036 /**
037  * Function to duplicate the current running process
038  */
039 pid_t fork(void);
040 
041 
042 /**
043  * Function to re-initialize the address space of the current process
044  * with that of the program 'progname'
045  */
046 int exec(const char *progname);
047 
048 
049 int nanosleep(unsigned long int sec,
050               unsigned long int nanosec);
051 
052 
053 int sleep(unsigned int seconds);
054 
055 
056 /**
057  * These flags (for mmap API) MUST be consistent with those defined in
058  * paging.h and umem_vmm.h
059  */
060 #define PROT_NONE  0
061 #define PROT_READ  (1<<0)
062 #define PROT_WRITE (1<<1)
063 #define PROT_EXEC  (1<<2) /* Not supported on IA32 */
064 
065 #define MAP_PRIVATE (0 << 0)
066 #define MAP_SHARED  (1 << 0)
067 #define MAP_FIXED   (1 << 31)
068 
069 
070 /**
071  * Unmap the given user address interval
072  */
073 int munmap(void * start, size_t length);
074 
075 
076 /**
077  * Change the access permissions of the given user address interval
078  */
079 int mprotect(const void *addr, size_t len, int prot);
080 
081 
082 /**
083  * This flag tells mremap that the underlying VR may be moved, when necessary
084  */
085 #define MREMAP_MAYMOVE (1 << 30)
086 
087 /**
088  * Grow/shrink the end of the given mapping
089  */
090 void * mremap(void * old_addr, size_t old_len,
091               size_t new_len,
092               unsigned long flags);
093 
094 
095 /** Flags for msync */
096 #define MS_SYNC  (1 << 0)
097 #define MS_ASYNC (0 << 0)
098 
099 /** Synchronize cache contents with mapped memory */
100 int msync(void *start, size_t length, int flags);
101 
102 
103 /**
104  * Standard heap management API
105  */
106 
107 /** @note MT UNSAFE */
108 int brk(void *end_data_seg);
109 
110 /** @note MT UNSAFE */
111 void *sbrk(ptrdiff_t increment);
112 
113 /** @note MT UNSAFE */
114 void * calloc (size_t nmemb, size_t size);
115 
116 /** @note MT UNSAFE */
117 void * malloc (size_t size);
118 
119 /** @note Does nothing (not implemented yet) */
120 void free(void *ptr);
121 
122 
123 /*
124  * Filesystem subsystem
125  */
126 
127 int mount(const char *source, const char *target,
128           const char *filesystemtype, unsigned long mountflags,
129           const char *data);
130 
131 
132 int umount(const char *target);
133 
134 
135 void sync(void);
136 
137 
138 struct statvfs
139 {
140   unsigned int  f_rdev_major;
141   unsigned int  f_rdev_minor;
142   size_t        f_sz_total;  /**< Total size */
143   size_t        f_sz_free;   /**< Size left on device */
144   unsigned int  f_node_total;/**< Total allocatable FS nodes */
145   unsigned int  f_node_avail;/**< Number of available free FS nodes */
146   unsigned int  f_flags;
147 };
148 
149 int statvfs(const char *path, struct statvfs *buf);
150 
151 
152 #define O_EXCL      (1 << 0)
153 #define O_CREAT     (1 << 1)
154 #define O_TRUNC     (1 << 2)
155 #define O_NOFOLLOW  (1 << 3)
156 #define O_DIRECTORY (1 << 4) /* Incompatible with CREAT/TRUNC */
157 #define O_SYNC      (1 << 5)
158 
159 #define O_RDONLY    (1 << 16)
160 #define O_WRONLY    (1 << 17)
161 #define O_RDWR      (O_RDONLY | O_WRONLY)
162 
163 /**
164  * FS access rights. Same as in kernel fs.h
165  */
166 #define S_IRUSR     00400
167 #define S_IWUSR     00200
168 #define S_IXUSR     00100
169 #define S_IRWXALL   07777 /* For symlinks */
170 
171 int open(const char *pathname, int flags, /* mode_t mode */...);
172 
173 int close(int fd);
174 
175 
176 int read(int fd, char * buf, size_t len);
177 int write(int fd, const char * buf, size_t len);
178 
179 /* Same as sos_seek_whence_t in kernel fs.h */
180 #define SEEK_SET 42
181 #define SEEK_CUR 24
182 #define SEEK_END 84
183 off_t lseek(int fd, off_t offset, int whence);
184 loff_t lseek64(int fd, loff_t offset, int whence);
185 void * mmap(void *start, size_t length, int prot , int flags,
186             int fd, loff_t offset);
187 int ftruncate(int fd, off_t length);
188 int ftruncate64(int fd, loff_t length);
189 int fcntl(int fd, int cmd, int arg);
190 int ioctl(int fd, int cmd, int arg);
191 
192 int creat(const char *pathname, mode_t mode);
193 int link (const char *oldpath, const char *newpath);
194 int unlink(const char *pathname);
195 int rename(const char *oldpath, const char *newpath);
196 int symlink(const char *target, const char *path);
197 
198 /* Same as sos_fs_node_type_t in kernel fs.h */
199 #define S_IFREG 0x42
200 #define S_IFDIR 0x24
201 #define S_IFLNK 0x84
202 #define S_IFCHR 0x48
203 #define S_IFBLK 0x12
204 int mknod(const char *pathname, mode_t mode,
205           int type,
206           unsigned int major, unsigned minor);
207 
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 
217 
218 struct dirent
219 {
220   unsigned long long int storage_location;
221   unsigned long long int offset_in_dirfile;
222   unsigned int type;
223   unsigned short namelen;
224 
225 #define SOS_FS_DIRENT_NAME_MAXLEN 128
226   char       name[SOS_FS_DIRENT_NAME_MAXLEN];
227 };
228 
229 /* Forward declaration (defined in libc.c) */
230 struct sos_DIR_struct;
231 #define DIR struct sos_DIR_struct
232 
233 DIR *opendir(const char *name);
234 int dirfd(const DIR * dir);
235 struct dirent *readdir(DIR *dir);
236 int closedir(DIR *dir);
237 
238 struct stat
239 {
240   unsigned int           st_rdev_major;
241   unsigned int           st_rdev_minor;
242   int                    st_type;
243   unsigned long long int st_storage_location;
244   int                    st_access_rights;
245   unsigned int           st_nlink;
246   signed long long int   st_size;
247 };
248 
249 int stat(const char *file_name, struct stat *buf);
250 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 
255 int printf(const char *, ...);
256 
257 #endif /* _SOS_USER_LIBC_H_ */

source navigation ] diff markup ] identifier search ] general search ]