+ argv_sp=argv+1;
+ if (*argv_sp && (*argv_sp)[0]!='-')
+ image_filename=*argv_sp++;
+ if (*argv_sp && (*argv_sp)[0]!='-')
+ mountpoint=*argv_sp++;
+ if (*argv_sp && !strcmp(*argv_sp,"-n")) {
+ opt_n=TRUE;
+ argv_sp++;
+ }
+ if (*argv_sp && !strcmp(*argv_sp,"-v")) {
+ opt_v=TRUE;
+ argv_sp++;
+ }
+ if (argv_sp[0] && argv_sp[1] && !strcmp(argv_sp[0],"-o")) {
+ argv_sp++;
+ opt_o=*argv_sp++;
+ }
+ if (*argv_sp) {
+ /* Lethal path but still give chance for "--help" etc. */
+ /* Do not: POPT_CONTEXT_POSIXMEHARDER
+ * as mount(8) puts there first un-pre-dashed "ro"/"rw" etc. */
+ /* poptGetNextOpt() requires valid: captive_options */
+ if ((context=poptGetContext(
+ PACKAGE, /* name */
+ argc,(/*en-const*/const char **)argv, /* argc,argv */
+ popt_table, /* options */
+ 0))) /* flags; && !POPT_CONTEXT_KEEP_FIRST */
+ while (0<=poptGetNextOpt(context));
+ g_error(_("Excessive argument: %s"),*argv_sp);
+ }
+
+ if (opt_o) {
+char *opt_o_spaced=(char */* de-const; length is not changed */)captive_strdup_alloca(opt_o);
+char *s,quote;
+
+ quote=0;
+ for (s=opt_o_spaced;*s;s++) {
+ /* Be compatible with: poptParseArgvString()
+ * which also does not differentiate '"' and "'" */
+ if (*s=='\\' && s[1]) {
+ s++;
+ continue;
+ }
+ if (quote) {
+ if (*s==quote)
+ quote=0;
+ continue;
+ }
+ switch (*s) {
+ case '"':
+ case '\'':
+ quote=*s;
+ continue;
+ case ',':
+ *s=' ';
+ continue;
+ }
+ }
+ if (poptParseArgvString(opt_o_spaced,&opt_o_argc,&opt_o_argv))
+ g_error(_("Error splitting arguments of the space-reparsed '-o': %s"),opt_o_spaced);
+ /* Adjust the options for all the subsystems eating the same string vector. */
+ for (csp=opt_o_argv;*csp;csp++) {
+ /* Unsupported mount(8) options not valid for fusermount(8) and causing:
+ * fusermount: mount failed: Invalid argument */
+ if (0
+ || !strcmp(*csp,"defaults")
+ || !strcmp(*csp, "auto")
+ || !strcmp(*csp,"noauto")
+ || !strcmp(*csp,"user")) {
+ memmove(csp,csp+1,(opt_o_argv+opt_o_argc+1-(csp+1))*sizeof(*csp));
+ opt_o_argc--;
+ csp--;
+ continue;
+ }
+ /* Pre-dash "ro"/"rw" to let libcaptive to be aware of the mode.
+ * We will put the final "ro"/"rw" there again from 'captive_options.rwmode' later. */
+ if (!strcmp(*csp,"ro"))
+ *csp="--ro";
+ if (!strcmp(*csp,"rw"))
+ *csp="--rw";
+ /* LUFS "uid" and "gid" options should map to FUSE well, I hope. */
+#define STRNCMP_CONST(mem,string) strncmp((mem),(string),strlen((string)))
+ if (0
+ || !STRNCMP_CONST(*csp,"fmask=")
+ || !STRNCMP_CONST(*csp,"dmask=")
+ || !STRNCMP_CONST(*csp,"channels=")
+ || !STRNCMP_CONST(*csp,"root=")
+ || !strcmp(*csp,"own_fs")
+ || !strcmp(*csp,"quiet")
+ || !STRNCMP_CONST(*csp,"dir_cache_ttl=")
+ )
+ g_error(_("Seen obsolete LUFS option \"%s\" - please update your \"/etc/fstab\" for FUSE options instead"),
+ *csp);
+#undef STRNCMP_CONST
+ }
+ }
+