summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Kendall <brian@briankendall.net>2022-04-14 00:22:07 -0400
committerBrian Kendall <brian@briankendall.net>2022-04-14 00:22:07 -0400
commite641fb0974f881eaa849555776c0cff16297af59 (patch)
treeeabb7eb56ff46d8952a0c78641a54faad7315a61
parent680f2f6f8fad15e83156eaa2a7648f13696256a1 (diff)
parent73eecd961778273d3634efa5e335044e5cdb42c0 (diff)
downloadunionfs-fuse-git-e641fb0974f881eaa849555776c0cff16297af59.tar.gz
Merge remote-tracking branch 'upstream/bribri' into bribri
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/cow.c9
-rw-r--r--src/findbranch.c9
-rw-r--r--src/fuse_ops.c43
-rw-r--r--src/opts.h4
-rwxr-xr-xtest_vagrant_macos.sh2
-rwxr-xr-xtest_vagrant_ubuntu.sh6
7 files changed, 45 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b513a0f..9c0ede8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,8 +32,8 @@ ELSE (WITH_XATTR)
ENDIF (WITH_XATTR)
if (UNIX AND APPLE)
- find_library(MACFUSE_PATH fuse HINTS /usr/local/lib)
- get_filename_component(MACFUSE_DIRECTORY ${MACFUSE_PATH} DIRECTORY)
+ find_library(MACFUSE_PATH fuse HINTS /usr/local/lib)
+ get_filename_component(MACFUSE_DIRECTORY ${MACFUSE_PATH} DIRECTORY)
link_directories(${MACFUSE_DIRECTORY})
endif()
diff --git a/src/cow.c b/src/cow.c
index dcee6f9..727cce9 100644
--- a/src/cow.c
+++ b/src/cow.c
@@ -47,8 +47,7 @@ int path_create_cutlast_cow(const char *path, int nbranch_ro, int nbranch_rw) {
DBG("%s\n", path);
char *dname = u_dirname(path);
- if (dname == NULL)
- RETURN(-ENOMEM);
+ if (dname == NULL) RETURN(-ENOMEM);
int ret = path_create_cow(dname, nbranch_ro, nbranch_rw);
free(dname);
@@ -65,10 +64,12 @@ int cow_cp(const char *path, int branch_ro, int branch_rw, bool copy_dir) {
path_create_cutlast_cow(path, branch_ro, branch_rw);
char from[PATHLEN_MAX], to[PATHLEN_MAX];
- if (BUILD_PATH(from, uopt.branches[branch_ro].path, path))
+ if (BUILD_PATH(from, uopt.branches[branch_ro].path, path)) {
RETURN(-ENAMETOOLONG);
- if (BUILD_PATH(to, uopt.branches[branch_rw].path, path))
+ }
+ if (BUILD_PATH(to, uopt.branches[branch_rw].path, path)) {
RETURN(-ENAMETOOLONG);
+ }
setlocale(LC_ALL, "");
diff --git a/src/findbranch.c b/src/findbranch.c
index f61668d..0d0827c 100644
--- a/src/findbranch.c
+++ b/src/findbranch.c
@@ -52,8 +52,9 @@
#include "usyslog.h"
static bool branch_contains_path(int branch, const char *path, bool *is_dir) {
- if (branch < 0 || branch >= uopt.nbranches)
+ if (branch < 0 || branch >= uopt.nbranches) {
RETURN(false);
+ }
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[branch].path, path)) {
@@ -68,16 +69,18 @@ static bool branch_contains_path(int branch, const char *path, bool *is_dir) {
if (res == 0) {
(*is_dir) = S_ISDIR(stbuf.st_mode);
RETURN(true);
- } else
+ } else {
RETURN(false);
+ }
}
bool branch_contains_file_or_parent_dir(int branch, const char *path) {
bool is_dir = false;
bool found = branch_contains_path(branch, path, &is_dir);
- if (found)
+ if (found) {
RETURN(true);
+ }
char *dname = u_dirname(path);
if (dname == NULL) {
diff --git a/src/fuse_ops.c b/src/fuse_ops.c
index d378ace..51b5097 100644
--- a/src/fuse_ops.c
+++ b/src/fuse_ops.c
@@ -492,14 +492,14 @@ static int unionfs_rename(const char *from, const char *to, unsigned int flags)
if (i == -1) RETURN(-errno);
if (uopt.preserve_branch && uopt.branches[i].rw) {
- int existing = find_rorw_branch(to);
-
- if (existing != -1 && existing != i) {
- USYSLOG(LOG_ERR, "%s: from %s would overwrite to on a different branch, which"
- "is not supported.\n", __func__, from);
- RETURN(-EXDEV);
- }
-
+ int existing = find_rorw_branch(to);
+
+ if (existing != -1 && existing != i) {
+ USYSLOG(LOG_ERR, "%s: from %s would overwrite to on a different branch, which"
+ "is not supported.\n", __func__, from);
+ RETURN(-EXDEV);
+ }
+
if (branch_contains_file_or_parent_dir(i, to)) {
DBG("preserving branch\n");
j = i;
@@ -520,7 +520,7 @@ static int unionfs_rename(const char *from, const char *to, unsigned int flags)
if (i != j) {
USYSLOG(LOG_ERR, "%s: from and to are on different writable branches %d vs %d, which"
- "is not supported yet.\n", __func__, i, j);
+ "is not supported yet.\n", __func__, i, j);
RETURN(-EXDEV);
}
@@ -529,18 +529,20 @@ static int unionfs_rename(const char *from, const char *to, unsigned int flags)
if (BUILD_PATH(t, uopt.branches[i].path, to)) RETURN(-ENAMETOOLONG);
filetype_t ftype = path_is_dir(f);
- if (ftype == NOT_EXISTING)
+ if (ftype == NOT_EXISTING) {
RETURN(-ENOENT);
- else if (ftype == IS_DIR)
+ } else if (ftype == IS_DIR) {
is_dir = true;
+ }
if (!uopt.branches[i].rw) {
// since original file is on a read-only branch, we copied the from file to a writable branch,
// but since we will rename from, we also need to hide the from file on the read-only branch
- if (is_dir)
+ if (is_dir) {
res = hide_dir(from, i);
- else
+ } else {
res = hide_file(from, i);
+ }
if (res) RETURN(-errno);
}
@@ -550,13 +552,15 @@ static int unionfs_rename(const char *from, const char *to, unsigned int flags)
int err = errno; // unlink() might overwrite errno
// if from was on a read-only branch we copied it, but now rename failed so we need to delete it
if (!uopt.branches[i].rw) {
- if (unlink(f))
+ if (unlink(f)) {
USYSLOG(LOG_ERR, "%s: cow of %s succeeded, but rename() failed and now "
- "also unlink() failed\n", __func__, from);
+ "also unlink() failed\n", __func__, from);
+ }
- if (remove_hidden(from, i))
+ if (remove_hidden(from, i)) {
USYSLOG(LOG_ERR, "%s: cow of %s succeeded, but rename() failed and now "
- "also removing the whiteout failed\n", __func__, from);
+ "also removing the whiteout failed\n", __func__, from);
+ }
}
RETURN(-err);
}
@@ -565,10 +569,11 @@ static int unionfs_rename(const char *from, const char *to, unsigned int flags)
// A lower branch still *might* have a file called 'from', we need to delete this.
// We only need to do this if we have been on a rw-branch, since we created
// a whiteout for read-only branches anyway.
- if (is_dir)
+ if (is_dir) {
maybe_whiteout(from, i, WHITEOUT_DIR);
- else
+ } else {
maybe_whiteout(from, i, WHITEOUT_FILE);
+ }
}
remove_hidden(to, i); // remove hide file (if any)
diff --git a/src/opts.h b/src/opts.h
index de96845..0ee2d08 100644
--- a/src/opts.h
+++ b/src/opts.h
@@ -21,7 +21,7 @@ typedef struct {
branch_entry_t *branches;
bool cow_enabled;
- bool preserve_branch;
+ bool preserve_branch;
bool statfs_omit_ro;
int doexit;
int retval;
@@ -37,7 +37,7 @@ typedef struct {
enum {
KEY_CHROOT,
KEY_COW,
- KEY_PRESERVE_BRANCH,
+ KEY_PRESERVE_BRANCH,
KEY_DEBUG_FILE,
KEY_DIRS,
KEY_HELP,
diff --git a/test_vagrant_macos.sh b/test_vagrant_macos.sh
index f95d43a..c0398cb 100755
--- a/test_vagrant_macos.sh
+++ b/test_vagrant_macos.sh
@@ -1,6 +1,8 @@
#!/bin/sh
set -e -x
+# for virtualbox to work with macos image, oracle extensions need to be installed (arch package virtualbox-ext-oracle)
+
# libfuse3 is disabled for macos since there's no support in macfuse
# see https://github.com/osxfuse/osxfuse/issues/390
diff --git a/test_vagrant_ubuntu.sh b/test_vagrant_ubuntu.sh
index b9f06be..1a4cc19 100755
--- a/test_vagrant_ubuntu.sh
+++ b/test_vagrant_ubuntu.sh
@@ -11,8 +11,10 @@ CMAKE_CMD="cmake .."
trap "vagrant destroy --force; rm -rf Vagrantfile" SIGINT SIGTERM ERR EXIT
rm -rf Vagrantfile
-#vagrant init ubuntu/hirsute64
-vagrant init ubuntu/focal64
+#vagrant init ubuntu/bionic64
+#vagrant init --box-version 20220324.0.0 ubuntu/focal64
+vagrant init --box-version 20220405.0.0 ubuntu/jammy64
+#vagrant box update
vagrant up
echo "