diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2021-01-30 10:30:17 +0200 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2021-01-30 10:30:17 +0200 |
commit | 481b3165ab6d1f3c52129b435955c504dd849fe5 (patch) | |
tree | 32a002b30027b834c341dbc00c975a0a16d89e88 /src | |
parent | 76f27264da0c8512e7f79193857f44b66cb0cc04 (diff) | |
download | bindfs-481b3165ab6d1f3c52129b435955c504dd849fe5.tar.gz |
bindfs_rename: removed fallback codepath.
It seems to only be useful if someone wants to emulate renameat2
on an older system or an exotic FS, with an application that
they can't modify, and assuming bindfs is single-threadedly the
only accesspoint to the underlying FS.
May reconsider if someone turns up with such a use case.
Diffstat (limited to 'src')
-rw-r--r-- | src/bindfs.c | 91 |
1 files changed, 13 insertions, 78 deletions
diff --git a/src/bindfs.c b/src/bindfs.c index d4320e8..7c0e655 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -1062,90 +1062,25 @@ static int bindfs_rename(const char *from, const char *to) return -errno; } - #ifdef HAVE_FUSE_3 - - #ifdef __NR_renameat2 - - res = syscall(__NR_renameat2, AT_FDCWD, real_from, AT_FDCWD, real_to, flags); - - #else //__NR_renameat2 - +#ifdef HAVE_FUSE_3 + if (flags == 0) { res = rename(real_from, real_to); - } - else if (flags == RENAME_NOREPLACE && access( real_to, F_OK ) != 0) { - res = rename(real_from, real_to); - } - else if (flags == RENAME_EXCHANGE && access( real_from, F_OK ) == 0 && access( real_to, F_OK ) == 0) { - char *tmp_from, *tmp_to; - int r, tmp_errno; - - tmp_from = tmpnam_inpath(real_from); - if (tmp_from) { - r = rename(real_from, tmp_from); - if (r == -1) { - res = r; - } - else { - tmp_to = tmpnam_inpath(real_to); - if (tmp_to) { - r = rename(real_to, tmp_to); - tmp_errno = errno; - if (r == -1) { - rename(tmp_from, real_from); - res = r; - errno = tmp_errno; - } - else { - r = rename(tmp_from, real_to); - tmp_errno = errno; - if (r == -1) { - rename(tmp_from, real_from); - rename(tmp_to, real_to); - res = r; - errno = tmp_errno; - } - else { - r = rename(tmp_to, real_from); - tmp_errno = errno; - if (r == -1) { - rename(tmp_from, real_from); - rename(tmp_to, real_to); - res = r; - errno = tmp_errno; - } - } - } - } - else { - rename(tmp_from, real_from); - res = -1; - errno = EAGAIN; - } - - free(tmp_to); - } - } - else { - res = -1; - errno = EAGAIN; - } - - free(tmp_from); - } - else { + } else { +#ifdef __NR_renameat2 + res = syscall(__NR_renameat2, AT_FDCWD, real_from, AT_FDCWD, real_to, flags); +#else // __NR_renameat2 res = -1; errno = EINVAL; +#endif // __NR_renameat2 } - - #endif //__NR_renameat2 - - #else //HAVE_FUSE_3 - + +#else // HAVE_FUSE_3 + res = rename(real_from, real_to); - - #endif //HAVE_FUSE_3 - + +#endif // HAVE_FUSE_3 + free(real_from); free(real_to); if (res == -1) |