aboutsummaryrefslogtreecommitdiff
path: root/bin/mv
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2004-03-21 13:38:37 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2004-03-21 13:38:37 +0000
commit3184e921006e4ae6bb7d6d7b59199d21b0110a9d (patch)
tree4834090f89fd2ef1159ddb974beaab9ce83dee44 /bin/mv
parent8e6b7161d309a40b6a844765fd33556a077df6a7 (diff)
downloadsrc-3184e921006e4ae6bb7d6d7b59199d21b0110a9d.tar.gz
src-3184e921006e4ae6bb7d6d7b59199d21b0110a9d.zip
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
Notes
Notes: svn path=/head/; revision=127272
Diffstat (limited to 'bin/mv')
-rw-r--r--bin/mv/mv.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 009ce513f2ca..7044a819665e 100644
--- a/bin/mv/mv.c
+++ b/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);