Changeset 0b18364 in mainline
- Timestamp:
- 2013-07-24T20:43:38Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a8c188
- Parents:
- cb65bbe
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vfs/vfs.c
rcb65bbe r0b18364 90 90 { 91 91 async_exchange_end(exch); 92 } 93 94 int _vfs_walk(int parent, const char *path, int flags) 95 { 96 async_exch_t *exch = vfs_exchange_begin(); 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 ipc_call_t answer; 104 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); 108 vfs_exchange_end(exch); 109 110 sysarg_t rc_orig; 111 async_wait_for(req, &rc_orig); 112 113 if (rc_orig != EOK) { 114 return (int) rc_orig; 115 } 116 117 if (rc != EOK) { 118 return (int) rc; 119 } 120 121 return (int) IPC_GET_ARG1(answer); 122 } 123 124 int _vfs_open(int fildes, int mode) 125 { 126 async_exch_t *exch = vfs_exchange_begin(); 127 sysarg_t rc = async_req_2_0(exch, VFS_IN_OPEN2, fildes, mode); 128 vfs_exchange_end(exch); 129 130 return (int) rc; 92 131 } 93 132 -
uspace/lib/c/include/ipc/vfs.h
rcb65bbe r0b18364 181 181 //WALK_PARTIAL = (1 << 0), 182 182 183 WALK_ALL_FLAGS = 0, 183 WALK_MAY_CREATE = (1 << 1), 184 WALK_MUST_CREATE = (1 << 2), 185 186 WALK_REGULAR = (1 << 3), 187 WALK_DIRECTORY = (1 << 4), 188 189 WALK_ALL_FLAGS = WALK_MAY_CREATE | WALK_MUST_CREATE | WALK_REGULAR | WALK_DIRECTORY, 184 190 }; 185 191 -
uspace/lib/c/include/vfs/vfs.h
rcb65bbe r0b18364 62 62 extern void vfs_exchange_end(async_exch_t *); 63 63 64 extern int _vfs_walk(int parent, const char *path, int flags); 65 extern int _vfs_open(int file, int mode); 66 64 67 #endif 65 68 -
uspace/srv/vfs/vfs_ops.c
rcb65bbe r0b18364 568 568 } 569 569 570 static inline bool walk_flags_valid(int flags) 571 { 572 if ((flags&~WALK_ALL_FLAGS) != 0) { 573 return false; 574 } 575 if ((flags&WALK_MAY_CREATE) && (flags&WALK_MUST_CREATE)) { 576 return false; 577 } 578 if ((flags&WALK_REGULAR) && (flags&WALK_DIRECTORY)) { 579 return false; 580 } 581 if ((flags&WALK_MAY_CREATE) || (flags&WALK_MUST_CREATE)) { 582 if (!(flags&WALK_DIRECTORY) && !(flags&WALK_REGULAR)) { 583 return false; 584 } 585 } 586 return true; 587 } 588 589 static inline int walk_lookup_flags(int flags) 590 { 591 int lflags = 0; 592 if (flags&WALK_MAY_CREATE || flags&WALK_MUST_CREATE) { 593 lflags |= L_CREATE; 594 } 595 if (flags&WALK_MUST_CREATE) { 596 lflags |= L_EXCLUSIVE; 597 } 598 if (flags&WALK_REGULAR) { 599 lflags |= L_FILE; 600 } 601 if (flags&WALK_DIRECTORY) { 602 lflags |= L_DIRECTORY; 603 } 604 return lflags; 605 } 606 570 607 void vfs_walk(ipc_callid_t rid, ipc_call_t *request) 571 608 { … … 577 614 int flags = IPC_GET_ARG2(*request); 578 615 579 if ((flags&~WALK_ALL_FLAGS) != 0) { 580 /* Invalid flags. */ 616 if (!walk_flags_valid(flags)) { 581 617 async_answer_0(rid, EINVAL); 582 618 return; … … 603 639 604 640 vfs_lookup_res_t lr; 605 rc = vfs_lookup_internal(path, 0, &lr, parent_node);641 rc = vfs_lookup_internal(path, walk_lookup_flags(flags), &lr, parent_node); 606 642 free(path); 607 643
Note:
See TracChangeset
for help on using the changeset viewer.