Changeset 589 for trunk/libs/mini-libc/unistd.h
- Timestamp:
- Nov 1, 2018, 12:48:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/mini-libc/unistd.h
r476 r589 26 26 27 27 /***************************************************************************************** 28 * This file defines the user level , memory mapping related <mman> library.28 * This file defines the user level <unistd> library. 29 29 * All these functions make a system call to access the kernel structures. 30 30 * The user/kernel shared structures and mnemonics are defined in … … 35 35 36 36 /***************************************************************************************** 37 * This function returns the pathname of the current working directory. 38 ***************************************************************************************** 39 * buf : buffer addres in user space. 40 * nbytes : user buffer size in bytes. 41 * @ return 0 if success / returns -1 if failure. 42 ****************************************************************************************/ 43 int getcwd( char * buf, 44 unsigned int nbytes ); 45 46 /***************************************************************************************** 47 * This function read bytes from an open file identified by the <fd> file descriptor. 48 * This file can be a regular file or a character oriented device. 49 ***************************************************************************************** 50 * @ fd : open file index in fd_array. 51 * @ buf : buffer virtual address in user space. 52 * @ count : number of bytes. 53 * @ return number of bytes actually read if success / returns -1 if failure. 54 ****************************************************************************************/ 55 int read( int fd, 56 void * buf, 57 unsigned int count ); 58 59 /***************************************************************************************** 60 * This function writes bytes to an open file identified by the <fd> file descriptor. 61 * This file can be a regular file or character oriented device. 62 ***************************************************************************************** 63 * @ fd : open file index in fd_array. 64 * @ buf : buffer virtual address in user space. 65 * @ count : number of bytes. 66 * @ return number of bytes actually written if success / returns -1 if failure. 67 ****************************************************************************************/ 68 int write( int fd, 69 const void * buf, 70 unsigned int count ); 71 72 /***************************************************************************************** 73 * This function repositions the offset of the file descriptor identified by <file_id>, 74 * according to the operation type defined by the <whence> argument. 75 ***************************************************************************************** 76 * @ fd : open file index in fd_array. 77 * @ offset : used to compute new offset value. 78 * @ whence : operation type (SEEK_SET / SEEK_CUR / SEEK_END defined in syscalls.h) 79 * @ return 0 if success / returns -1 if failure. 80 ****************************************************************************************/ 81 int lseek( int fd, 82 unsigned int offset, 83 int whence ); 37 * This function sets a timer to deliver the signal SIGALRM to the calling process, 38 * after the specified number of seconds. 39 * If an alarm has already been set with alarm() but has not been delivered, 40 * another call to alarm() will supersede the prior call. 41 * The request alarm(0) cancels the current alarm and the signal will not be delivered. 42 ***************************************************************************************** 43 * @ seconds : number of seconds. 44 * @ returns the amount of time left on the timer from a previous call to alarm(). 45 * If no alarm is currently set, the return value is 0. 46 ****************************************************************************************/ 47 unsigned alarm( unsigned seconds ); 48 49 /***************************************************************************************** 50 * This function change the current working directory in reference process descriptor. 51 ***************************************************************************************** 52 * @ pathname : pathname (can be relative or absolute). 53 * @ return 0 if success / returns -1 if failure. 54 ****************************************************************************************/ 55 int chdir( const char * pathname ); 84 56 85 57 /***************************************************************************************** 86 58 * This function release the memory allocated for the file descriptor identified by 87 * the <file_id> argument, and remove the fd array_entry in all copies of the process 88 * descriptor. 59 * the <fd> argument, and remove the fd array_entry in all process descriptor copies. 89 60 ***************************************************************************************** 90 61 * @ fd : file descriptor index in fd_array. … … 92 63 ****************************************************************************************/ 93 64 int close( int fd ); 94 95 /*****************************************************************************************96 * This function removes a directory entry identified by the <pathname> from the97 * directory, and decrement the link count of the file referenced by the link.98 * If the link count reduces to zero, and no process has the file open, then all resources99 * associated with the file are released. If one or more process have the file open when100 * the last link is removed, the link is removed, but the removal of the file is delayed101 * until all references to it have been closed.102 *****************************************************************************************103 * @ pathname : pathname (can be relative or absolute).104 * @ return 0 if success / returns -1 if failure.105 ****************************************************************************************/106 int unlink( const char * pathname );107 108 /*****************************************************************************************109 * This function creates in the calling thread cluster an unnamed pipe, and two110 * (read and write) file descriptors to access this pipe. The calling function must pass111 * the pointer on the fd[] array.112 * TODO not implemented yet...113 *****************************************************************************************114 * @ fd[0] : [out] read only file descriptor index.115 * @ fd[1] : [out] write only file descriptor index.116 * @ return 0 if success / return -1 if failure.117 ****************************************************************************************/118 int pipe( int fd[2] );119 120 /*****************************************************************************************121 * This function change the current working directory in reference process descriptor.122 *****************************************************************************************123 * @ pathname : pathname (can be relative or absolute).124 * @ return 0 if success / returns -1 if failure.125 ****************************************************************************************/126 int chdir( const char * pathname );127 128 /*****************************************************************************************129 * This function removes a directory file whose name is given by <pathname>.130 * The directory must not have any entries other than `.' and `..'.131 *****************************************************************************************132 * @ pathname : pathname (can be relative or absolute).133 * @ return 0 if success / returns -1 if failure.134 ****************************************************************************************/135 int rmdir( char * pathname );136 137 /*****************************************************************************************138 * This function implement the "fork" system call on the user side.139 * The calling process descriptor (parent process), and the associated thread descriptor140 * are replicated in a - likely - remote cluster, that becomes the new process owner.141 * The child process get a new PID is linked to the parent PID. The child process inherit142 * from the parent process the memory image, and all open files (including the TXT).143 * The child process becomes the TXT terminal owner.144 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be145 * stored in the calling thread descriptor by the specific fork_place() system call.146 * If not, the kernel function makes a query to the DQDT to select the target cluster.147 *****************************************************************************************148 * @ if success, returns child process PID to parent, and return O to child.149 * @ if failure, returns -1 to parent / no child process is created.150 ****************************************************************************************/151 int fork( void );152 65 153 66 /***************************************************************************************** … … 174 87 175 88 /***************************************************************************************** 89 * This function implement the "fork" system call on the user side. 90 * The calling process descriptor (parent process), and the associated thread descriptor 91 * are replicated in a - likely - remote cluster, that becomes the new process owner. 92 * The child process get a new PID is linked to the parent PID. The child process inherit 93 * from the parent process the memory image, and all open files (including the TXT). 94 * The child process becomes the TXT terminal owner. 95 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be 96 * stored in the calling thread descriptor by the specific fork_place() system call. 97 * If not, the kernel function makes a query to the DQDT to select the target cluster. 98 ***************************************************************************************** 99 * @ if success, returns child process PID to parent, and return O to child. 100 * @ if failure, returns -1 to parent / no child process is created. 101 ****************************************************************************************/ 102 int fork( void ); 103 104 /***************************************************************************************** 105 * This function returns the pathname of the current working directory. 106 ***************************************************************************************** 107 * buf : buffer addres in user space. 108 * nbytes : user buffer size in bytes. 109 * @ return 0 if success / returns -1 if failure. 110 ****************************************************************************************/ 111 int getcwd( char * buf, 112 unsigned int nbytes ); 113 114 /***************************************************************************************** 176 115 * This function implements the "getpid" system call on the user side. 177 116 ***************************************************************************************** … … 189 128 190 129 /***************************************************************************************** 191 * This function sets a timer to deliver the signal SIGALRM to the calling process, 192 * after the specified number of seconds. 193 * If an alarm has already been set with alarm() but has not been delivered, 194 * another call to alarm() will supersede the prior call. 195 * The request alarm(0) cancels the current alarm and the signal will not be delivered. 196 ***************************************************************************************** 197 * @ seconds : number of seconds. 198 * @ returns the amount of time left on the timer from a previous call to alarm(). 199 * If no alarm is currently set, the return value is 0. 200 ****************************************************************************************/ 201 unsigned alarm( unsigned seconds ); 130 * This function repositions the offset of the file descriptor identified by <fd>, 131 * according to the operation type defined by the <whence> argument. 132 ***************************************************************************************** 133 * @ fd : open file index in fd_array. 134 * @ offset : used to compute new offset value. 135 * @ whence : operation type (SEEK_SET / SEEK_CUR / SEEK_END) 136 * @ return 0 if success / returns -1 if failure. 137 ****************************************************************************************/ 138 int lseek( int fd, 139 unsigned int offset, 140 int whence ); 141 142 /***************************************************************************************** 143 * This function stops the calling process until any signal is received. 144 ***************************************************************************************** 145 * @ return 0 if success / returns -1 if failure. 146 ****************************************************************************************/ 147 int pause( void ); 148 149 /***************************************************************************************** 150 * This function creates in the calling thread cluster an unnamed pipe, and two 151 * (read and write) file descriptors to access this pipe. The calling function must pass 152 * the pointer on the fd[] array. 153 * TODO not implemented yet... 154 ***************************************************************************************** 155 * @ fd[0] : [out] read only file descriptor index. 156 * @ fd[1] : [out] write only file descriptor index. 157 * @ return 0 if success / return -1 if failure. 158 ****************************************************************************************/ 159 int pipe( int fd[2] ); 160 161 /***************************************************************************************** 162 * This function read bytes from an open file identified by the <fd> file descriptor. 163 * This file can be a regular file or a character oriented device. 164 ***************************************************************************************** 165 * @ fd : open file index in fd_array. 166 * @ buf : buffer virtual address in user space. 167 * @ count : number of bytes. 168 * @ return number of bytes actually read if success / returns -1 if failure. 169 ****************************************************************************************/ 170 int read( int fd, 171 void * buf, 172 unsigned int count ); 173 174 /***************************************************************************************** 175 * This function removes a directory file whose name is given by <pathname>. 176 * The directory must not have any entries other than `.' and `..'. 177 ***************************************************************************************** 178 * @ pathname : pathname (can be relative or absolute). 179 * @ return 0 if success / returns -1 if failure. 180 ****************************************************************************************/ 181 int rmdir( char * pathname ); 182 183 /***************************************************************************************** 184 * This function removes a directory entry identified by the <pathname> from the 185 * directory, and decrement the link count of the file referenced by the link. 186 * If the link count reduces to zero, and no process has the file open, then all resources 187 * associated with the file are released. If one or more process have the file open when 188 * the last link is removed, the link is removed, but the removal of the file is delayed 189 * until all references to it have been closed. 190 ***************************************************************************************** 191 * @ pathname : pathname (can be relative or absolute). 192 * @ return 0 if success / returns -1 if failure. 193 ****************************************************************************************/ 194 int unlink( const char * pathname ); 195 196 /***************************************************************************************** 197 * This function writes bytes to an open file identified by the <fd> file descriptor. 198 * This file can be a regular file or character oriented device. 199 ***************************************************************************************** 200 * @ fd : open file index in fd_array. 201 * @ buf : buffer virtual address in user space. 202 * @ count : number of bytes. 203 * @ return number of bytes actually written if success / returns -1 if failure. 204 ****************************************************************************************/ 205 int write( int fd, 206 const void * buf, 207 unsigned int count ); 202 208 203 209 #endif
Note: See TracChangeset
for help on using the changeset viewer.