summaryrefslogtreecommitdiff
path: root/src/rmdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rmdir.c')
-rw-r--r--src/rmdir.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/rmdir.c b/src/rmdir.c
index fa380aa..5170425 100644
--- a/src/rmdir.c
+++ b/src/rmdir.c
@@ -31,16 +31,18 @@
#include "general.h"
#include "findbranch.h"
#include "string.h"
+#include "readdir.h"
+#include "usyslog.h"
/**
* If the branch that has the directory to be removed is in read-write mode,
* we can really delete the file.
*/
static int rmdir_rw(const char *path, int branch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
char p[PATHLEN_MAX];
- snprintf(p, PATHLEN_MAX, "%s%s", uopt.branches[branch_rw].path, path);
+ if (BUILD_PATH(p, uopt.branches[branch_rw].path, path)) return ENAMETOOLONG;
int res = rmdir(p);
if (res == -1) return errno;
@@ -55,7 +57,7 @@ static int rmdir_rw(const char *path, int branch_rw) {
* lower level directory.
*/
static int rmdir_ro(const char *path, int branch_ro) {
- DBG_IN();
+ DBG("%s\n", path);
// find a writable branch above branch_ro
int branch_rw = find_lowest_rw_branch(branch_ro);
@@ -68,7 +70,7 @@ static int rmdir_ro(const char *path, int branch_ro) {
case (ENOTDIR):
case (ENOTEMPTY):
// catch errors not allowed for rmdir()
- usyslog (LOG_ERR, "%s: Creating the whiteout failed: %s\n",
+ USYSLOG (LOG_ERR, "%s: Creating the whiteout failed: %s\n",
__func__, strerror(errno));
errno = EFAULT;
}
@@ -82,7 +84,9 @@ static int rmdir_ro(const char *path, int branch_ro) {
* rmdir() call
*/
int unionfs_rmdir(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
+
+ if (dir_not_empty(path)) return -ENOTEMPTY;
int i = find_rorw_branch(path);
if (i == -1) return -errno;