Changeset d6084ef in mainline for uspace/srv/vfs/vfs_lookup.c
- Timestamp:
- 2008-03-02T15:05:26Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dadcec1
- Parents:
- 9bb85f3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_lookup.c
r9bb85f3 rd6084ef 50 50 51 51 /* Forward static declarations. */ 52 static char *canonify(char *path );52 static char *canonify(char *path, size_t *lenp); 53 53 54 54 atomic_t plb_futex = FUTEX_INITIALIZER; … … 58 58 /** Perform a path lookup. 59 59 * 60 * @param path Path to be resolved; it needn't be an ASCIIZ string.61 * @param len Number of path characters pointed by path.60 * @param path Path to be resolved; it must be a NULL-terminated 61 * string. 62 62 * @param lflag Flags to be used during lookup. 63 63 * @param result Empty structure where the lookup result will be stored. … … 68 68 * @return EOK on success or an error code from errno.h. 69 69 */ 70 int vfs_lookup_internal(char *path, size_t len, int lflag,71 vfs_ lookup_res_t *result, vfs_pair_t *altroot)70 int vfs_lookup_internal(char *path, int lflag, vfs_lookup_res_t *result, 71 vfs_pair_t *altroot) 72 72 { 73 73 vfs_pair_t *root; 74 75 if (!len)76 return EINVAL;77 74 78 75 if (altroot) … … 83 80 if (!root->fs_handle) 84 81 return ENOENT; 82 83 size_t len; 84 path = canonify(path, &len); 85 if (!path) 86 return EINVAL; 85 87 86 88 futex_down(&plb_futex); … … 274 276 static void terminate_slash(token_t *t, token_t *tfsl, token_t *tlcomp) 275 277 { 276 tfsl->stop[1] = '\0'; 278 if (tfsl->stop[1]) /* avoid writing to a well-formatted path */ 279 tfsl->stop[1] = '\0'; 277 280 } 278 281 static void remove_trailing_slash(token_t *t, token_t *tfsl, token_t *tlcomp) … … 435 438 * It works in-place and requires a NULL-terminated input string. 436 439 * 437 * @param Path to be canonified. 440 * @param path Path to be canonified. 441 * @param lenp Pointer where the length of the final path will be 442 * stored. Can be NULL. 438 443 * 439 444 * @return Canonified path or NULL on failure. 440 445 */ 441 char *canonify(char *path )446 char *canonify(char *path, size_t *lenp) 442 447 { 443 448 state_t state; … … 451 456 state = S_INI; 452 457 t = tfsl; 458 tlcomp = tfsl; 453 459 while (state != S_ACCEPT && state != S_RESTART && state != S_REJECT) { 454 460 if (trans[state][t.kind].f) … … 464 470 return NULL; 465 471 case S_ACCEPT: 472 if (lenp) 473 *lenp = (size_t)((tlcomp.stop - tfsl.start) + 1); 466 474 return tfsl.start; 467 475 default:
Note:
See TracChangeset
for help on using the changeset viewer.