summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-09-13 16:36:41 +0000
committerMiles Bader <miles@gnu.org>1995-09-13 16:36:41 +0000
commit04c07411536d09ca5e5f5eb243e918f02db0b71b (patch)
treedf1509809b1f5ef5a3cdb2a1b61a3fef7178a0d9 /ext2fs
parent6be67229bc918b5aae4e31621c5d769b629697b1 (diff)
(diskfs_lookup): Don't attempt to lock NP if NPP is not set. Don't
even set NP if NPP is not set; use INUM as "lookup succeeded flag" instead. Lookups for REMOVE now *must* set NPP.
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/dir.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ext2fs/dir.c b/ext2fs/dir.c
index 889950a6..7dcd1786 100644
--- a/ext2fs/dir.c
+++ b/ext2fs/dir.c
@@ -107,6 +107,9 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
int blockaddr;
int idx;
+ if (type == REMOVE)
+ assert (npp);
+
if (npp)
*npp = 0;
@@ -173,7 +176,7 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
think about that as an error yet. */
err = 0;
- if (inum)
+ if (inum && npp)
{
if (namelen != 2 || name[0] != '.' || name[1] != '.')
{
@@ -249,15 +252,15 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
/* If we will be modifying the directory, make sure it's allowed. */
if (type == RENAME
- || (type == REMOVE && np)
- || (type == CREATE && !np))
+ || (type == REMOVE && inum)
+ || (type == CREATE && !inum))
{
err = diskfs_checkdirmod (dp, np, cred);
if (err)
goto out;
}
- if ((type == CREATE || type == RENAME) && !np && ds && ds->stat == LOOKING)
+ if ((type == CREATE || type == RENAME) && !inum && ds && ds->stat == LOOKING)
{
/* We didn't find any room, so mark ds to extend the dir */
ds->type = CREATE;
@@ -281,7 +284,8 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
if (np)
{
- if (err || !npp)
+ assert (npp);
+ if (err)
{
if (!spec_dotdot)
{
@@ -299,11 +303,11 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
/* We did iget */
diskfs_nput (np);
}
- else if (npp)
+ else
*npp = np;
}
- return err ? : np ? 0 : ENOENT;
+ return err ? : inum ? 0 : ENOENT;
}
/* Scan block at address BLKADDR (of node DP; block index IDX), for