On Fri, 19 Jul 2013 21:02:41 +0200, Christian Weisgerber wrote:
> Switching the processing order in getmntname() fixes the behavior.
> Can anybody think of something that would be broken by this?
I can't see any reason not do to this. I'm sure you were trying
for a minimal diff but doesn't it make more sense to make the loop
more like the one in umountall()?
- todd
Index: sbin/umount/umount.c
===================================================================
RCS file: /home/cvs/openbsd/src/sbin/umount/umount.c,v
retrieving revision 1.23
diff -u -r1.23 umount.c
--- sbin/umount/umount.c 21 Apr 2013 11:56:09 -0000 1.23
+++ sbin/umount/umount.c 19 Jul 2013 20:16:37 -0000
@@ -253,27 +253,27 @@
getmntname(char *name, mntwhat what, char *type)
{
struct statfs *mntbuf;
- int i, mntsize;
+ int n;
- if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
+ if ((n = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
warn("getmntinfo");
return (NULL);
}
- for (i = 0; i < mntsize; i++) {
+ while (--n >= 0) {
if ((what == MNTON) &&
- (strncmp(mntbuf[i].f_mntfromname, name, MNAMELEN) == 0 ||
- strncmp(mntbuf[i].f_mntfromspec, name, MNAMELEN) == 0)) {
+ (strncmp(mntbuf[n].f_mntfromname, name, MNAMELEN) == 0 ||
+ strncmp(mntbuf[n].f_mntfromspec, name, MNAMELEN) == 0)) {
if (type)
- memcpy(type, mntbuf[i].f_fstypename,
- sizeof(mntbuf[i].f_fstypename));
- return (mntbuf[i].f_mntonname);
+ memcpy(type, mntbuf[n].f_fstypename,
+ sizeof(mntbuf[n].f_fstypename));
+ return (mntbuf[n].f_mntonname);
}
if ((what == MNTFROM) &&
- (strncmp(mntbuf[i].f_mntonname, name, MNAMELEN) == 0)) {
+ (strncmp(mntbuf[n].f_mntonname, name, MNAMELEN) == 0)) {
if (type)
- memcpy(type, mntbuf[i].f_fstypename,
- sizeof(mntbuf[i].f_fstypename));
- return (mntbuf[i].f_mntfromname);
+ memcpy(type, mntbuf[n].f_fstypename,
+ sizeof(mntbuf[n].f_fstypename));
+ return (mntbuf[n].f_mntfromname);
}
}
return (NULL);