Fix PR 1607, hopefully without breaking the PR 5208 fixes.
umount() was trying to stat() the mountpoint, this would fail if the mountpoint was a NFS mountpoint, and the fallback code would try and pass a hostname:/dir path as the mountpoint to unmount(2), which would fail. This whole stat() of the name supplied on the command line business is trouble as it'll wedge on a hung NFS mount. I'm not entirely sure why we are not simply looking up both arguments in the mount table and doing the right thing without accessing the filesystem. It seems that we're going to a lot of trouble to allow mountpoints on symlinks and other wierd things. PR: 1607
This commit is contained in:
parent
1f56217280
commit
428fb2dd11
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35939
@ -212,37 +212,37 @@ umountfs(name, typelist)
|
||||
struct timeval pertry, try;
|
||||
CLIENT *clp;
|
||||
int so;
|
||||
char *type, *delimp, *hostp, *mntpt, *newname, rname[MAXPATHLEN];
|
||||
char *type, *delimp, *hostp, *mntpt, *origname, rname[MAXPATHLEN];
|
||||
|
||||
if (realpath(name, rname) == NULL) {
|
||||
/* Continue and let the system call check it... */
|
||||
strcpy(rname, name);
|
||||
}
|
||||
|
||||
origname = name;
|
||||
if (stat(name, &sb) < 0) {
|
||||
if (((mntpt = getmntname(rname, MNTFROM, &type)) == NULL) &&
|
||||
mntpt = rname;
|
||||
if ((getmntname(rname, MNTFROM, &type) == NULL) &&
|
||||
((mntpt = getmntname(name, MNTON, &type)) == NULL)) {
|
||||
warnx("%s: not currently mounted", name);
|
||||
return (1);
|
||||
}
|
||||
name = rname;
|
||||
} else if (S_ISBLK(sb.st_mode)) {
|
||||
if ((mntpt = getmntname(name, MNTON, &type)) == NULL) {
|
||||
warnx("%s: not currently mounted", name);
|
||||
return (1);
|
||||
}
|
||||
name = rname;
|
||||
} else if (S_ISDIR(sb.st_mode)) {
|
||||
mntpt = rname;
|
||||
if ((newname = getmntname(mntpt, MNTFROM, &type)) == NULL) {
|
||||
if (getmntname(mntpt, MNTFROM, &type) == NULL) {
|
||||
warnx("%s: not currently mounted", name);
|
||||
return (1);
|
||||
}
|
||||
newname = name;
|
||||
} else {
|
||||
warnx("%s: not a directory or special device", name);
|
||||
return (1);
|
||||
}
|
||||
name = rname;
|
||||
|
||||
if (checkvfsname(type, typelist))
|
||||
return (1);
|
||||
@ -267,7 +267,7 @@ umountfs(name, typelist)
|
||||
return (1);
|
||||
|
||||
if (vflag)
|
||||
(void)printf("%s: unmount from %s\n", name, mntpt);
|
||||
(void)printf("%s: unmount from %s\n", origname, mntpt);
|
||||
if (fake)
|
||||
return (0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user