diff options
-rw-r--r-- | libdiskfs/dir-link.c | 17 |
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; |