summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1999-06-29 01:38:52 +0000
committerThomas Bushnell <thomas@gnu.org>1999-06-29 01:38:52 +0000
commitf9dd257d975747d31ef8e496ffbf2a8e177ca121 (patch)
treecee0f3da273f651363d06d452317d9dda52d0e6a /libdiskfs
parent9e55fdd762a7d606e6b1090ff1317ad7f0baa911 (diff)
1999-06-28 Thomas Bushnell, BSG <tb@mit.edu>
* dir-rmdir.c (diskfs_S_dir_rmdir): Reorganized to make clearer.
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/ChangeLog4
-rw-r--r--libdiskfs/dir-rmdir.c52
2 files changed, 26 insertions, 30 deletions
diff --git a/libdiskfs/ChangeLog b/libdiskfs/ChangeLog
index 3efc9f5f..d10ea2ef 100644
--- a/libdiskfs/ChangeLog
+++ b/libdiskfs/ChangeLog
@@ -1,3 +1,7 @@
+1999-06-28 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * dir-rmdir.c (diskfs_S_dir_rmdir): Reorganized to make clearer.
+
1999-06-27 Thomas Bushnell, BSG <tb@mit.edu>
* sync-default.c (diskfs_default_sync_interval): Reduce to five
diff --git a/libdiskfs/dir-rmdir.c b/libdiskfs/dir-rmdir.c
index a6387023..314e4e0a 100644
--- a/libdiskfs/dir-rmdir.c
+++ b/libdiskfs/dir-rmdir.c
@@ -1,5 +1,5 @@
/* libdsikfs implementation of fs.defs: dir_rmdir
- Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation
+ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1999 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -42,27 +42,6 @@ diskfs_S_dir_rmdir (struct protid *dircred,
if (error == EAGAIN)
error = ENOTEMPTY;
- if (np)
- {
- if ((np->dn_stat.st_mode & S_IPTRANS)
- || fshelp_translated (&np->transbox))
- {
- diskfs_nput (np);
- error = EBUSY;
- }
- if (!S_ISDIR (np->dn_stat.st_mode))
- {
- diskfs_nput (np);
- error = ENOTDIR;
- }
- }
- if (error)
- {
- mutex_unlock (&dnp->lock);
- diskfs_drop_dirstat (dnp, ds);
- return error;
- }
-
/* Attempt to rmdir(".") */
if (dnp == np)
{
@@ -72,18 +51,28 @@ diskfs_S_dir_rmdir (struct protid *dircred,
return EINVAL;
}
- /* Verify the directory is empty (and valid). (Rmdir ".." won't be
- valid since ".." will contain a reference to the current directory and
- thus be non-empty). */
- if (!diskfs_dirempty (np, dircred))
+ if ((np->dn_stat.st_mode & S_IPTRANS)
+ || fshelp_translated (&np->transbox))
{
- diskfs_nput (np);
- diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
- return ENOTEMPTY;
+ error = EBUSY;
+ goto out;
}
+ if (!S_ISDIR (np->dn_stat.st_mode))
+ {
+ error = ENOTDIR;
+ goto out;
+ }
+
+ if (!diskfs_dirempty (np, dircred))
+ {
+ error = ENOTEMPTY;
+ goto out;
+ }
+
error = diskfs_dirremove (dnp, np, name, ds);
+ ds = 0;
+
if (!error)
{
np->dn_stat.st_nlink--;
@@ -95,6 +84,9 @@ diskfs_S_dir_rmdir (struct protid *dircred,
if (diskfs_synchronous)
diskfs_file_update (dnp, 1);
+ out:
+ if (ds)
+ diskfs_drop_dirstat (dnp, ds);
diskfs_nput (np);
mutex_unlock (&dnp->lock);
return 0;