summaryrefslogtreecommitdiff
path: root/ufs
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-09-13 16:30:20 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-09-13 16:30:20 +0000
commit4d5e699b41a64698b63167cf638d2712cae9ec52 (patch)
treec744b97a3fa448d141967c96b751d7f5eed3320c /ufs
parent34186ecd645aaa4e9f903498810bea0a9fbaef6a (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 'ufs')
-rw-r--r--ufs/dir.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ufs/dir.c b/ufs/dir.c
index 1d7004d8..ab98d4bb 100644
--- a/ufs/dir.c
+++ b/ufs/dir.c
@@ -100,6 +100,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;
@@ -166,7 +169,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] != '.')
{
@@ -242,15 +245,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;
@@ -274,7 +277,8 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
if (np)
{
- if (err || !npp)
+ assert (npp);
+ if (err)
{
if (!spec_dotdot)
{
@@ -292,11 +296,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