Hi Dario, 

  Sorry... try this; clean version of 003 attached.  Builds clean as checked 
out from git.


The diff-to-diff is:


04 23:31:22 vargo@inside:djmount> git diff 
debian/patches/003-support-fstab-mounting.diff
diff --git a/debian/patches/003-support-fstab-mounting.diff 
b/debian/patches/003-support-fstab-mounting.diff
index 15fd689..0e6159c 100644
--- a/debian/patches/003-support-fstab-mounting.diff
+++ b/debian/patches/003-support-fstab-mounting.diff
@@ -79,12 +79,8
 @@
 +                              //If debug...
 +                              int i = 0;
 +                              for (i = 0; i <= unknown_ptr; i++) {
-+                                      char* message = talloc_size(tmp_ctx, 
sizeof(char) *
 100);
-+                                      snprintf(message, 100, "Found unknown 
option = %s%s",
++                                      Log_Printf (LOG_WARNING, "Found unknown 
option = %s%s",
 +                                              unknown_options[i], 
(options_sloppy ? "; ignoring" :
 ""));
-+                                      //printf("%s\n", message);
-+                                      Log_Printf (LOG_WARNING, message);
-+                                      talloc_free (message);
 +                             
 }
 +                              //If 'sloppy' is not enabled...
 +                              if (! options_sloppy) {

Thanks,

Kevin



>________________________________
> From: Dario Minnucci <mid...@debian.org>
>To: 660...@bugs.debian.org 
>Cc: Kevin Vargo <var...@yahoo.com> 
>Sent: Monday, April 2, 2012 6:56 PM
>Subject: Re: Bug#660098: djmount: support /etc/fstab mounting
> 
>
>Hi Kevin,
>
>First of all, thanks al lot for improving djmount.
>
>I've forwarded your patch upstream [0], but will not be included in next 
>djmount release (0.71-4)
>for Debian because applying it raises the following error:
>
>
>[...]
>fuse_main.c: In function ‘main’:
>fuse_main.c:709:6: error: format not a string literal and no format arguments 
>[-Werror=format-security]
>cc1: some warnings being treated as errors
>make[4]: *** [fuse_main.o] Error 1
>[...]
>
>
>I'll take a look at it when I have some spare time but meanwhile, if you want 
>to review it you can
>find latest djmount sources at git.debian.org repository [1].
>
>The patch is already added, under debian/patches but it isn't imported.
>
>Regards,
>
>
>[0] 
>https://sourceforge.net/tracker/?func=detail&aid=3514280&group_id=142039&atid=751317
>[1] http://anonscm.debian.org/gitweb/?p=collab-maint/djmount.git;a=summary
>
>-- 
>Dario Minnucci <mid...@debian.org>
>Phone: +34 902884117 | Fax: +34 902024417 | Support: +34 807450000
>Key fingerprint = BAA1 7AAF B21D 6567 D457  D67D A82F BB83 F3D5 7033
>
>
>
>
>
#
# 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 <var...@yahoo.com>
# Last-Update: 2012-04-02
#
--- djmount-0.71.orig/djmount/fuse_main.c	2006-08-27 16:12:20.000000000 -0400
+++ djmount-0.71/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);
 			

Reply via email to