Add the possibility to specify "-o force" with "mdconfig -du".
Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
This commit is contained in:
parent
2715f5ad31
commit
81e2127caa
@ -62,6 +62,7 @@
|
|||||||
.Nm
|
.Nm
|
||||||
.Fl d
|
.Fl d
|
||||||
.Fl u Ar unit
|
.Fl u Ar unit
|
||||||
|
.Op Fl o Oo Cm no Oc Ns Ar force
|
||||||
.Nm
|
.Nm
|
||||||
.Fl l
|
.Fl l
|
||||||
.Op Fl n
|
.Op Fl n
|
||||||
|
@ -58,7 +58,7 @@ usage()
|
|||||||
"usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n"
|
"usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n"
|
||||||
" [-s size] [-S sectorsize] [-u unit]\n"
|
" [-s size] [-S sectorsize] [-u unit]\n"
|
||||||
" [-x sectors/track] [-y heads/cyl]\n"
|
" [-x sectors/track] [-y heads/cyl]\n"
|
||||||
" mdconfig -d -u unit\n"
|
" mdconfig -d -u unit [-o [no]force]\n"
|
||||||
" mdconfig -l [-v] [-n] [-u unit]\n");
|
" mdconfig -l [-v] [-n] [-u unit]\n");
|
||||||
fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n");
|
fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n");
|
||||||
fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n");
|
fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n");
|
||||||
@ -160,6 +160,16 @@ main(int argc, char **argv)
|
|||||||
close(fd);
|
close(fd);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
|
if (action == DETACH) {
|
||||||
|
if (!strcmp(optarg, "force"))
|
||||||
|
mdio.md_options |= MD_FORCE;
|
||||||
|
else if (!strcmp(optarg, "noforce"))
|
||||||
|
mdio.md_options &= ~MD_FORCE;
|
||||||
|
else
|
||||||
|
errx(1, "Unknown option: %s.", optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (cmdline != 2)
|
if (cmdline != 2)
|
||||||
usage();
|
usage();
|
||||||
if (!strcmp(optarg, "async"))
|
if (!strcmp(optarg, "async"))
|
||||||
|
@ -1133,13 +1133,15 @@ xmdctlioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread
|
|||||||
mdinit(sc);
|
mdinit(sc);
|
||||||
return (0);
|
return (0);
|
||||||
case MDIOCDETACH:
|
case MDIOCDETACH:
|
||||||
if (mdio->md_mediasize != 0 || mdio->md_options != 0)
|
if (mdio->md_mediasize != 0 ||
|
||||||
|
(mdio->md_options & ~MD_FORCE) != 0)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
sc = mdfind(mdio->md_unit);
|
sc = mdfind(mdio->md_unit);
|
||||||
if (sc == NULL)
|
if (sc == NULL)
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
if (sc->opencount != 0 && !(sc->flags & MD_FORCE))
|
if (sc->opencount != 0 && !(sc->flags & MD_FORCE) &&
|
||||||
|
!(mdio->md_options & MD_FORCE))
|
||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
return (mddestroy(sc, td));
|
return (mddestroy(sc, td));
|
||||||
case MDIOCQUERY:
|
case MDIOCQUERY:
|
||||||
|
Loading…
Reference in New Issue
Block a user