diff options
author | Michael I. Bushnell <mib@gnu.org> | 1996-03-20 21:12:51 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1996-03-20 21:12:51 +0000 |
commit | 0e7b2edd364a2662cc1fe9a7dea4b1e18a96c662 (patch) | |
tree | 38e89c80aa49fee2bd1a2fbb41fa114d244b55af /libdiskfs | |
parent | 7b66e876d196d610680bcb8adb2cf40b33b59640 (diff) |
(diskfs_lookup): Do permission checking and cache looking here.
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/lookup.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/libdiskfs/lookup.c b/libdiskfs/lookup.c index 59100cef..2e36798b 100644 --- a/libdiskfs/lookup.c +++ b/libdiskfs/lookup.c @@ -73,6 +73,51 @@ diskfs_lookup (struct node *dp, struct dirstat *ds, struct protid *cred) { - return diskfs_lookup_hard (dp, name, type, np, ds, cred); + error_t err; + struct node *ournp, **npp; + + npp = np ? : &ournp; + + if (!S_ISDIR (dp->dn_stat.st_mode)) + { + diskfs_null_dirstat (ds); + return ENOTDIR; + } + err = diskfs_access (dp, S_IEXEC, cred); + if (err) + { + diskfs_null_dirstat (ds); + return err; + } + + if (type == LOOKUP) + { + /* Check the cache first */ + *np = diskfs_check_cache (dp, name); + if (*np == (struct node *)-1) + { + *np = 0; + return ENOENT; + } + else if (*np) + { + diskfs_null_dirstat (ds); + return 0; + } + } + + err = diskfs_lookup_hard (dp, name, type, npp, 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); + + return err; } |