|
Lines 152-161
Link Here
|
| 152 |
do_move(from, to) |
152 |
do_move(from, to) |
| 153 |
char *from, *to; |
153 |
char *from, *to; |
| 154 |
{ |
154 |
{ |
| 155 |
struct stat sb; |
155 |
struct stat sb_from, sb; |
| 156 |
int ask, ch, first; |
156 |
int ask, ch, first, got_from; |
| 157 |
char modep[15]; |
157 |
char modep[15]; |
| 158 |
|
158 |
|
|
|
159 |
got_from = 0; /* lstat of "from" not done yet */ |
| 159 |
/* |
160 |
/* |
| 160 |
* Check access. If interactive and file exists, ask user if it |
161 |
* Check access. If interactive and file exists, ask user if it |
| 161 |
* should be replaced. Otherwise if file exists but isn't writable |
162 |
* should be replaced. Otherwise if file exists but isn't writable |
|
Lines 164-173
Link Here
|
| 164 |
if (!fflg && !access(to, F_OK)) { |
165 |
if (!fflg && !access(to, F_OK)) { |
| 165 |
|
166 |
|
| 166 |
/* prompt only if source exist */ |
167 |
/* prompt only if source exist */ |
| 167 |
if (lstat(from, &sb) == -1) { |
168 |
if (lstat(from, &sb_from) == -1) { |
| 168 |
warn("%s", from); |
169 |
warn("%s", from); |
| 169 |
return (1); |
170 |
return (1); |
| 170 |
} |
171 |
} |
|
|
172 |
got_from = 1; |
| 171 |
|
173 |
|
| 172 |
#define YESNO "(y/n [n]) " |
174 |
#define YESNO "(y/n [n]) " |
| 173 |
ask = 0; |
175 |
ask = 0; |
|
Lines 202-207
Link Here
|
| 202 |
struct statfs sfs; |
204 |
struct statfs sfs; |
| 203 |
char path[MAXPATHLEN]; |
205 |
char path[MAXPATHLEN]; |
| 204 |
|
206 |
|
|
|
207 |
/* if from isn't a directory it can't be a mount point */ |
| 208 |
if (!got_from && lstat(from, &sb_from) == -1) { |
| 209 |
warn("%s", from); |
| 210 |
return (1); |
| 211 |
} |
| 212 |
if (!S_ISDIR(sb_from.st_mode)) |
| 213 |
goto copy_it; |
| 214 |
|
| 205 |
/* Can't mv(1) a mount point. */ |
215 |
/* Can't mv(1) a mount point. */ |
| 206 |
if (realpath(from, path) == NULL) { |
216 |
if (realpath(from, path) == NULL) { |
| 207 |
warnx("cannot resolve %s: %s", from, path); |
217 |
warnx("cannot resolve %s: %s", from, path); |
|
Lines 221-232
Link Here
|
| 221 |
* it's a regular file, do the copy internally; otherwise, use |
231 |
* it's a regular file, do the copy internally; otherwise, use |
| 222 |
* cp and rm. |
232 |
* cp and rm. |
| 223 |
*/ |
233 |
*/ |
| 224 |
if (lstat(from, &sb)) { |
234 |
if (!got_from && lstat(from, &sb_from)) { |
| 225 |
warn("%s", from); |
235 |
warn("%s", from); |
| 226 |
return (1); |
236 |
return (1); |
| 227 |
} |
237 |
} |
| 228 |
return (S_ISREG(sb.st_mode) ? |
238 |
copy_it: |
| 229 |
fastcopy(from, to, &sb) : copy(from, to)); |
239 |
return (S_ISREG(sb_from.st_mode) ? |
|
|
240 |
fastcopy(from, to, &sb_from) : copy(from, to)); |
| 230 |
} |
241 |
} |
| 231 |
|
242 |
|
| 232 |
int |
243 |
int |