Changes in uspace/lib/posix/source/unistd.c [0d0b319:1165a419] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/source/unistd.c
r0d0b319 r1165a419 40 40 #include "posix/unistd.h" 41 41 42 #include <errno.h> 43 42 #include "posix/errno.h" 44 43 #include "posix/string.h" 45 44 #include "posix/fcntl.h" … … 53 52 #include <libarch/config.h> 54 53 55 // FIXME: replace with a hash table56 54 aoff64_t posix_pos[MAX_OPEN_FILES]; 57 55 … … 128 126 char *posix_getcwd(char *buf, size_t size) 129 127 { 130 if (failed(vfs_cwd_get(buf, size))) 128 int rc = rcerrno(vfs_cwd_get, buf, size); 129 if (rc != EOK) 131 130 return NULL; 132 131 return buf; … … 140 139 int posix_chdir(const char *path) 141 140 { 142 if (failed(vfs_cwd_set(path))) 141 int rc = rcerrno(vfs_cwd_set, path); 142 if (rc != EOK) 143 143 return -1; 144 144 return 0; … … 196 196 { 197 197 posix_pos[fildes] = 0; 198 if (failed(vfs_put(fildes))) 198 int rc = rcerrno(vfs_put, fildes); 199 if (rc != EOK) 199 200 return -1; 200 201 else … … 212 213 ssize_t posix_read(int fildes, void *buf, size_t nbyte) 213 214 { 214 s ize_t nread;215 if ( failed(vfs_read(fildes, &posix_pos[fildes], buf, nbyte, &nread)))216 return -1; 217 return (ssize_t) nread;215 ssize_t size = rcerrno(vfs_read, fildes, &posix_pos[fildes], buf, nbyte); 216 if (size < 0) 217 return -1; 218 return size; 218 219 } 219 220 … … 228 229 ssize_t posix_write(int fildes, const void *buf, size_t nbyte) 229 230 { 230 s ize_t nwr;231 if ( failed(vfs_write(fildes, &posix_pos[fildes], buf, nbyte, &nwr)))232 return -1; 233 return nwr;231 ssize_t size = rcerrno(vfs_write, fildes, &posix_pos[fildes], buf, nbyte); 232 if (size < 0) 233 return -1; 234 return size; 234 235 } 235 236 … … 246 247 { 247 248 struct stat st; 249 int rc; 248 250 249 251 switch (whence) { … … 255 257 break; 256 258 case SEEK_END: 257 if (failed(vfs_stat(fildes, &st))) 259 rc = rcerrno(vfs_stat, fildes, &st); 260 if (rc != EOK) 258 261 return -1; 259 262 posix_pos[fildes] = st.size + offset; … … 276 279 int posix_fsync(int fildes) 277 280 { 278 if ( failed(vfs_sync(fildes)))281 if (rcerrno(vfs_sync, fildes) != EOK) 279 282 return -1; 280 283 else … … 291 294 int posix_ftruncate(int fildes, posix_off_t length) 292 295 { 293 if ( failed(vfs_resize(fildes, (aoff64_t) length)))296 if (rcerrno(vfs_resize, fildes, (aoff64_t) length) != EOK) 294 297 return -1; 295 298 else … … 305 308 int posix_rmdir(const char *path) 306 309 { 307 if ( failed(vfs_unlink_path(path)))310 if (rcerrno(vfs_unlink_path, path) != EOK) 308 311 return -1; 309 312 else … … 319 322 int posix_unlink(const char *path) 320 323 { 321 if ( failed(vfs_unlink_path(path)))324 if (rcerrno(vfs_unlink_path, path) != EOK) 322 325 return -1; 323 326 else … … 346 349 int posix_dup2(int fildes, int fildes2) 347 350 { 348 int file; 349 if (failed(vfs_clone(fildes, fildes2, false, &file))) { 350 return -1; 351 } 352 return file; 351 return negerrno(vfs_clone, fildes, fildes2, false); 353 352 } 354 353
Note:
See TracChangeset
for help on using the changeset viewer.