style(9) tweak
Approved by: dd
This commit is contained in:
parent
2fa4b9b3d6
commit
94ddc5afe9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81628
@ -86,7 +86,7 @@ static int run(int *, const char *, ...) __printflike(2, 3);
|
|||||||
static void usage(void);
|
static void usage(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int ac, char **av)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct mtpt_info mi; /* Mountpoint info. */
|
struct mtpt_info mi; /* Mountpoint info. */
|
||||||
char *mdconfig_arg, *newfs_arg, /* Args to helper programs. */
|
char *mdconfig_arg, *newfs_arg, /* Args to helper programs. */
|
||||||
@ -115,7 +115,7 @@ main(int ac, char **av)
|
|||||||
newfs_arg = strdup("");
|
newfs_arg = strdup("");
|
||||||
mount_arg = strdup("");
|
mount_arg = strdup("");
|
||||||
|
|
||||||
while ((ch = getopt(ac, av,
|
while ((ch = getopt(argc, argv,
|
||||||
"a:b:c:Dd:e:F:f:hi:LMm:Nn:O:o:p:Ss:t:w:X")) != -1)
|
"a:b:c:Dd:e:F:f:hi:LMm:Nn:O:o:p:Ss:t:w:X")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -198,13 +198,13 @@ main(int ac, char **av)
|
|||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
ac -= optind;
|
argc -= optind;
|
||||||
av += optind;
|
argv += optind;
|
||||||
if (ac < 2)
|
if (argc < 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
/* Derive 'unit' (global). */
|
/* Derive 'unit' (global). */
|
||||||
unitstr = av[0];
|
unitstr = argv[0];
|
||||||
if (strncmp(unitstr, "/dev/", 5) == 0)
|
if (strncmp(unitstr, "/dev/", 5) == 0)
|
||||||
unitstr += 5;
|
unitstr += 5;
|
||||||
if (strncmp(unitstr, mdname, mdnamelen) == 0)
|
if (strncmp(unitstr, mdname, mdnamelen) == 0)
|
||||||
@ -218,7 +218,7 @@ main(int ac, char **av)
|
|||||||
errx(1, "bad device unit: %s", unitstr);
|
errx(1, "bad device unit: %s", unitstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtpoint = av[1];
|
mtpoint = argv[1];
|
||||||
if (!have_mdtype)
|
if (!have_mdtype)
|
||||||
mdtype = MD_SWAP;
|
mdtype = MD_SWAP;
|
||||||
if (softdep)
|
if (softdep)
|
||||||
@ -540,8 +540,8 @@ extract_ugid(const char *str, struct mtpt_info *mip)
|
|||||||
static int
|
static int
|
||||||
run(int *ofd, const char *cmdline, ...)
|
run(int *ofd, const char *cmdline, ...)
|
||||||
{
|
{
|
||||||
char **av, **avp; /* Result of splitting 'cmd'. */
|
char **argv, **argvp; /* Result of splitting 'cmd'. */
|
||||||
int ac;
|
int argc;
|
||||||
char *cmd; /* Expansion of 'cmdline'. */
|
char *cmd; /* Expansion of 'cmdline'. */
|
||||||
int pid, status; /* Child info. */
|
int pid, status; /* Child info. */
|
||||||
int pfd[2]; /* Pipe to the child. */
|
int pfd[2]; /* Pipe to the child. */
|
||||||
@ -558,18 +558,18 @@ run(int *ofd, const char *cmdline, ...)
|
|||||||
err(1, "vasprintf");
|
err(1, "vasprintf");
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
/* Split up 'cmd' into 'av' for use with execve. */
|
/* Split up 'cmd' into 'argv' for use with execve. */
|
||||||
for (ac = 1, p = cmd; (p = strchr(p, ' ')) != NULL; p++)
|
for (argc = 1, p = cmd; (p = strchr(p, ' ')) != NULL; p++)
|
||||||
ac++; /* 'ac' generation loop. */
|
argc++; /* 'argc' generation loop. */
|
||||||
av = (char **)malloc(sizeof(*av) * (ac + 1));
|
argv = (char **)malloc(sizeof(*argv) * (argc + 1));
|
||||||
assert(av != NULL);
|
assert(argv != NULL);
|
||||||
for (p = cmd, avp = av; (*avp = strsep(&p, " ")) != NULL;)
|
for (p = cmd, argvp = argv; (*argvp = strsep(&p, " ")) != NULL;)
|
||||||
if (**av != '\0')
|
if (**argv != '\0')
|
||||||
if (++avp >= &av[ac]) {
|
if (++argvp >= &argv[argc]) {
|
||||||
*avp = NULL;
|
*argvp = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(*av);
|
assert(*argv);
|
||||||
|
|
||||||
/* Make sure the above loop works as expected. */
|
/* Make sure the above loop works as expected. */
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -583,8 +583,8 @@ run(int *ofd, const char *cmdline, ...)
|
|||||||
*/
|
*/
|
||||||
(void)fprintf(stderr, "DEBUG: running:");
|
(void)fprintf(stderr, "DEBUG: running:");
|
||||||
/* Should be equivilent to 'cmd' (before strsep, of course). */
|
/* Should be equivilent to 'cmd' (before strsep, of course). */
|
||||||
for (i = 0; av[i] != NULL; i++)
|
for (i = 0; argv[i] != NULL; i++)
|
||||||
(void)fprintf(stderr, " %s", av[i]);
|
(void)fprintf(stderr, " %s", argv[i]);
|
||||||
(void)fprintf(stderr, "\n");
|
(void)fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,15 +617,15 @@ run(int *ofd, const char *cmdline, ...)
|
|||||||
err(1, "dup2");
|
err(1, "dup2");
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)execv(av[0], av);
|
(void)execv(argv[0], argv);
|
||||||
warn("exec: %s", av[0]);
|
warn("exec: %s", argv[0]);
|
||||||
_exit(-1);
|
_exit(-1);
|
||||||
case -1:
|
case -1:
|
||||||
err(1, "fork");
|
err(1, "fork");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
free(av);
|
free(argv);
|
||||||
while (waitpid(pid, &status, 0) != pid)
|
while (waitpid(pid, &status, 0) != pid)
|
||||||
;
|
;
|
||||||
return (WEXITSTATUS(status));
|
return (WEXITSTATUS(status));
|
||||||
|
Loading…
Reference in New Issue
Block a user