void-packages/srcpkgs/djmount/patches/003-support-fstab-mounting....

97 lines
3.3 KiB
Diff

Description: Support /etc/fstab mounting
Forwarded: https://sourceforge.net/tracker/?func=detail&aid=3514280&group_id=142039&atid=751317
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660098
Author: Kevin Vargo <vargok@yahoo.com>
Last-Update: 2012-04-02
--- djmount/fuse_main.c 2006-08-27 16:12:20.000000000 -0400
+++ djmount/fuse_main.c 2011-12-23 15:39:29.000000000 -0500
@@ -529,6 +529,7 @@
" --version print version number, then exit\n"
" -o [options] mount options (see below)\n"
" -d[levels] enable debug output (implies -f)\n"
+ " -s sloppy -- ignore unknown options\n"
" -f foreground operation (default: daemonized)\n"
"\n"
"Mount options (one or more comma separated options) :\n"
@@ -538,6 +539,7 @@
" playlists use playlists for AV files, instead of plain files\n"
" search_history=<size> number of remembered searches (default: %d)\n"
" (set to 0 to disable search)\n"
+ " sloppy ignore unknown options (e.g., for /etc/fstab)\n"
"\n", DEFAULT_SEARCH_HISTORY_SIZE);
fprintf
(stream,
@@ -635,6 +637,9 @@
Log_Printf (LOG_DEBUG, " Fuse option = %s", fuse_argv[fuse_argc]); \
fuse_argc++
+ //Ignore unknown options "sloppy" -- mount -s
+ bool options_sloppy = false;
+
int opt = 1;
char* o;
while ((o = argv[opt++])) {
@@ -646,6 +651,9 @@
} else if (strcmp(o, "-f") == 0) {
background = false;
+
+ } else if (strcmp(o, "-s") == 0) {
+ options_sloppy = true;
} else if (*o != '-') {
// mount point
@@ -657,6 +665,10 @@
char* options_copy = strdup (options);
char* tokptr = 0;
char* s;
+
+ char** unknown_options = talloc_size(tmp_ctx, sizeof(char) * strlen(options_copy));
+ int unknown_ptr = -1;
+
for (s = strtok_r (options_copy, ",", &tokptr);
s != NULL;
s = strtok_r (NULL, ",", &tokptr)) {
@@ -669,16 +681,39 @@
} else if (strncmp(s, "search_history=", 15)
== 0) {
search_history_size = atoi (s+15);
+ //check for '-s|-o sloppy' -- ignore unknown options
+ } else if (strncmp(s, "sloppy", 15) == 0 ||
+ (strlen(s) == 1 && strncmp(s, "s", 1) == 0)) {
+ options_sloppy = true;
} else if (strncmp(s, "fsname=", 7) == 0 ||
strstr (FUSE_ALLOWED_OPTIONS, s)) {
FUSE_ARG ("-o");
FUSE_ARG (talloc_strdup (tmp_ctx, s));
} else {
+ //Record unknown options for analysis, after we're sure
+ //we don't see '-o sloppy'
+ unknown_options[++unknown_ptr] = strdup(s);
+ }
+ }
+
+ //Now, we should know if we have invalid option(s), or can
+ //ignore:
+ if (unknown_ptr >= 0) {
+ //If debug...
+ int i = 0;
+ for (i = 0; i <= unknown_ptr; i++) {
+ Log_Printf (LOG_WARNING, "Found unknown option = %s%s",
+ unknown_options[i], (options_sloppy ? "; ignoring" : ""));
+ }
+ //If 'sloppy' is not enabled...
+ if (! options_sloppy) {
bad_usage (argv[0],
- "unknown mount option '%s'",
- s); // ---------->
+ "unknown mount option '%s' (and [-s|-o sloppy] not provided)",
+ unknown_options[0]); // ---------->
}
}
+ talloc_free(unknown_options);
+
free (options_copy);
Log_Printf (LOG_INFO, " Mount options = %s", options);