mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-28 11:57:28 +00:00
When symbolic link is pointed onto a mount point, it can't be moved
to a different file system. Patch in PR was incorrect. PR: bin/64430 Submitted by: Samuel Tardieu MFC after: 3 days
This commit is contained in:
parent
8e6b7161d3
commit
3184e92100
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127272
23
bin/mv/mv.c
23
bin/mv/mv.c
@ -210,14 +210,25 @@ do_move(char *from, char *to)
|
||||
struct statfs sfs;
|
||||
char path[PATH_MAX];
|
||||
|
||||
/* Can't mv(1) a mount point. */
|
||||
if (realpath(from, path) == NULL) {
|
||||
warnx("cannot resolve %s: %s", from, path);
|
||||
/*
|
||||
* If the source is a symbolic link and is on another
|
||||
* filesystem, it can be recreated at the destination.
|
||||
*/
|
||||
if (lstat(from, &sb) == -1) {
|
||||
warn("%s", from);
|
||||
return (1);
|
||||
}
|
||||
if (!statfs(path, &sfs) && !strcmp(path, sfs.f_mntonname)) {
|
||||
warnx("cannot rename a mount point");
|
||||
return (1);
|
||||
if (!S_ISLNK(sb.st_mode)) {
|
||||
/* Can't mv(1) a mount point. */
|
||||
if (realpath(from, path) == NULL) {
|
||||
warnx("cannot resolve %s: %s", from, path);
|
||||
return (1);
|
||||
}
|
||||
if (!statfs(path, &sfs) &&
|
||||
!strcmp(path, sfs.f_mntonname)) {
|
||||
warnx("cannot rename a mount point");
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warn("rename %s to %s", from, to);
|
||||
|
Loading…
Reference in New Issue
Block a user