14b88c807SRodney W. Grimes /*- 24b88c807SRodney W. Grimes * Copyright (c) 1990, 1993, 1994 34b88c807SRodney W. Grimes * The Regents of the University of California. All rights reserved. 44b88c807SRodney W. Grimes * 54b88c807SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 64b88c807SRodney W. Grimes * modification, are permitted provided that the following conditions 74b88c807SRodney W. Grimes * are met: 84b88c807SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 94b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 104b88c807SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 114b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 124b88c807SRodney W. Grimes * documentation and/or other materials provided with the distribution. 134b88c807SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 144b88c807SRodney W. Grimes * must display the following acknowledgement: 154b88c807SRodney W. Grimes * This product includes software developed by the University of 164b88c807SRodney W. Grimes * California, Berkeley and its contributors. 174b88c807SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 184b88c807SRodney W. Grimes * may be used to endorse or promote products derived from this software 194b88c807SRodney W. Grimes * without specific prior written permission. 204b88c807SRodney W. Grimes * 214b88c807SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 224b88c807SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 234b88c807SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 244b88c807SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 254b88c807SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 264b88c807SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 274b88c807SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 284b88c807SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 294b88c807SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 304b88c807SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 314b88c807SRodney W. Grimes * SUCH DAMAGE. 324b88c807SRodney W. Grimes */ 334b88c807SRodney W. Grimes 344b88c807SRodney W. Grimes #ifndef lint 354b88c807SRodney W. Grimes static char copyright[] = 364b88c807SRodney W. Grimes "@(#) Copyright (c) 1990, 1993, 1994\n\ 374b88c807SRodney W. Grimes The Regents of the University of California. All rights reserved.\n"; 384b88c807SRodney W. Grimes #endif /* not lint */ 394b88c807SRodney W. Grimes 404b88c807SRodney W. Grimes #ifndef lint 414b88c807SRodney W. Grimes static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94"; 424b88c807SRodney W. Grimes #endif /* not lint */ 434b88c807SRodney W. Grimes 444b88c807SRodney W. Grimes #include <sys/types.h> 454b88c807SRodney W. Grimes #include <sys/stat.h> 464b88c807SRodney W. Grimes 474b88c807SRodney W. Grimes #include <err.h> 484b88c807SRodney W. Grimes #include <errno.h> 494b88c807SRodney W. Grimes #include <fcntl.h> 504b88c807SRodney W. Grimes #include <fts.h> 514b88c807SRodney W. Grimes #include <stdio.h> 524b88c807SRodney W. Grimes #include <stdlib.h> 534b88c807SRodney W. Grimes #include <string.h> 544b88c807SRodney W. Grimes #include <unistd.h> 554b88c807SRodney W. Grimes 564b88c807SRodney W. Grimes int dflag, eval, fflag, iflag, Pflag, stdin_ok; 574b88c807SRodney W. Grimes 584b88c807SRodney W. Grimes int check __P((char *, char *, struct stat *)); 594b88c807SRodney W. Grimes void checkdot __P((char **)); 604b88c807SRodney W. Grimes void rm_file __P((char **)); 614b88c807SRodney W. Grimes void rm_overwrite __P((char *, struct stat *)); 624b88c807SRodney W. Grimes void rm_tree __P((char **)); 634b88c807SRodney W. Grimes void usage __P((void)); 6467a3d3a8SPoul-Henning Kamp char *user_from_uid __P((uid_t, int)); 6567a3d3a8SPoul-Henning Kamp char *group_from_gid __P((gid_t, int)); 664b88c807SRodney W. Grimes 674b88c807SRodney W. Grimes /* 684b88c807SRodney W. Grimes * rm -- 694b88c807SRodney W. Grimes * This rm is different from historic rm's, but is expected to match 704b88c807SRodney W. Grimes * POSIX 1003.2 behavior. The most visible difference is that -f 714b88c807SRodney W. Grimes * has two specific effects now, ignore non-existent files and force 724b88c807SRodney W. Grimes * file removal. 734b88c807SRodney W. Grimes */ 744b88c807SRodney W. Grimes int 754b88c807SRodney W. Grimes main(argc, argv) 764b88c807SRodney W. Grimes int argc; 774b88c807SRodney W. Grimes char *argv[]; 784b88c807SRodney W. Grimes { 794b88c807SRodney W. Grimes int ch, rflag; 804b88c807SRodney W. Grimes 814b88c807SRodney W. Grimes Pflag = rflag = 0; 824b88c807SRodney W. Grimes while ((ch = getopt(argc, argv, "dfiPRr")) != EOF) 834b88c807SRodney W. Grimes switch(ch) { 844b88c807SRodney W. Grimes case 'd': 854b88c807SRodney W. Grimes dflag = 1; 864b88c807SRodney W. Grimes break; 874b88c807SRodney W. Grimes case 'f': 884b88c807SRodney W. Grimes fflag = 1; 894b88c807SRodney W. Grimes iflag = 0; 904b88c807SRodney W. Grimes break; 914b88c807SRodney W. Grimes case 'i': 924b88c807SRodney W. Grimes fflag = 0; 934b88c807SRodney W. Grimes iflag = 1; 944b88c807SRodney W. Grimes break; 954b88c807SRodney W. Grimes case 'P': 964b88c807SRodney W. Grimes Pflag = 1; 974b88c807SRodney W. Grimes break; 984b88c807SRodney W. Grimes case 'R': 994b88c807SRodney W. Grimes case 'r': /* Compatibility. */ 1004b88c807SRodney W. Grimes rflag = 1; 1014b88c807SRodney W. Grimes break; 1024b88c807SRodney W. Grimes case '?': 1034b88c807SRodney W. Grimes default: 1044b88c807SRodney W. Grimes usage(); 1054b88c807SRodney W. Grimes } 1064b88c807SRodney W. Grimes argc -= optind; 1074b88c807SRodney W. Grimes argv += optind; 1084b88c807SRodney W. Grimes 1094b88c807SRodney W. Grimes if (argc < 1) 1104b88c807SRodney W. Grimes usage(); 1114b88c807SRodney W. Grimes 1124b88c807SRodney W. Grimes checkdot(argv); 1134b88c807SRodney W. Grimes if (!*argv) 1144b88c807SRodney W. Grimes exit (eval); 1154b88c807SRodney W. Grimes 1164b88c807SRodney W. Grimes stdin_ok = isatty(STDIN_FILENO); 1174b88c807SRodney W. Grimes 1184b88c807SRodney W. Grimes if (rflag) 1194b88c807SRodney W. Grimes rm_tree(argv); 1204b88c807SRodney W. Grimes else 1214b88c807SRodney W. Grimes rm_file(argv); 1224b88c807SRodney W. Grimes exit (eval); 1234b88c807SRodney W. Grimes } 1244b88c807SRodney W. Grimes 1254b88c807SRodney W. Grimes void 1264b88c807SRodney W. Grimes rm_tree(argv) 1274b88c807SRodney W. Grimes char **argv; 1284b88c807SRodney W. Grimes { 1294b88c807SRodney W. Grimes FTS *fts; 1304b88c807SRodney W. Grimes FTSENT *p; 1314b88c807SRodney W. Grimes int needstat; 1324b88c807SRodney W. Grimes 1334b88c807SRodney W. Grimes /* 1344b88c807SRodney W. Grimes * Remove a file hierarchy. If forcing removal (-f), or interactive 1354b88c807SRodney W. Grimes * (-i) or can't ask anyway (stdin_ok), don't stat the file. 1364b88c807SRodney W. Grimes */ 1374b88c807SRodney W. Grimes needstat = !fflag && !iflag && stdin_ok; 1384b88c807SRodney W. Grimes 1394b88c807SRodney W. Grimes /* 1404b88c807SRodney W. Grimes * If the -i option is specified, the user can skip on the pre-order 1414b88c807SRodney W. Grimes * visit. The fts_number field flags skipped directories. 1424b88c807SRodney W. Grimes */ 1434b88c807SRodney W. Grimes #define SKIPPED 1 1444b88c807SRodney W. Grimes 1454b88c807SRodney W. Grimes if (!(fts = fts_open(argv, 146a8c32ea5SAndreas Schulz needstat ? FTS_PHYSICAL|FTS_NOCHDIR : 147a8c32ea5SAndreas Schulz FTS_PHYSICAL|FTS_NOSTAT|FTS_NOCHDIR, (int (*)())NULL))) 1484b88c807SRodney W. Grimes err(1, NULL); 1494b88c807SRodney W. Grimes while ((p = fts_read(fts)) != NULL) { 1504b88c807SRodney W. Grimes switch (p->fts_info) { 1514b88c807SRodney W. Grimes case FTS_DNR: 1524b88c807SRodney W. Grimes if (!fflag || p->fts_errno != ENOENT) { 1534b88c807SRodney W. Grimes warnx("%s: %s", 1544b88c807SRodney W. Grimes p->fts_path, strerror(p->fts_errno)); 1554b88c807SRodney W. Grimes eval = 1; 1564b88c807SRodney W. Grimes } 1574b88c807SRodney W. Grimes continue; 1584b88c807SRodney W. Grimes case FTS_ERR: 1594b88c807SRodney W. Grimes errx(1, "%s: %s", p->fts_path, strerror(p->fts_errno)); 1604b88c807SRodney W. Grimes case FTS_NS: 1614b88c807SRodney W. Grimes /* 1624b88c807SRodney W. Grimes * FTS_NS: assume that if can't stat the file, it 1634b88c807SRodney W. Grimes * can't be unlinked. 1644b88c807SRodney W. Grimes */ 1654b88c807SRodney W. Grimes if (!needstat) 1664b88c807SRodney W. Grimes break; 1674b88c807SRodney W. Grimes if (!fflag || p->fts_errno != ENOENT) { 1684b88c807SRodney W. Grimes warnx("%s: %s", 1694b88c807SRodney W. Grimes p->fts_path, strerror(p->fts_errno)); 1704b88c807SRodney W. Grimes eval = 1; 1714b88c807SRodney W. Grimes } 1724b88c807SRodney W. Grimes continue; 1734b88c807SRodney W. Grimes case FTS_D: 1744b88c807SRodney W. Grimes /* Pre-order: give user chance to skip. */ 1754b88c807SRodney W. Grimes if (iflag && !check(p->fts_path, p->fts_accpath, 1764b88c807SRodney W. Grimes p->fts_statp)) { 1774b88c807SRodney W. Grimes (void)fts_set(fts, p, FTS_SKIP); 1784b88c807SRodney W. Grimes p->fts_number = SKIPPED; 1794b88c807SRodney W. Grimes } 1804b88c807SRodney W. Grimes continue; 1814b88c807SRodney W. Grimes case FTS_DP: 1824b88c807SRodney W. Grimes /* Post-order: see if user skipped. */ 1834b88c807SRodney W. Grimes if (p->fts_number == SKIPPED) 1844b88c807SRodney W. Grimes continue; 1854b88c807SRodney W. Grimes break; 1864b88c807SRodney W. Grimes } 1874b88c807SRodney W. Grimes if (!fflag && 1884b88c807SRodney W. Grimes !check(p->fts_path, p->fts_accpath, p->fts_statp)) 1894b88c807SRodney W. Grimes continue; 1904b88c807SRodney W. Grimes 1914b88c807SRodney W. Grimes /* 1924b88c807SRodney W. Grimes * If we can't read or search the directory, may still be 1934b88c807SRodney W. Grimes * able to remove it. Don't print out the un{read,search}able 1944b88c807SRodney W. Grimes * message unless the remove fails. 1954b88c807SRodney W. Grimes */ 1964b88c807SRodney W. Grimes if (p->fts_info == FTS_DP || p->fts_info == FTS_DNR) { 1974b88c807SRodney W. Grimes if (!rmdir(p->fts_accpath)) 1984b88c807SRodney W. Grimes continue; 1994b88c807SRodney W. Grimes if (errno == ENOENT) { 2004b88c807SRodney W. Grimes if (fflag) 2014b88c807SRodney W. Grimes continue; 2024b88c807SRodney W. Grimes } else if (p->fts_info != FTS_DP) 2034b88c807SRodney W. Grimes warnx("%s: unable to read", p->fts_path); 2044b88c807SRodney W. Grimes } else { 2054b88c807SRodney W. Grimes if (Pflag) 2064b88c807SRodney W. Grimes rm_overwrite(p->fts_accpath, NULL); 20767a3d3a8SPoul-Henning Kamp if (!unlink(p->fts_accpath) || (fflag && errno == ENOENT)) 2084b88c807SRodney W. Grimes continue; 2094b88c807SRodney W. Grimes } 2104b88c807SRodney W. Grimes warn("%s", p->fts_path); 2114b88c807SRodney W. Grimes eval = 1; 2124b88c807SRodney W. Grimes } 2134b88c807SRodney W. Grimes if (errno) 2144b88c807SRodney W. Grimes err(1, "fts_read"); 2154b88c807SRodney W. Grimes } 2164b88c807SRodney W. Grimes 2174b88c807SRodney W. Grimes void 2184b88c807SRodney W. Grimes rm_file(argv) 2194b88c807SRodney W. Grimes char **argv; 2204b88c807SRodney W. Grimes { 2214b88c807SRodney W. Grimes struct stat sb; 2224b88c807SRodney W. Grimes int df, rval; 2234b88c807SRodney W. Grimes char *f; 2244b88c807SRodney W. Grimes 2254b88c807SRodney W. Grimes df = dflag; 2264b88c807SRodney W. Grimes /* 2274b88c807SRodney W. Grimes * Remove a file. POSIX 1003.2 states that, by default, attempting 2284b88c807SRodney W. Grimes * to remove a directory is an error, so must always stat the file. 2294b88c807SRodney W. Grimes */ 2304b88c807SRodney W. Grimes while ((f = *argv++) != NULL) { 2314b88c807SRodney W. Grimes /* Assume if can't stat the file, can't unlink it. */ 2324b88c807SRodney W. Grimes if (lstat(f, &sb)) { 2334b88c807SRodney W. Grimes if (!fflag || errno != ENOENT) { 2344b88c807SRodney W. Grimes warn("%s", f); 2354b88c807SRodney W. Grimes eval = 1; 2364b88c807SRodney W. Grimes } 2374b88c807SRodney W. Grimes continue; 2384b88c807SRodney W. Grimes } 2394b88c807SRodney W. Grimes if (S_ISDIR(sb.st_mode) && !df) { 2404b88c807SRodney W. Grimes warnx("%s: is a directory", f); 2414b88c807SRodney W. Grimes eval = 1; 2424b88c807SRodney W. Grimes continue; 2434b88c807SRodney W. Grimes } 2444b88c807SRodney W. Grimes if (!fflag && !check(f, f, &sb)) 2454b88c807SRodney W. Grimes continue; 2464b88c807SRodney W. Grimes if (S_ISDIR(sb.st_mode)) 2474b88c807SRodney W. Grimes rval = rmdir(f); 2484b88c807SRodney W. Grimes else { 2494b88c807SRodney W. Grimes if (Pflag) 2504b88c807SRodney W. Grimes rm_overwrite(f, &sb); 2514b88c807SRodney W. Grimes rval = unlink(f); 2524b88c807SRodney W. Grimes } 2534b88c807SRodney W. Grimes if (rval && (!fflag || errno != ENOENT)) { 2544b88c807SRodney W. Grimes warn("%s", f); 2554b88c807SRodney W. Grimes eval = 1; 2564b88c807SRodney W. Grimes } 2574b88c807SRodney W. Grimes } 2584b88c807SRodney W. Grimes } 2594b88c807SRodney W. Grimes 2604b88c807SRodney W. Grimes /* 2614b88c807SRodney W. Grimes * rm_overwrite -- 2624b88c807SRodney W. Grimes * Overwrite the file 3 times with varying bit patterns. 2634b88c807SRodney W. Grimes * 2644b88c807SRodney W. Grimes * XXX 2654b88c807SRodney W. Grimes * This is a cheap way to *really* delete files. Note that only regular 2664b88c807SRodney W. Grimes * files are deleted, directories (and therefore names) will remain. 2674b88c807SRodney W. Grimes * Also, this assumes a fixed-block file system (like FFS, or a V7 or a 2684b88c807SRodney W. Grimes * System V file system). In a logging file system, you'll have to have 2694b88c807SRodney W. Grimes * kernel support. 2704b88c807SRodney W. Grimes */ 2714b88c807SRodney W. Grimes void 2724b88c807SRodney W. Grimes rm_overwrite(file, sbp) 2734b88c807SRodney W. Grimes char *file; 2744b88c807SRodney W. Grimes struct stat *sbp; 2754b88c807SRodney W. Grimes { 2764b88c807SRodney W. Grimes struct stat sb; 2774b88c807SRodney W. Grimes off_t len; 2784b88c807SRodney W. Grimes int fd, wlen; 2794b88c807SRodney W. Grimes char buf[8 * 1024]; 2804b88c807SRodney W. Grimes 2814b88c807SRodney W. Grimes fd = -1; 2824b88c807SRodney W. Grimes if (sbp == NULL) { 2834b88c807SRodney W. Grimes if (lstat(file, &sb)) 2844b88c807SRodney W. Grimes goto err; 2854b88c807SRodney W. Grimes sbp = &sb; 2864b88c807SRodney W. Grimes } 2874b88c807SRodney W. Grimes if (!S_ISREG(sbp->st_mode)) 2884b88c807SRodney W. Grimes return; 2894b88c807SRodney W. Grimes if ((fd = open(file, O_WRONLY, 0)) == -1) 2904b88c807SRodney W. Grimes goto err; 2914b88c807SRodney W. Grimes 2924b88c807SRodney W. Grimes #define PASS(byte) { \ 2934b88c807SRodney W. Grimes memset(buf, byte, sizeof(buf)); \ 2944b88c807SRodney W. Grimes for (len = sbp->st_size; len > 0; len -= wlen) { \ 2954b88c807SRodney W. Grimes wlen = len < sizeof(buf) ? len : sizeof(buf); \ 2964b88c807SRodney W. Grimes if (write(fd, buf, wlen) != wlen) \ 2974b88c807SRodney W. Grimes goto err; \ 2984b88c807SRodney W. Grimes } \ 2994b88c807SRodney W. Grimes } 3004b88c807SRodney W. Grimes PASS(0xff); 3014b88c807SRodney W. Grimes if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) 3024b88c807SRodney W. Grimes goto err; 3034b88c807SRodney W. Grimes PASS(0x00); 3044b88c807SRodney W. Grimes if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) 3054b88c807SRodney W. Grimes goto err; 3064b88c807SRodney W. Grimes PASS(0xff); 3074b88c807SRodney W. Grimes if (!fsync(fd) && !close(fd)) 3084b88c807SRodney W. Grimes return; 3094b88c807SRodney W. Grimes 3104b88c807SRodney W. Grimes err: eval = 1; 3114b88c807SRodney W. Grimes warn("%s", file); 3124b88c807SRodney W. Grimes } 3134b88c807SRodney W. Grimes 3144b88c807SRodney W. Grimes 3154b88c807SRodney W. Grimes int 3164b88c807SRodney W. Grimes check(path, name, sp) 3174b88c807SRodney W. Grimes char *path, *name; 3184b88c807SRodney W. Grimes struct stat *sp; 3194b88c807SRodney W. Grimes { 3204b88c807SRodney W. Grimes int ch, first; 3214b88c807SRodney W. Grimes char modep[15]; 3224b88c807SRodney W. Grimes 3234b88c807SRodney W. Grimes /* Check -i first. */ 3244b88c807SRodney W. Grimes if (iflag) 3254b88c807SRodney W. Grimes (void)fprintf(stderr, "remove %s? ", path); 3264b88c807SRodney W. Grimes else { 3274b88c807SRodney W. Grimes /* 3284b88c807SRodney W. Grimes * If it's not a symbolic link and it's unwritable and we're 3294b88c807SRodney W. Grimes * talking to a terminal, ask. Symbolic links are excluded 3304b88c807SRodney W. Grimes * because their permissions are meaningless. Check stdin_ok 3314b88c807SRodney W. Grimes * first because we may not have stat'ed the file. 3324b88c807SRodney W. Grimes */ 3334b88c807SRodney W. Grimes if (!stdin_ok || S_ISLNK(sp->st_mode) || !access(name, W_OK)) 3344b88c807SRodney W. Grimes return (1); 3354b88c807SRodney W. Grimes strmode(sp->st_mode, modep); 3364b88c807SRodney W. Grimes (void)fprintf(stderr, "override %s%s%s/%s for %s? ", 3374b88c807SRodney W. Grimes modep + 1, modep[9] == ' ' ? "" : " ", 3384b88c807SRodney W. Grimes user_from_uid(sp->st_uid, 0), 3394b88c807SRodney W. Grimes group_from_gid(sp->st_gid, 0), path); 3404b88c807SRodney W. Grimes } 3414b88c807SRodney W. Grimes (void)fflush(stderr); 3424b88c807SRodney W. Grimes 3434b88c807SRodney W. Grimes first = ch = getchar(); 3444b88c807SRodney W. Grimes while (ch != '\n' && ch != EOF) 3454b88c807SRodney W. Grimes ch = getchar(); 3464b88c807SRodney W. Grimes return (first == 'y'); 3474b88c807SRodney W. Grimes } 3484b88c807SRodney W. Grimes 34967a3d3a8SPoul-Henning Kamp #define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2]))) 3504b88c807SRodney W. Grimes void 3514b88c807SRodney W. Grimes checkdot(argv) 3524b88c807SRodney W. Grimes char **argv; 3534b88c807SRodney W. Grimes { 3544b88c807SRodney W. Grimes char *p, **save, **t; 3554b88c807SRodney W. Grimes int complained; 3564b88c807SRodney W. Grimes 3574b88c807SRodney W. Grimes complained = 0; 3584b88c807SRodney W. Grimes for (t = argv; *t;) { 3594b88c807SRodney W. Grimes if ((p = strrchr(*t, '/')) != NULL) 3604b88c807SRodney W. Grimes ++p; 3614b88c807SRodney W. Grimes else 3624b88c807SRodney W. Grimes p = *t; 3634b88c807SRodney W. Grimes if (ISDOT(p)) { 3644b88c807SRodney W. Grimes if (!complained++) 3654b88c807SRodney W. Grimes warnx("\".\" and \"..\" may not be removed"); 3664b88c807SRodney W. Grimes eval = 1; 3674b88c807SRodney W. Grimes for (save = t; (t[0] = t[1]) != NULL; ++t); 3684b88c807SRodney W. Grimes t = save; 3694b88c807SRodney W. Grimes } else 3704b88c807SRodney W. Grimes ++t; 3714b88c807SRodney W. Grimes } 3724b88c807SRodney W. Grimes } 3734b88c807SRodney W. Grimes 3744b88c807SRodney W. Grimes void 3754b88c807SRodney W. Grimes usage() 3764b88c807SRodney W. Grimes { 3774b88c807SRodney W. Grimes 3784b88c807SRodney W. Grimes (void)fprintf(stderr, "usage: rm [-dfiRr] file ...\n"); 3794b88c807SRodney W. Grimes exit(1); 3804b88c807SRodney W. Grimes } 381