always terminated with the dollar (
.B $
) token.
+.TP
+.BI slashes_are_spaces= value
+If set to 1, slashes ("/") in the first token of each line of the protofile
+are converted to spaces.
+This enables the creation of a filesystem containing filenames with spaces.
+By default, this is set to 0.
.RE
.TP
.B \-q
static char *newregfile(char **pp, int *len);
static void rtinit(xfs_mount_t *mp);
static long filesize(int fd);
+static int slashes_are_spaces;
/*
* Use this for block reservations needed for mkfs's conditions
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;
+
+ if (!slashes_are_spaces)
+ return p;
+
+ /* Replace slash with space because slashes aren't allowed. */
+ while (*c) {
+ if (*c == '/')
+ *c = ' ';
+ c++;
+ }
+
+ return p;
+}
+
static void
rsvfile(
xfs_mount_t *mp,
rtinit(mp);
tp = NULL;
for (;;) {
- name = getstr(pp);
+ name = getdirentname(pp);
if (!name)
break;
if (strcmp(name, "$") == 0)
parse_proto(
xfs_mount_t *mp,
struct fsxattr *fsx,
- char **pp)
+ char **pp,
+ int proto_slashes_are_spaces)
{
+ slashes_are_spaces = proto_slashes_are_spaces;
parseproto(mp, NULL, fsx, pp, NULL);
}
#define MKFS_PROTO_H_
char *setup_proto(char *fname);
-void parse_proto(struct xfs_mount *mp, struct fsxattr *fsx, char **pp);
+void parse_proto(struct xfs_mount *mp, struct fsxattr *fsx, char **pp,
+ int proto_slashes_are_spaces);
void res_failed(int err);
#endif /* MKFS_PROTO_H_ */
enum {
P_FILE = 0,
+ P_SLASHES,
P_MAX_OPTS,
};
.ini_section = "proto",
.subopts = {
[P_FILE] = "file",
+ [P_SLASHES] = "slashes_are_spaces",
[P_MAX_OPTS] = NULL,
},
.subopt_params = {
.conflicts = { { NULL, LAST_CONFLICT } },
.defaultval = SUBOPT_NEEDS_VAL,
},
+ { .index = P_SLASHES,
+ .conflicts = { { NULL, LAST_CONFLICT } },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
},
};
int loginternal;
int lsunit;
int is_supported;
+ int proto_slashes_are_spaces;
/* parameters where 0 is not a valid value */
int64_t agcount;
struct cli_params *cli)
{
switch (subopt) {
+ case P_SLASHES:
+ cli->proto_slashes_are_spaces = getnum(value, opts, subopt);
+ break;
case P_FILE:
fallthrough;
default:
/*
* Allocate the root inode and anything else in the proto file.
*/
- parse_proto(mp, &cli.fsx, &protostring);
+ parse_proto(mp, &cli.fsx, &protostring, cli.proto_slashes_are_spaces);
/*
* Protect ourselves against possible stupidity