rm.c (136112) | rm.c (136113) |
---|---|
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 136112 2004-10-04 11:14:12Z des $"); | 42__FBSDID("$FreeBSD: head/bin/rm/rm.c 136113 2004-10-04 11:26:01Z des $"); |
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> --- 6 unchanged lines hidden (view full) --- 57#include <sysexits.h> 58#include <unistd.h> 59 60int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok; 61uid_t uid; 62 63int check(char *, char *, struct stat *); 64void checkdot(char **); | 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> --- 6 unchanged lines hidden (view full) --- 57#include <sysexits.h> 58#include <unistd.h> 59 60int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok; 61uid_t uid; 62 63int check(char *, char *, struct stat *); 64void checkdot(char **); |
65void checkslash(char **); |
|
65void rm_file(char **); 66int rm_overwrite(char *, struct stat *); 67void rm_tree(char **); 68void usage(void); 69 70/* 71 * rm -- 72 * This rm is different from historic rm's, but is expected to match --- 62 unchanged lines hidden (view full) --- 135 136 if (argc < 1) { 137 if (fflag) 138 return (0); 139 usage(); 140 } 141 142 checkdot(argv); | 66void rm_file(char **); 67int rm_overwrite(char *, struct stat *); 68void rm_tree(char **); 69void usage(void); 70 71/* 72 * rm -- 73 * This rm is different from historic rm's, but is expected to match --- 62 unchanged lines hidden (view full) --- 136 137 if (argc < 1) { 138 if (fflag) 139 return (0); 140 usage(); 141 } 142 143 checkdot(argv); |
144 checkslash(argv); |
|
143 uid = geteuid(); 144 145 if (*argv) { 146 stdin_ok = isatty(STDIN_FILENO); 147 148 if (rflag) 149 rm_tree(argv); 150 else --- 309 unchanged lines hidden (view full) --- 460 (void)fflush(stderr); 461 462 first = ch = getchar(); 463 while (ch != '\n' && ch != EOF) 464 ch = getchar(); 465 return (first == 'y' || first == 'Y'); 466} 467 | 145 uid = geteuid(); 146 147 if (*argv) { 148 stdin_ok = isatty(STDIN_FILENO); 149 150 if (rflag) 151 rm_tree(argv); 152 else --- 309 unchanged lines hidden (view full) --- 462 (void)fflush(stderr); 463 464 first = ch = getchar(); 465 while (ch != '\n' && ch != EOF) 466 ch = getchar(); 467 return (first == 'y' || first == 'Y'); 468} 469 |
470#define ISSLASH(a) ((a)[0] == '/' && (a)[1] == '\0') 471void 472checkslash(char **argv) 473{ 474 char **t, **u; 475 int complained; 476 477 complained = 0; 478 for (t = argv; *t;) { 479 if (ISSLASH(*t)) { 480 if (!complained++) 481 warnx("\"/\" may not be removed"); 482 eval = 1; 483 for (u = t; u[0] != NULL; ++u) 484 u[0] = u[1]; 485 } else { 486 ++t; 487 } 488 } 489} 490 |
|
468#define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2]))) 469void 470checkdot(char **argv) 471{ 472 char *p, **save, **t; 473 int complained; 474 475 complained = 0; --- 26 unchanged lines hidden --- | 491#define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2]))) 492void 493checkdot(char **argv) 494{ 495 char *p, **save, **t; 496 int complained; 497 498 complained = 0; --- 26 unchanged lines hidden --- |