Changeset View
Changeset View
Standalone View
Standalone View
sbin/mdmfs/mdmfs.c
Show All 12 Lines | |||||
/* Do the work. */ | /* Do the work. */ | ||||
if (detach && !autounit) | if (detach && !autounit) | ||||
do_mdconfig_detach(); | do_mdconfig_detach(); | ||||
if (autounit) | if (autounit) | ||||
do_mdconfig_attach_au(mdconfig_arg, mdtype); | do_mdconfig_attach_au(mdconfig_arg, mdtype); | ||||
else | else | ||||
do_mdconfig_attach(mdconfig_arg, mdtype); | do_mdconfig_attach(mdconfig_arg, mdtype); | ||||
free(mdconfig_arg); | |||||
if (newfs) | if (newfs) | ||||
do_newfs(newfs_arg); | do_newfs(newfs_arg); | ||||
free(newfs_arg); | |||||
do_mount(mount_arg, mtpoint); | do_mount(mount_arg, mtpoint); | ||||
free(mount_arg); | |||||
do_mtptsetup(mtpoint, &mi); | do_mtptsetup(mtpoint, &mi); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Append the expansion of 'fmt' to the buffer pointed to by '*dstp'; | * Append the expansion of 'fmt' to the buffer pointed to by '*dstp'; | ||||
* reallocate as required. | * reallocate as required. | ||||
Show All 24 Lines | |||||
/* If the output format changes, we want to know about it. */ | /* If the output format changes, we want to know about it. */ | ||||
assert(strncmp(linep, mdname, mdnamelen) == 0); | assert(strncmp(linep, mdname, mdnamelen) == 0); | ||||
linebuf = malloc(linelen - mdnamelen + 1); | linebuf = malloc(linelen - mdnamelen + 1); | ||||
assert(linebuf != NULL); | assert(linebuf != NULL); | ||||
/* Can't use strlcpy because linep is not NULL-terminated. */ | /* Can't use strlcpy because linep is not NULL-terminated. */ | ||||
strncpy(linebuf, linep + mdnamelen, linelen); | strncpy(linebuf, linep + mdnamelen, linelen); | ||||
linebuf[linelen] = '\0'; | linebuf[linelen] = '\0'; | ||||
ul = strtoul(linebuf, &p, 10); | ul = strtoul(linebuf, &p, 10); | ||||
free(linebuf); | |||||
if (ul == ULONG_MAX || *p != '\n') | if (ul == ULONG_MAX || *p != '\n') | ||||
errx(1, "unexpected output from mdconfig (attach)"); | errx(1, "unexpected output from mdconfig (attach)"); | ||||
unit = ul; | unit = ul; | ||||
fclose(sfd); | fclose(sfd); | ||||
close(fd); | close(fd); | ||||
} | } | ||||
Show All 12 Lines |