summaryrefslogtreecommitdiff
path: root/src/general.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/general.c')
-rw-r--r--src/general.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/general.c b/src/general.c
index 5a7ce89..e0bb374 100644
--- a/src/general.c
+++ b/src/general.c
@@ -37,18 +37,18 @@
*/
static int filedir_hidden(const char *path) {
// cow mode disabled, no need for hidden files
- if (!uopt.cow_enabled) return false;
+ if (!uopt.cow_enabled) RETURN(false);
char p[PATHLEN_MAX];
- if (strlen(path) + strlen(HIDETAG) > PATHLEN_MAX) return -ENAMETOOLONG;
+ if (strlen(path) + strlen(HIDETAG) > PATHLEN_MAX) RETURN(-ENAMETOOLONG);
snprintf(p, PATHLEN_MAX, "%s%s", path, HIDETAG);
DBG("%s\n", p);
struct stat stbuf;
int res = lstat(p, &stbuf);
- if (res == 0) return true;
+ if (res == 0) RETURN(true);
- return 0;
+ RETURN(0);
}
/**
@@ -57,10 +57,10 @@ static int filedir_hidden(const char *path) {
int path_hidden(const char *path, int branch) {
DBG("%s\n", path);
- if (!uopt.cow_enabled) return false;
+ if (!uopt.cow_enabled) RETURN(false);
char whiteoutpath[PATHLEN_MAX];
- if (BUILD_PATH(whiteoutpath, uopt.branches[branch].path, METADIR, path)) return false;
+ if (BUILD_PATH(whiteoutpath, uopt.branches[branch].path, METADIR, path)) RETURN(false);
// -1 as we MUST not end on the next path element
char *walk = whiteoutpath + uopt.branches[branch].path_len + strlen(METADIR) - 1;
@@ -77,13 +77,13 @@ int path_hidden(const char *path, int branch) {
// walk - path = strlen(/dir1)
snprintf(p, (walk - whiteoutpath) + 1, "%s", whiteoutpath);
int res = filedir_hidden(p);
- if (res) return res; // path is hidden or error
+ if (res) RETURN(res); // path is hidden or error
// as above the do loop, walk over the next slashes, walk = dir2/
while (*walk != '\0' && *walk == '/') walk++;
} while (*walk != '\0');
- return 0;
+ RETURN(0);
}
/**
@@ -93,15 +93,15 @@ int path_hidden(const char *path, int branch) {
int remove_hidden(const char *path, int maxbranch) {
DBG("%s\n", path);
- if (!uopt.cow_enabled) return 0;
+ if (!uopt.cow_enabled) RETURN(0);
if (maxbranch == -1) maxbranch = uopt.nbranches;
int i;
for (i = 0; i <= maxbranch; i++) {
char p[PATHLEN_MAX];
- if (BUILD_PATH(p, uopt.branches[i].path, METADIR, path)) return -ENAMETOOLONG;
- if (strlen(p) + strlen(HIDETAG) > PATHLEN_MAX) return -ENAMETOOLONG;
+ if (BUILD_PATH(p, uopt.branches[i].path, METADIR, path)) RETURN(-ENAMETOOLONG);
+ if (strlen(p) + strlen(HIDETAG) > PATHLEN_MAX) RETURN(-ENAMETOOLONG);
strcat(p, HIDETAG); // TODO check length
switch (path_is_dir(p)) {
@@ -111,7 +111,7 @@ int remove_hidden(const char *path, int maxbranch) {
}
}
- return 0;
+ RETURN(0);
}
/**
@@ -124,11 +124,11 @@ filetype_t path_is_dir(const char *path) {
struct stat buf;
- if (lstat(path, &buf) == -1) return NOT_EXISTING;
+ if (lstat(path, &buf) == -1) RETURN(NOT_EXISTING);
- if (S_ISDIR(buf.st_mode)) return IS_DIR;
+ if (S_ISDIR(buf.st_mode)) RETURN(IS_DIR);
- return IS_FILE;
+ RETURN(IS_FILE);
}
/**
@@ -139,26 +139,26 @@ static int do_create_whiteout(const char *path, int branch_rw, enum whiteout mod
char metapath[PATHLEN_MAX];
- if (BUILD_PATH(metapath, METADIR, path)) return -1;
+ if (BUILD_PATH(metapath, METADIR, path)) RETURN(-1);
// p MUST be without path to branch prefix here! 2 x branch_rw is correct here!
// this creates e.g. branch/.unionfs/some_directory
path_create_cutlast(metapath, branch_rw, branch_rw);
char p[PATHLEN_MAX];
- if (BUILD_PATH(p, uopt.branches[branch_rw].path, metapath)) return -1;
+ if (BUILD_PATH(p, uopt.branches[branch_rw].path, metapath)) RETURN(-1);
strcat(p, HIDETAG); // TODO check length
int res;
if (mode == WHITEOUT_FILE) {
res = open(p, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
- if (res == -1) return -1;
+ if (res == -1) RETURN(-1);
res = close(res);
} else {
res = mkdir(p, S_IRWXU);
}
- return res;
+ RETURN(res);
}
/**
@@ -166,7 +166,7 @@ static int do_create_whiteout(const char *path, int branch_rw, enum whiteout mod
*/
int hide_file(const char *path, int branch_rw) {
DBG("%s\n", path);
- return do_create_whiteout(path, branch_rw, WHITEOUT_FILE);
+ RETURN(do_create_whiteout(path, branch_rw, WHITEOUT_FILE));
}
/**
@@ -174,7 +174,7 @@ int hide_file(const char *path, int branch_rw) {
*/
int hide_dir(const char *path, int branch_rw) {
DBG("%s\n", path);
- return do_create_whiteout(path, branch_rw, WHITEOUT_DIR);
+ RETURN(do_create_whiteout(path, branch_rw, WHITEOUT_DIR));
}
/**
@@ -186,10 +186,10 @@ int maybe_whiteout(const char *path, int branch_rw, enum whiteout mode) {
// we are not interested in the branch itself, only if it exists at all
if (find_rorw_branch(path) != -1) {
- return do_create_whiteout(path, branch_rw, mode);
+ RETURN(do_create_whiteout(path, branch_rw, mode));
}
- return 0;
+ RETURN(0);
}
/**
@@ -203,8 +203,8 @@ int set_owner(const char *path) {
usyslog(LOG_WARNING,
":%s: Setting the correct file owner failed: %s !\n",
__func__, strerror(errno));
- return -errno;
+ RETURN(-errno);
}
}
- return 0;
+ RETURN(0);
}