Deleted Added
sdiff udiff text old ( 76878 ) new ( 77409 )
full compact
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ken Smith of The State University of New York at Buffalo.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 31 unchanged lines hidden (view full) ---

40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
46#endif
47static const char rcsid[] =
48 "$FreeBSD: head/bin/mv/mv.c 76878 2001-05-20 05:00:16Z kris $";
49#endif /* not lint */
50
51#include <sys/param.h>
52#include <sys/time.h>
53#include <sys/wait.h>
54#include <sys/stat.h>
55#include <sys/mount.h>
56
57#include <err.h>
58#include <errno.h>
59#include <fcntl.h>
60#include <stdio.h>
61#include <stdlib.h>
62#include <string.h>
63#include <sysexits.h>
64#include <unistd.h>
65
66#include "pathnames.h"
67

--- 9 unchanged lines hidden (view full) ---

77main(argc, argv)
78 int argc;
79 char *argv[];
80{
81 register int baselen, len, rval;
82 register char *p, *endp;
83 struct stat sb;
84 int ch;
85 char path[MAXPATHLEN];
86
87 while ((ch = getopt(argc, argv, "fiv")) != -1)
88 switch (ch) {
89 case 'i':
90 iflg = 1;
91 fflg = 0;
92 break;
93 case 'f':

--- 38 unchanged lines hidden (view full) ---

132 * may have trailing slashes.
133 */
134 p = *argv + strlen(*argv);
135 while (p != *argv && p[-1] == '/')
136 --p;
137 while (p != *argv && p[-1] != '/')
138 --p;
139
140 if ((baselen + (len = strlen(p))) >= MAXPATHLEN) {
141 warnx("%s: destination pathname too long", *argv);
142 rval = 1;
143 } else {
144 memmove(endp, p, (size_t)len + 1);
145 if (do_move(*argv, path))
146 rval = 1;
147 }
148 }

--- 47 unchanged lines hidden (view full) ---

196 if (!rename(from, to)) {
197 if (vflg)
198 printf("%s -> %s\n", from, to);
199 return (0);
200 }
201
202 if (errno == EXDEV) {
203 struct statfs sfs;
204 char path[MAXPATHLEN];
205
206 /* Can't mv(1) a mount point. */
207 if (realpath(from, path) == NULL) {
208 warnx("cannot resolve %s: %s", from, path);
209 return (1);
210 }
211 if (!statfs(path, &sfs) && !strcmp(path, sfs.f_mntonname)) {
212 warnx("cannot rename a mount point");

--- 167 unchanged lines hidden ---