aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindfs.117
-rw-r--r--src/bindfs.c29
2 files changed, 31 insertions, 15 deletions
diff --git a/src/bindfs.1 b/src/bindfs.1
index 92444a2..d92c55d 100644
--- a/src/bindfs.1
+++ b/src/bindfs.1
@@ -196,22 +196,23 @@ The read/write permissions are checked against the (possibly modified)
file permissions inside the mount.
-.SH TIME-RELATED OPTIONS
+.SH MISCELLANEOUS WORKAROUNDS
+.TP
+.B \-\-ctime\-from-mtime, \-o ctime\-from\-mtime
Recall that a unix file has three standard timestamps:
\fBatime\fP (last access i.e. read time),
\fBmtime\fP (last content modification time)
\fBctime\fP (last content or metadata (inode) change time)
-It may sometimes be useful to alter these timestamps, but care should be taken
-not to cause programs (e.g. backup jobs) to miss important changes.
-
-.TP
-.B \-\-ctime\-from-mtime, \-o ctime\-from\-mtime
-Reads the ctime of each file and directory from its mtime.
+With this option, the ctime of each file and directory is read from its mtime.
In other words, only content modifications (as opposed to metadata changes)
will be reflected in a mirrored file's ctime.
-(The underlying file's ctime will still be updated normally.)
+The underlying file's ctime will still be updated normally.
+
+.TP
+.B \-\-hide-hard-links, \-o hide-hard-links
+Shows the hard link count of all files as 1.
.SH FUSE OPTIONS
diff --git a/src/bindfs.c b/src/bindfs.c
index ff7b35f..4cb1305 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -118,6 +118,9 @@ static struct settings {
int num_mirrored_members;
int ctime_from_mtime;
+
+ int hide_hard_links;
+
} settings;
@@ -256,6 +259,10 @@ static int getattr_common(const char *procpath, struct stat *stbuf)
if (access(procpath, X_OK) == -1)
stbuf->st_mode &= ~0111;
+ /* Hide hard links */
+ if (settings.hide_hard_links)
+ stbuf->st_nlink = 1;
+
return 0;
}
@@ -342,8 +349,8 @@ static int bindfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
{
DIR *dp = get_dirp(fi);
struct dirent *de;
-
(void) path;
+
seekdir(dp, offset);
while ((de = readdir(dp)) != NULL) {
struct stat st;
@@ -628,7 +635,6 @@ static int bindfs_ftruncate(const char *path, off_t size,
struct fuse_file_info *fi)
{
int res;
-
(void) path;
res = ftruncate(fi->fh, size);
@@ -706,8 +712,8 @@ static int bindfs_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
int res;
-
(void) path;
+
res = pread(fi->fh, buf, size, offset);
if (res == -1)
res = -errno;
@@ -719,8 +725,8 @@ static int bindfs_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
int res;
-
(void) path;
+
res = pwrite(fi->fh, buf, size, offset);
if (res == -1)
res = -errno;
@@ -744,6 +750,7 @@ static int bindfs_statfs(const char *path, struct statvfs *stbuf)
static int bindfs_release(const char *path, struct fuse_file_info *fi)
{
(void) path;
+
close(fi->fh);
return 0;
@@ -937,9 +944,10 @@ static void print_usage(const char *progname)
" --xattr-ro Read-only xattr operations.\n"
" --xattr-rw Read-write xattr operations (the default).\n"
"\n"
- "Time-related:\n"
+ "Workarounds:\n"
" --ctime-from-mtime Read file properties' change time\n"
" from file content modification time.\n"
+ " --hide-hard-links Always report a hard link count of 0.\n"
"\n"
"FUSE options:\n"
" -o opt[,opt,...] Mount options.\n"
@@ -986,7 +994,8 @@ enum OptionKey {
OPTKEY_XATTR_NONE,
OPTKEY_XATTR_READ_ONLY,
OPTKEY_XATTR_READ_WRITE,
- OPTKEY_CTIME_FROM_MTIME
+ OPTKEY_CTIME_FROM_MTIME,
+ OPTKEY_HIDE_HARD_LINKS
};
static int process_option(void *data, const char *arg, int key,
@@ -1060,7 +1069,11 @@ static int process_option(void *data, const char *arg, int key,
case OPTKEY_CTIME_FROM_MTIME:
settings.ctime_from_mtime = 1;
- return 0;
+ return 0;
+
+ case OPTKEY_HIDE_HARD_LINKS:
+ settings.hide_hard_links = 1;
+ return 0;
case OPTKEY_NONOPTION:
if (!settings.mntsrc) {
@@ -1136,6 +1149,7 @@ int main(int argc, char *argv[])
OPT2("--xattr-ro", "xattr-ro", OPTKEY_XATTR_READ_ONLY),
OPT2("--xattr-rw", "xattr-rw", OPTKEY_XATTR_READ_WRITE),
OPT2("--ctime-from-mtime", "ctime-from-mtime", OPTKEY_CTIME_FROM_MTIME),
+ OPT2("--hide-hard-links", "hide-hard-links", OPTKEY_HIDE_HARD_LINKS),
FUSE_OPT_END
};
@@ -1168,6 +1182,7 @@ int main(int argc, char *argv[])
settings.mirrored_members = NULL;
settings.num_mirrored_members = 0;
settings.ctime_from_mtime = 0;
+ settings.hide_hard_links = 0;
atexit(&atexit_func);
/* Parse options */