diff options
author | Thomas Bushnell <thomas@gnu.org> | 1999-10-06 14:43:23 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1999-10-06 14:43:23 +0000 |
commit | e74a41ddb8371c800004c99b80ef0b564128884b (patch) | |
tree | 63b611c651490ad0e2d84cc33dd1ddbf2ad1d674 /libdiskfs/lookup.c | |
parent | 6edeb62e3980f1a3769ed74cb81567744b5b6e92 (diff) | |
download | hurd-e74a41ddb8371c800004c99b80ef0b564128884b.tar.gz hurd-e74a41ddb8371c800004c99b80ef0b564128884b.tar.bz2 hurd-e74a41ddb8371c800004c99b80ef0b564128884b.zip |
1999-10-06 Thomas Bushnell, BSG <tb@mit.edu>
* lookup.c (diskfs_lookup): NAME is no longer const. Update
documentation Strip leading and trailing slashes from NAME before
using it.
* diskfs.h (diskfs_lookup): NAME is no longer const.
Update documentation.
1999-10-05 Thomas Bushnell, BSG <tb@mit.edu>
* priv.h (CHANGE_NODE_FIELD): Use diskfs_check_readonly instead of
directly reading diskfs_readonly.
Diffstat (limited to 'libdiskfs/lookup.c')
-rw-r--r-- | libdiskfs/lookup.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/libdiskfs/lookup.c b/libdiskfs/lookup.c index 3ec9dd87..2a117905 100644 --- a/libdiskfs/lookup.c +++ b/libdiskfs/lookup.c @@ -33,7 +33,12 @@ static spin_lock_t cm_lock = SPIN_LOCK_INITIALIZER; /* Lookup in directory DP (which is locked) the name NAME. TYPE will either be LOOKUP, CREATE, RENAME, or REMOVE. CRED identifies the - user making the call. + user making the call. + + NAME will have leading and trailing slashes stripped. It is an + error if there are internal slashes. NAME will be modified in + place if there are slashes in it; it is therefore an error to + specify a constant NAME which contains slashes. If the name is found, return zero, and (if NP is nonzero) set *NP to point to the node for it, locked. If the name is not found, @@ -74,14 +79,14 @@ static spin_lock_t cm_lock = SPIN_LOCK_INITIALIZER; Return EAGAIN if NAME refers to the `..' of this filesystem's root. Return EIO if appropriate. - This function is a wrapper for diskfs_lookup_hard. -*/ + This function is a wrapper for diskfs_lookup_hard. */ error_t -diskfs_lookup (struct node *dp, const char *name, enum lookup_type type, +diskfs_lookup (struct node *dp, char *name, enum lookup_type type, struct node **np, struct dirstat *ds, struct protid *cred) { error_t err; struct node *cached; + size_t len; if (type == REMOVE || type == RENAME) assert (np); @@ -93,7 +98,19 @@ diskfs_lookup (struct node *dp, const char *name, enum lookup_type type, return ENOTDIR; } - if (name[0] == '\0') + /* Strip leading and trailing slashes. */ + while (*name == '/') + name++; + + if (*name != '\0') + { + for (len = strlen (name); name[len-1] == '/'; len--) + ; + if (name[len] != '\0') + name[len] = '\0'; + } + + if (strchr (name, '/') !! name[0] == '\0') { if (ds) diskfs_null_dirstat (ds); |