Magellan Linux

Annotation of /trunk/mkinitrd-magellan/busybox/coreutils/rm.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 816 - (hide annotations) (download)
Fri Apr 24 18:33:46 2009 UTC (15 years, 1 month ago) by niro
File MIME type: text/plain
File size: 1211 byte(s)
-updated to busybox-1.13.4
1 niro 532 /* vi: set sw=4 ts=4: */
2     /*
3     * Mini rm implementation for busybox
4     *
5     * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
6     *
7     * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8     */
9    
10     /* BB_AUDIT SUSv3 compliant */
11     /* http://www.opengroup.org/onlinepubs/007904975/utilities/rm.html */
12    
13     /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
14     *
15     * Size reduction.
16     */
17    
18 niro 816 #include "libbb.h"
19 niro 532
20 niro 816 /* This is a NOFORK applet. Be very careful! */
21    
22     int rm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
23     int rm_main(int argc UNUSED_PARAM, char **argv)
24 niro 532 {
25     int status = 0;
26     int flags = 0;
27     unsigned opt;
28    
29     opt_complementary = "f-i:i-f";
30 niro 816 opt = getopt32(argv, "fiRr");
31     argv += optind;
32     if (opt & 1)
33     flags |= FILEUTILS_FORCE;
34     if (opt & 2)
35 niro 532 flags |= FILEUTILS_INTERACTIVE;
36 niro 816 if (opt & 12)
37 niro 532 flags |= FILEUTILS_RECUR;
38    
39 niro 816 if (*argv != NULL) {
40 niro 532 do {
41 niro 816 const char *base = bb_get_last_path_component_strip(*argv);
42 niro 532
43 niro 816 if (DOT_OR_DOTDOT(base)) {
44 niro 532 bb_error_msg("cannot remove '.' or '..'");
45     } else if (remove_file(*argv, flags) >= 0) {
46     continue;
47     }
48     status = 1;
49     } while (*++argv);
50     } else if (!(flags & FILEUTILS_FORCE)) {
51     bb_show_usage();
52     }
53    
54     return status;
55     }