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