summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-03-20 21:16:13 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-03-20 21:16:13 +0000
commit30bd04b7b95f717ae2027d1651211e1a7391ac70 (patch)
tree058a8ab84fb290c4e7fb7c19ea902279976da5c4
parent22f6258e833068204f028ae02683249d287387a2 (diff)
(diskfs_lookup): Cleaner.
-rw-r--r--libdiskfs/lookup.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libdiskfs/lookup.c b/libdiskfs/lookup.c
index 2e36798b..5d1c6b19 100644
--- a/libdiskfs/lookup.c
+++ b/libdiskfs/lookup.c
@@ -74,10 +74,10 @@ diskfs_lookup (struct node *dp,
struct protid *cred)
{
error_t err;
- struct node *ournp, **npp;
-
- npp = np ? : &ournp;
+ if (type == REMOVE || type == RENAME)
+ assert (np);
+
if (!S_ISDIR (dp->dn_stat.st_mode))
{
diskfs_null_dirstat (ds);
@@ -106,18 +106,25 @@ diskfs_lookup (struct node *dp,
}
}
- err = diskfs_lookup_hard (dp, name, type, npp, ds, cred);
+ err = diskfs_lookup_hard (dp, name, type, np, ds, cred);
if (err && err != ENOENT)
return err;
if (type == RENAME
|| (type == CREATE && err == ENOENT)
|| (type == REMOVE && err != ENOENT))
- err = diskfs_checkdirmod (dp, *npp, cred);
-
- if (*npp && !np)
- diskfs_nput (*npp);
+ err = diskfs_checkdirmod (dp, np, cred);
return err;
}
+ /* If we will be modifying the directory, make sure it's allowed. */
+ if (type == RENAME
+ || (type == REMOVE && inum)
+ || (type == CREATE && !inum))
+ {
+ err = diskfs_checkdirmod (dp, np, cred);
+ if (err)
+ goto out;
+ }
+