Contents of /trunk/mkinitrd-magellan/busybox/coreutils/rm.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 1150 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 1150 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* 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 | #include <unistd.h> |
19 | #include "busybox.h" |
20 | |
21 | int rm_main(int argc, char **argv) |
22 | { |
23 | int status = 0; |
24 | int flags = 0; |
25 | unsigned opt; |
26 | |
27 | opt_complementary = "f-i:i-f"; |
28 | opt = getopt32(argc, argv, "fiRr"); |
29 | if(opt & 1) |
30 | flags |= FILEUTILS_FORCE; |
31 | if(opt & 2) |
32 | flags |= FILEUTILS_INTERACTIVE; |
33 | if(opt & 12) |
34 | flags |= FILEUTILS_RECUR; |
35 | |
36 | if (*(argv += optind) != NULL) { |
37 | do { |
38 | const char *base = bb_get_last_path_component(*argv); |
39 | |
40 | if ((base[0] == '.') && (!base[1] || ((base[1] == '.') && !base[2]))) { |
41 | bb_error_msg("cannot remove '.' or '..'"); |
42 | } else if (remove_file(*argv, flags) >= 0) { |
43 | continue; |
44 | } |
45 | status = 1; |
46 | } while (*++argv); |
47 | } else if (!(flags & FILEUTILS_FORCE)) { |
48 | bb_show_usage(); |
49 | } |
50 | |
51 | return status; |
52 | } |