Deleted Added
full compact
rm.c (241014) rm.c (249948)
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

34 The Regents of the University of California. All rights reserved.\n";
35#endif /* not lint */
36
37#ifndef lint
38static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
39#endif /* not lint */
40#endif
41#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

34 The Regents of the University of California. All rights reserved.\n";
35#endif /* not lint */
36
37#ifndef lint
38static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
39#endif /* not lint */
40#endif
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: head/bin/rm/rm.c 241014 2012-09-27 23:31:12Z mdf $");
42__FBSDID("$FreeBSD: head/bin/rm/rm.c 249948 2013-04-26 17:45:37Z eadler $");
43
44#include <sys/stat.h>
45#include <sys/param.h>
46#include <sys/mount.h>
47
48#include <err.h>
49#include <errno.h>
50#include <fcntl.h>
51#include <fts.h>
52#include <grp.h>
53#include <pwd.h>
54#include <stdint.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <string.h>
58#include <sysexits.h>
59#include <unistd.h>
60
61static int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
43
44#include <sys/stat.h>
45#include <sys/param.h>
46#include <sys/mount.h>
47
48#include <err.h>
49#include <errno.h>
50#include <fcntl.h>
51#include <fts.h>
52#include <grp.h>
53#include <pwd.h>
54#include <stdint.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <string.h>
58#include <sysexits.h>
59#include <unistd.h>
60
61static int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
62static int rflag, Iflag;
62static int rflag, Iflag, xflag;
63static uid_t uid;
64static volatile sig_atomic_t info;
65
66int check(char *, char *, struct stat *);
67int check2(char **);
68void checkdot(char **);
69void checkslash(char **);
70void rm_file(char **);

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

101 argc -= optind;
102 argv += optind;
103 if (argc != 1)
104 usage();
105 rm_file(&argv[0]);
106 exit(eval);
107 }
108
63static uid_t uid;
64static volatile sig_atomic_t info;
65
66int check(char *, char *, struct stat *);
67int check2(char **);
68void checkdot(char **);
69void checkslash(char **);
70void rm_file(char **);

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

101 argc -= optind;
102 argv += optind;
103 if (argc != 1)
104 usage();
105 rm_file(&argv[0]);
106 exit(eval);
107 }
108
109 Pflag = rflag = 0;
110 while ((ch = getopt(argc, argv, "dfiIPRrvW")) != -1)
109 Pflag = rflag = xflag = 0;
110 while ((ch = getopt(argc, argv, "dfiIPRrvWx")) != -1)
111 switch(ch) {
112 case 'd':
113 dflag = 1;
114 break;
115 case 'f':
116 fflag = 1;
117 iflag = 0;
118 break;

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

131 rflag = 1;
132 break;
133 case 'v':
134 vflag = 1;
135 break;
136 case 'W':
137 Wflag = 1;
138 break;
111 switch(ch) {
112 case 'd':
113 dflag = 1;
114 break;
115 case 'f':
116 fflag = 1;
117 iflag = 0;
118 break;

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

131 rflag = 1;
132 break;
133 case 'v':
134 vflag = 1;
135 break;
136 case 'W':
137 Wflag = 1;
138 break;
139 case 'x':
140 xflag = 1;
141 break;
139 default:
140 usage();
141 }
142 argc -= optind;
143 argv += optind;
144
145 if (argc < 1) {
146 if (fflag)

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

191 */
192#define SKIPPED 1
193
194 flags = FTS_PHYSICAL;
195 if (!needstat)
196 flags |= FTS_NOSTAT;
197 if (Wflag)
198 flags |= FTS_WHITEOUT;
142 default:
143 usage();
144 }
145 argc -= optind;
146 argv += optind;
147
148 if (argc < 1) {
149 if (fflag)

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

194 */
195#define SKIPPED 1
196
197 flags = FTS_PHYSICAL;
198 if (!needstat)
199 flags |= FTS_NOSTAT;
200 if (Wflag)
201 flags |= FTS_WHITEOUT;
202 if (xflag)
203 flags |= FTS_XDEV;
199 if (!(fts = fts_open(argv, flags, NULL))) {
200 if (fflag && errno == ENOENT)
201 return;
202 err(1, "fts_open");
203 }
204 while ((p = fts_read(fts)) != NULL) {
205 switch (p->fts_info) {
206 case FTS_DNR:

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

619 }
620}
621
622void
623usage(void)
624{
625
626 (void)fprintf(stderr, "%s\n%s\n",
204 if (!(fts = fts_open(argv, flags, NULL))) {
205 if (fflag && errno == ENOENT)
206 return;
207 err(1, "fts_open");
208 }
209 while ((p = fts_read(fts)) != NULL) {
210 switch (p->fts_info) {
211 case FTS_DNR:

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

624 }
625}
626
627void
628usage(void)
629{
630
631 (void)fprintf(stderr, "%s\n%s\n",
627 "usage: rm [-f | -i] [-dIPRrvW] file ...",
632 "usage: rm [-f | -i] [-dIPRrvWx] file ...",
628 " unlink file");
629 exit(EX_USAGE);
630}
631
632static void
633siginfo(int sig __unused)
634{
635
636 info = 1;
637}
633 " unlink file");
634 exit(EX_USAGE);
635}
636
637static void
638siginfo(int sig __unused)
639{
640
641 info = 1;
642}