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 | |
parent | 6edeb62e3980f1a3769ed74cb81567744b5b6e92 (diff) |
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.
-rw-r--r-- | libdiskfs/ChangeLog | 13 | ||||
-rw-r--r-- | libdiskfs/diskfs.h | 7 | ||||
-rw-r--r-- | libdiskfs/lookup.c | 27 | ||||
-rw-r--r-- | libdiskfs/priv.h | 2 |
4 files changed, 42 insertions, 7 deletions
diff --git a/libdiskfs/ChangeLog b/libdiskfs/ChangeLog index ecf93c4e..b72f761e 100644 --- a/libdiskfs/ChangeLog +++ b/libdiskfs/ChangeLog @@ -1,3 +1,16 @@ +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. + 1999-09-20 Thomas Bushnell, BSG <tb@mit.edu> * node-times.c (diskfs_set_node_times): Don't implement diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 73c55faf..65452c60 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -643,6 +643,11 @@ struct node *diskfs_make_node (struct disknode *dn); either be LOOKUP, CREATE, RENAME, or REMOVE. CRED identifies the 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, return ENOENT, and (if NP is nonzero) set *NP to zero. If NP is @@ -685,7 +690,7 @@ struct node *diskfs_make_node (struct disknode *dn); This function is a wrapper for diskfs_lookup_hard. */ error_t diskfs_lookup (struct node *dp, - const char *name, enum lookup_type type, + char *name, enum lookup_type type, struct node **np, struct dirstat *ds, struct protid *cred); 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); diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h index fca32d16..032d7d09 100644 --- a/libdiskfs/priv.h +++ b/libdiskfs/priv.h @@ -120,7 +120,7 @@ extern fshelp_fetch_root_callback2_t _diskfs_translator_callback2; if (!(PROTID)) \ return EOPNOTSUPP; \ \ - if (diskfs_readonly) \ + if (diskfs_check_readonly ()) \ return EROFS; \ \ np = (PROTID)->po->np; \ |