]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: substitute slashes with spaces in protofiles xfsprogs-fixes-6.2_2023-02-17
authorDarrick J. Wong <djwong@kernel.org>
Thu, 2 Feb 2023 01:02:53 +0000 (17:02 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Sat, 18 Feb 2023 00:50:36 +0000 (16:50 -0800)
A user requested the ability to specify directory entry names in a
protofile that have spaces in them.  The protofile format itself does
not allow spaces (yay 1973-era protofiles!) but it does allow slashes.
Slashes aren't allowed in directory entry names, so we'll permit this
one gross hack.

/
0 0
d--775 1000 1000
: Descending path /code/t/fstests
 get/isk.sh   ---775 1000 1000 /code/t/fstests/getdisk.sh
$

Will produce "get isk.h" in the root directory.

Requested-by: Daan De Meyer <daan.j.demeyer@gmail.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
mkfs/proto.c

index 68ecdbf36325cb7c5640b42475c9eb53a2683fbe..bf8de0189dbee5afef0bae24e85ca75eea838b15 100644 (file)
@@ -171,6 +171,27 @@ getstr(
        return NULL;
 }
 
+/* Extract directory entry name from a protofile. */
+static char *
+getdirentname(
+       char    **pp)
+{
+       char    *p = getstr(pp);
+       char    *c = p;
+
+       if (!p)
+               return NULL;
+
+       /* Replace slash with space because slashes aren't allowed. */
+       while (*c) {
+               if (*c == '/')
+                       *c = ' ';
+               c++;
+       }
+
+       return p;
+}
+
 static void
 rsvfile(
        xfs_mount_t     *mp,
@@ -580,7 +601,7 @@ parseproto(
                        rtinit(mp);
                tp = NULL;
                for (;;) {
-                       name = getstr(pp);
+                       name = getdirentname(pp);
                        if (!name)
                                break;
                        if (strcmp(name, "$") == 0)