aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindfs.c7
-rw-r--r--src/misc.c27
-rw-r--r--src/misc.h3
3 files changed, 37 insertions, 0 deletions
diff --git a/src/bindfs.c b/src/bindfs.c
index 0aa0a51..a40d578 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -1993,6 +1993,13 @@ int main(int argc, char *argv[])
fuse_opt_add_arg(&args, "-ouse_ino");
fuse_opt_add_arg(&args, "-oreaddir_ino");
+ /* Show the source dir in the first field on /etc/mtab. */
+ {
+ char *tmp = sprintf_new("-ofsname=%s", settings.mntsrc);
+ fuse_opt_add_arg(&args, tmp);
+ free(tmp);
+ }
+
/* We need to disable the attribute cache whenever two users
can see different attributes. For now, only mirroring can do that. */
if (is_mirroring_enabled()) {
diff --git a/src/misc.c b/src/misc.c
index 612ec82..e0aba02 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -18,6 +18,8 @@
*/
#include "misc.h"
+#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
@@ -68,6 +70,31 @@ char *strdup_until(const char *s, const char *endchars)
}
}
+char *sprintf_new(const char *format, ...)
+{
+ va_list ap;
+ size_t buffer_size = strlen(format) + 32;
+ char *buffer = malloc(buffer_size);
+ if (buffer == NULL) {
+ return NULL;
+ }
+
+ while (1) {
+ va_start(ap, format);
+ size_t len = (size_t)vsnprintf(buffer, buffer_size, format, ap);
+ va_end(ap);
+ if (len < buffer_size) {
+ return buffer;
+ }
+ free(buffer);
+ buffer_size *= 2;
+ buffer = malloc(buffer_size);
+ if (buffer == NULL) {
+ return NULL;
+ }
+ }
+}
+
const char *my_basename(const char *path)
{
const char *p;
diff --git a/src/misc.h b/src/misc.h
index dc654d6..b059596 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -31,6 +31,9 @@ int count_substrs(const char *s, const char *sub);
an end character is reached. */
char *strdup_until(const char *s, const char *endchars);
+/* Like sprintf but writes to an automatically malloc'ed buffer. */
+char *sprintf_new(const char *format, ...);
+
/* Returns a pointer to the first character after the
final slash of path, or path itself if it contains no slashes.
If the path ends with a slash, then the result is an empty