Changeset 3ef62df in mainline
- Timestamp:
- 2013-07-24T22:29:51Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9b48c06
- Parents:
- 1393bbb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vfs/vfs.c
r1393bbb r3ef62df 96 96 async_exch_t *exch = vfs_exchange_begin(); 97 97 98 // TODO: assume this is done at a higher level.99 char *precanon = str_dup(path);100 size_t canon_size;101 char *canon = canonify(precanon, &canon_size);102 103 98 ipc_call_t answer; 104 99 aid_t req = async_send_2(exch, VFS_IN_WALK, parent, flags, &answer); 105 sysarg_t rc = async_data_write_start(exch, canon, canon_size); 106 107 free(precanon); 100 sysarg_t rc = async_data_write_start(exch, path, str_size(path)); 108 101 vfs_exchange_end(exch); 109 102 … … 327 320 } 328 321 322 static int walk_flags(int oflags) 323 { 324 int flags = 0; 325 if (oflags & O_CREAT) { 326 if (oflags & O_EXCL) { 327 flags |= WALK_MUST_CREATE; 328 } else { 329 flags |= WALK_MAY_CREATE; 330 } 331 } 332 return flags; 333 } 334 329 335 static int open_internal(const char *abs, size_t abs_size, int lflag, int oflag) 330 336 { … … 365 371 int open(const char *path, int oflag, ...) 366 372 { 373 // FIXME: Some applications call this incorrectly. 374 if ((oflag & (O_RDONLY|O_WRONLY|O_RDWR)) == 0) { 375 oflag |= O_RDWR; 376 } 377 378 assert((((oflag & O_RDONLY) != 0) + ((oflag & O_WRONLY) != 0) + ((oflag & O_RDWR) != 0)) == 1); 379 367 380 size_t abs_size; 368 381 char *abs = absolutize(path, &abs_size); 369 if (!abs) 382 if (!abs) { 370 383 return ENOMEM; 371 372 int ret = open_internal(abs, abs_size, L_FILE, oflag); 373 free(abs); 374 384 } 385 386 int ret = _vfs_walk(-1, abs, walk_flags(oflag) | WALK_REGULAR); 387 if (ret < 0) { 388 return ret; 389 } 390 391 int mode = 392 ((oflag & O_RDWR) ? MODE_READ|MODE_WRITE : 0) | 393 ((oflag & O_RDONLY) ? MODE_READ : 0) | 394 ((oflag & O_WRONLY) ? MODE_WRITE : 0) | 395 ((oflag & O_APPEND) ? MODE_APPEND : 0); 396 397 int rc = _vfs_open(ret, mode); 398 if (rc < 0) { 399 // _vfs_put(ret); 400 close(ret); 401 return rc; 402 } 403 404 if (oflag & O_TRUNC) { 405 assert(oflag & O_WRONLY || oflag & O_RDWR); 406 assert(!(oflag & O_APPEND)); 407 408 // _vfs_resize 409 (void) ftruncate(ret, 0); 410 } 411 375 412 return ret; 376 413 }
Note:
See TracChangeset
for help on using the changeset viewer.