summaryrefslogtreecommitdiff
path: root/src/unlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/unlink.c')
-rw-r--r--src/unlink.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/unlink.c b/src/unlink.c
index 06a7fa2..8b4000d 100644
--- a/src/unlink.c
+++ b/src/unlink.c
@@ -28,6 +28,7 @@
#include "cow.h"
#include "general.h"
#include "findbranch.h"
+#include "string.h"
/**
* If the branch that has the file to be unlinked is in read-only mode,
@@ -36,20 +37,20 @@
* lower level file.
*/
static int unlink_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);
- if (branch_rw < 0) return EACCES;
+ if (branch_rw < 0) RETURN(EACCES);
if (hide_file(path, branch_rw) == -1) {
// creating the file with the hide tag failed
// TODO: open() error messages are not optimal on unlink()
- return errno;
+ RETURN(errno);
}
- return 0;
+ RETURN(0);
}
/**
@@ -57,25 +58,25 @@ static int unlink_ro(const char *path, int branch_ro) {
* we can really delete the file.
*/
static int unlink_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 = unlink(p);
- if (res == -1) return errno;
+ if (res == -1) RETURN(errno);
- return 0;
+ RETURN(0);
}
/**
* unlink() call
*/
int unionfs_unlink(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rorw_branch(path);
- if (i == -1) return errno;
+ if (i == -1) RETURN(errno);
int res;
if (!uopt.branches[i].rw) {
@@ -94,5 +95,5 @@ int unionfs_unlink(const char *path) {
}
}
- return -res;
+ RETURN(-res);
}