Use realpath() on the source as well as the target otherwise it can be

impossible to unmount a union which was mounted with a relative pathname.
This commit is contained in:
Doug Rabson 1997-04-29 09:09:09 +00:00
parent 4b15c06830
commit 64a094f9de
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25275
2 changed files with 16 additions and 8 deletions

View File

@ -73,6 +73,7 @@ main(argc, argv)
{
struct union_args args;
int ch, mntflags;
char source[MAXPATHLEN];
char target[MAXPATHLEN];
struct vfsconf vfc;
int error;
@ -106,9 +107,12 @@ main(argc, argv)
if (realpath(argv[0], target) == 0)
err(EX_OSERR, "%s", target);
if (subdir(target, argv[1]) || subdir(argv[1], target))
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
argv[0], target, argv[1]);
if (realpath(argv[1], source) == 0)
err(EX_OSERR, "%s", target);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",
argv[0], target, argv[1], source);
args.target = target;
@ -122,7 +126,7 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "union filesystem is not available");
if (mount(vfc.vfc_name, argv[1], mntflags, &args))
if (mount(vfc.vfc_name, source, mntflags, &args))
err(EX_OSERR, target);
exit(0);
}

View File

@ -73,6 +73,7 @@ main(argc, argv)
{
struct union_args args;
int ch, mntflags;
char source[MAXPATHLEN];
char target[MAXPATHLEN];
struct vfsconf vfc;
int error;
@ -106,9 +107,12 @@ main(argc, argv)
if (realpath(argv[0], target) == 0)
err(EX_OSERR, "%s", target);
if (subdir(target, argv[1]) || subdir(argv[1], target))
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
argv[0], target, argv[1]);
if (realpath(argv[1], source) == 0)
err(EX_OSERR, "%s", target);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",
argv[0], target, argv[1], source);
args.target = target;
@ -122,7 +126,7 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "union filesystem is not available");
if (mount(vfc.vfc_name, argv[1], mntflags, &args))
if (mount(vfc.vfc_name, source, mntflags, &args))
err(EX_OSERR, target);
exit(0);
}