summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-07-13 18:29:12 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-07-13 18:29:12 +0000
commit9439f19f3cba619b7e371b496c78479766cd5665 (patch)
treeea7d505ca86c48b747501014aa558205c7d5c05f
parent9ab4359b3cedc299cd601fde22100d7cd769978c (diff)
entered into RCS
-rw-r--r--libdiskfs/dir-link.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libdiskfs/dir-link.c b/libdiskfs/dir-link.c
index f2104aa2..1bc4e643 100644
--- a/libdiskfs/dir-link.c
+++ b/libdiskfs/dir-link.c
@@ -39,18 +39,21 @@ diskfs_S_dir_link (struct protid *filecred,
if (!dircred)
return EXDEV;
+ mutex_lock (&np->lock);
+ if (S_ISDIR (np->dn_stat.st_mode))
+ {
+ mutex_unlock (&np->lock);
+ return EISDIR;
+ }
+ mutex_unlock (&np->lock);
+
dnp = dircred->po->np;
mutex_lock (&dnp->lock);
+
/* This lock is safe since a non-directory is inherently a leaf */
- /* XXX But we don't know yet that it is a non-directory */
mutex_lock (&np->lock);
- if (S_ISDIR (np->dn_stat.st_mode))
- {
- error = EISDIR;
- goto out;
- }
- else if (np->dn_stat.st_nlink == diskfs_link_max - 1)
+ if (np->dn_stat.st_nlink == diskfs_link_max - 1)
{
error = EMLINK;
goto out;