Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umount: Add -d option to detach vn device #24

Closed

Conversation

ricardobranco777
Copy link
Contributor

Add a -d option to umount to detach a vnode device. A similar option exists in Linux's umount and FreeBSD: freebsd/freebsd-src#972

iteratee pushed a commit to iteratee/DragonFlyBSD that referenced this pull request Mar 13, 2024
While there, tweak a bit the assertion and conditional on 'pkt->p_af'.
dragonflybot pushed a commit that referenced this pull request Mar 22, 2024
The '-d' option tells umount(8) to detach the underlying vn(4) device if
the filesystem was mounted from it.  Note that vn(4) is a virtual disk
and can provides multiple filesystems, so the vn(4) detaching can only
succeed when all the filesystems are umounted.

For example:
$ vnconfig -c vn dfly.img
vn4
$ mount_msdos /dev/vn4s1 /mnt/dfly/boot
$ mount_ufs /dev/vn4s2a /mnt/dfly/root
$ umount -d /mnt/dfly/boot
umount: VNIOCDETACH: /dev/vn4: Device busy
umount: detach of /dev/vn4s1 failed
$ umount -d /mnt/dfly/root
(now vn4 is detached)

A similar option exists in Linux's and FreeBSD's umount(8).

GitHub PR: #24
See Also: freebsd/freebsd-src#972
@liweitianux
Copy link
Member

OK. I've merged this patch with some fixes and changes.

There was an issue with the original patch: it was detaching the /dev/vnXsY partition/slice device instead of the /dev/vnX, and that would make the vnX device still exists but unusable. For example, vnconfig -l will show it but vnconfig -e vnX would always fail with something like VNIOCATTACH: Device not configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants