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 ]

Diff markup

Differences between /userland/libc.h (Article 7.5) and /userland/libc.h (Article 9)


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

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