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 md devices #972
Conversation
867a9e3
to
fbfcb91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's some first pass review
i did find a few things that need changing
typedef enum { FIND, REMOVE, CHECKUNIQUE } dowhat; | ||
|
||
static struct addrinfo *nfshost_ai = NULL; | ||
static int fflag, vflag; | ||
static int dflag, fflag, vflag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is not for you, just in general:
all of these flags should be converted to bool
at some point
sbin/umount/umount.c
Outdated
mdio.md_options = fflag ? MD_FORCE : 0; | ||
|
||
if (strncmp(device, DEV_MD, sizeof(DEV_MD) - 1)) { | ||
if (!multiple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We checked this before entering the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We checked this before entering the function
I don't see a proper check for DEV_MD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i meant for multiple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i meant for multiple
In this case we need the check to avoid a warning when using -a
.
d871456
to
eaa3b5c
Compare
eaa3b5c
to
2e79aa6
Compare
(void)printf("%s: detached\n", | ||
sfs->f_mntfromname); | ||
} else if (!all) | ||
return (-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this means umount will return a failure code if -d is specified on non /dev/md backed devices. Is this what you want? And should the error checking be done before you unmount or after when you notice you can't detach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this means umount will return a failure code if -d is specified on non /dev/md backed devices. Is this what you want?
Yes, but only if the -a
wasn't specified for obvious reasons.
@@ -70,24 +80,28 @@ int checkname (char *, char **); | |||
int umountfs(struct statfs *sfs); | |||
void usage (void); | |||
int xdr_dir (XDR *, char *); | |||
int md_detach(const char *); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is only used in umount.c, it should be static... but all the other functions above it should be too, so consistency wins out over standard practice. Just fyi for next time.
OK. I think this is ready. The style script spotted a non-static function used only in umount... but it is consistent with the others, so I'm going to let the consistency rule trump the static rule. |
Reviewed by: imp Pull Request: #972
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
Add a
-d
option to umount(8) to detach a memory device. A similar option exists in Linux's umount(8).Follow-up to https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=114468