summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-01-15 09:42:01 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2005-01-15 09:42:01 +0000
commit5ef2a9bd077a6a3cfcbc7d8d3fdccbf4b397df62 (patch)
treecbe39316938df043f94992917501fafff78cf57b
parentcdae16e0ae887442e1b4565550230d3d3bb99090 (diff)
downloadfuse-5ef2a9bd077a6a3cfcbc7d8d3fdccbf4b397df62.tar.gz
fix
-rw-r--r--ChangeLog4
-rw-r--r--util/fusermount.c44
2 files changed, 38 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index ace122c..7530e5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2005-01-13 Miklos Szeredi <miklos@szeredi.hu>
+ * fusermount: improve parsing of /etc/fuse.conf
+
+2005-01-13 Miklos Szeredi <miklos@szeredi.hu>
+
* Remove 'mount_max' and 'user_allow_other' module options. These
are now checked by fusermount, and can be set in /etc/fuse.conf
diff --git a/util/fusermount.c b/util/fusermount.c
index 9e39dbd..d1568d5 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
@@ -343,24 +344,47 @@ static int unmount_fuse(const char *mnt, int quiet, int lazy)
}
#endif /* USE_UCLIBC */
+static void strip_line(char *line)
+{
+ char *s = strchr(line, '#');
+ if (s != NULL)
+ s[0] = '\0';
+ for (s = line + strlen(line) - 1; s >= line && isspace((unsigned char) *s); s--);
+ s[1] = '\0';
+ for (s = line; isspace((unsigned char) *s); s++);
+ if (s != line)
+ memmove(line, s, strlen(s)+1);
+}
+
static void read_conf(void)
{
FILE *fp = fopen(FUSE_CONF, "r");
if (fp != NULL) {
+ int linenum = 1;
char line[256];
int isnewline = 1;
while (fgets(line, sizeof(line), fp) != NULL) {
if (isnewline) {
- int tmp;
- if (strcmp(line, "user_allow_other\n") == 0)
- user_allow_other = 1;
- else if (sscanf(line, "mount_max = %i\n", &tmp) == 1)
- mount_max = tmp;
- }
- if(line[strlen(line)-1] == '\n')
- isnewline = 1;
- else
- isnewline = 0;
+ if (line[strlen(line)-1] == '\n') {
+ int tmp;
+ strip_line(line);
+ if (strcmp(line, "user_allow_other") == 0)
+ user_allow_other = 1;
+ else if (sscanf(line, "mount_max = %i", &tmp) == 1)
+ mount_max = tmp;
+ else if(line[0])
+ fprintf(stderr, "%s: unknown parameter in %s at line %i: '%s'\n",
+ progname, FUSE_CONF, linenum, line);
+ } else {
+ fprintf(stderr, "%s: reading %s: line %i too long\n",
+ progname, FUSE_CONF, linenum);
+ isnewline = 0;
+ }
+
+ } else if(line[strlen(line)-1] == '\n')
+ isnewline = 1;
+ if (isnewline)
+ linenum ++;
}
fclose(fp);
} else if (errno != ENOENT) {