Whamcloud - gitweb
fsck.c (parse_fstab_line, parse_escape): Add support for
authorTheodore Ts'o <tytso@mit.edu>
Thu, 23 Jan 2003 00:55:59 +0000 (19:55 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 23 Jan 2003 00:55:59 +0000 (19:55 -0500)
backslash escaping in /etc/fstab.  (i.e., so that \040
will work.)

misc/ChangeLog
misc/fsck.c

index e5e4fc1..c5273d4 100644 (file)
@@ -1,3 +1,9 @@
+2003-01-22  Theodore Ts'o  <tytso@mit.edu>
+
+       * fsck.c (parse_fstab_line, parse_escape): Add support for
+               backslash escaping in /etc/fstab.  (i.e., so that \040
+               will work.)
+
 2002-11-12  Theodore Ts'o  <tytso@mit.edu>
 
        * mke2fs.c (PRS): Don't enable the dir_index feature by default;
index ac54d2e..c6df845 100644 (file)
@@ -153,6 +153,41 @@ static char *parse_word(char **buf)
        return word;
 }
 
+static void parse_escape(char *word)
+{
+       char    *p, *q;
+       int     ac, i;
+
+       for (p = word, q = word; *p; p++, q++) {
+               *q = *p;
+               if (*p != '\\')
+                       continue;
+               if (*++p == 0)
+                       break;
+               if (*p == 't') {
+                       *q = '\t';
+                       continue;
+               }
+               if (*p == 'n') {
+                       *q = '\n';
+                       continue;
+               }
+               if (!isdigit(*p)) {
+                       *q = *p;
+                       continue;
+               }
+               ac = 0;
+               for (i = 0; i < 3; i++, p++) {
+                       if (!isdigit(*p))
+                               break;
+                       ac = (ac * 8) + (*p - '0');
+               }
+               *q = ac;
+               p--;
+       }
+       *q = 0;
+}
+
 static void free_instance(struct fsck_instance *i)
 {
        if (i->prog)
@@ -183,6 +218,13 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs)
        freq = parse_word(&cp);
        passno = parse_word(&cp);
 
+       parse_escape(device);
+       parse_escape(mntpnt);
+       parse_escape(type);
+       parse_escape(opts);
+       parse_escape(freq);
+       parse_escape(passno);
+
        if (!device)
                return 0;       /* Allow blank lines */