mv.c (76878) | mv.c (77409) |
---|---|
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[] = | 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 $"; | 48 "$FreeBSD: head/bin/mv/mv.c 77409 2001-05-29 18:20:36Z imp $"; |
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> | 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 <limits.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; | 61#include <stdio.h> 62#include <stdlib.h> 63#include <string.h> 64#include <sysexits.h> 65#include <unistd.h> 66 67#include "pathnames.h" 68 --- 9 unchanged lines hidden (view full) --- 78main(argc, argv) 79 int argc; 80 char *argv[]; 81{ 82 register int baselen, len, rval; 83 register char *p, *endp; 84 struct stat sb; 85 int ch; |
85 char path[MAXPATHLEN]; | 86 char path[PATH_MAX]; |
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 | 87 88 while ((ch = getopt(argc, argv, "fiv")) != -1) 89 switch (ch) { 90 case 'i': 91 iflg = 1; 92 fflg = 0; 93 break; 94 case 'f': --- 38 unchanged lines hidden (view full) --- 133 * may have trailing slashes. 134 */ 135 p = *argv + strlen(*argv); 136 while (p != *argv && p[-1] == '/') 137 --p; 138 while (p != *argv && p[-1] != '/') 139 --p; 140 |
140 if ((baselen + (len = strlen(p))) >= MAXPATHLEN) { | 141 if ((baselen + (len = strlen(p))) >= PATH_MAX) { |
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; | 142 warnx("%s: destination pathname too long", *argv); 143 rval = 1; 144 } else { 145 memmove(endp, p, (size_t)len + 1); 146 if (do_move(*argv, path)) 147 rval = 1; 148 } 149 } --- 47 unchanged lines hidden (view full) --- 197 if (!rename(from, to)) { 198 if (vflg) 199 printf("%s -> %s\n", from, to); 200 return (0); 201 } 202 203 if (errno == EXDEV) { 204 struct statfs sfs; |
204 char path[MAXPATHLEN]; | 205 char path[PATH_MAX]; |
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 --- | 206 207 /* Can't mv(1) a mount point. */ 208 if (realpath(from, path) == NULL) { 209 warnx("cannot resolve %s: %s", from, path); 210 return (1); 211 } 212 if (!statfs(path, &sfs) && !strcmp(path, sfs.f_mntonname)) { 213 warnx("cannot rename a mount point"); --- 167 unchanged lines hidden --- |