From 9439f19f3cba619b7e371b496c78479766cd5665 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 13 Jul 1994 18:29:12 +0000 Subject: entered into RCS --- libdiskfs/dir-link.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'libdiskfs/dir-link.c') 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; -- cgit v1.2.3