Deleted Added
sdiff udiff text old ( 149790 ) new ( 174664 )
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

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

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
42#endif /* not lint */
43#endif
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/bin/mv/mv.c 149790 2005-09-05 04:36:08Z csjp $");
46
47#include <sys/types.h>
48#include <sys/acl.h>
49#include <sys/param.h>
50#include <sys/time.h>
51#include <sys/wait.h>
52#include <sys/stat.h>
53#include <sys/mount.h>

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

350 if (vflg)
351 printf("%s -> %s\n", from, to);
352 return (0);
353}
354
355int
356copy(char *from, char *to)
357{
358 int pid, status;
359
360 if ((pid = fork()) == 0) {
361 execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to,
362 (char *)NULL);
363 warn("%s", _PATH_CP);
364 _exit(1);
365 }
366 if (waitpid(pid, &status, 0) == -1) {
367 warn("%s: waitpid", _PATH_CP);
368 return (1);
369 }
370 if (!WIFEXITED(status)) {
371 warnx("%s: did not terminate normally", _PATH_CP);
372 return (1);
373 }
374 if (WEXITSTATUS(status)) {
375 warnx("%s: terminated with %d (non-zero) status",
376 _PATH_CP, WEXITSTATUS(status));
377 return (1);
378 }
379 if (!(pid = vfork())) {
380 execl(_PATH_RM, "mv", "-rf", "--", from, (char *)NULL);
381 warn("%s", _PATH_RM);
382 _exit(1);
383 }
384 if (waitpid(pid, &status, 0) == -1) {
385 warn("%s: waitpid", _PATH_RM);
386 return (1);
387 }
388 if (!WIFEXITED(status)) {
389 warnx("%s: did not terminate normally", _PATH_RM);
390 return (1);
391 }
392 if (WEXITSTATUS(status)) {
393 warnx("%s: terminated with %d (non-zero) status",
394 _PATH_RM, WEXITSTATUS(status));
395 return (1);
396 }
397 return (0);
398}
399
400void
401usage(void)
402{
403
404 (void)fprintf(stderr, "%s\n%s\n",
405 "usage: mv [-f | -i | -n] [-v] source target",
406 " mv [-f | -i | -n] [-v] source ... directory");
407 exit(EX_USAGE);
408}