Changeset 221afc9e in mainline for uspace/lib/posix/unistd.c
- Timestamp:
- 2011-07-12T02:43:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2346e78
- Parents:
- 46ac986
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/unistd.c
r46ac986 r221afc9e 94 94 95 95 /** 96 * Get the pathname of the current working directory. 97 * 98 * @param buf Buffer into which the pathname shall be put. 99 * @param size Size of the buffer. 100 * @return Buffer pointer on success, NULL on failure. 101 */ 102 char *posix_getcwd(char *buf, size_t size) 103 { 104 /* Native getcwd() does not set any errno despite the fact that general 105 * usage pattern of this function depends on it (caller is repeatedly 106 * guessing the required size of the buffer by checking for ERANGE on 107 * failure). */ 108 if (size == 0) { 109 errno = EINVAL; 110 return NULL; 111 } 112 char *ret = getcwd(buf, size); 113 if (ret == NULL && errno == EOK) { 114 errno = ERANGE; 115 } 116 return ret; 117 } 118 119 /** 96 120 * Determine the page size of the current run of the process. 97 121 * … … 133 157 /* There is currently no support for user accounts in HelenOS. */ 134 158 return 0; 159 } 160 161 /** 162 * Read from a file. 163 * 164 * @param fildes File descriptor of the opened file. 165 * @param buf Buffer to which the read bytes shall be stored. 166 * @param nbyte Upper limit on the number of read bytes. 167 * @return Number of read bytes on success, -1 otherwise. 168 */ 169 ssize_t posix_read(int fildes, void *buf, size_t nbyte) 170 { 171 int rc = read(fildes, buf, nbyte); 172 if (rc < 0) { 173 errno = -rc; 174 return -1; 175 } else { 176 return rc; 177 } 178 } 179 180 /** 181 * Remove a link to a file. 182 * 183 * @param path File pathname. 184 * @return Zero on success, -1 otherwise. 185 */ 186 int posix_unlink(const char *path) 187 { 188 int rc = unlink(path); 189 if (rc < 0) { 190 errno = -rc; 191 return -1; 192 } else { 193 return rc; 194 } 135 195 } 136 196
Note:
See TracChangeset
for help on using the changeset viewer.