Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (hide annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1400 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 niro 532 /* vi: set sw=4 ts=4: */
2     /*
3     * Mini mkdir 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/mkdir.html */
12    
13     /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
14     *
15     * Fixed broken permission setting when -p was used; especially in
16     * conjunction with -m.
17     */
18    
19     #include <stdlib.h>
20     #include <unistd.h>
21     #include <getopt.h> /* struct option */
22     #include "busybox.h"
23    
24     #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
25     static const struct option mkdir_long_options[] = {
26     { "mode", 1, NULL, 'm' },
27     { "parents", 0, NULL, 'p' },
28     { 0, 0, 0, 0 }
29     };
30     #endif
31    
32     int mkdir_main(int argc, char **argv)
33     {
34     mode_t mode = (mode_t)(-1);
35     int status = EXIT_SUCCESS;
36     int flags = 0;
37     unsigned opt;
38     char *smode;
39    
40     #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
41     applet_long_options = mkdir_long_options;
42     #endif
43     opt = getopt32(argc, argv, "m:p", &smode);
44     if (opt & 1) {
45     mode = 0777;
46     if (!bb_parse_mode(smode, &mode)) {
47     bb_error_msg_and_die("invalid mode '%s'", smode);
48     }
49     }
50     if (opt & 2)
51     flags |= FILEUTILS_RECUR;
52    
53     if (optind == argc) {
54     bb_show_usage();
55     }
56    
57     argv += optind;
58    
59     do {
60     if (bb_make_directory(*argv, mode, flags)) {
61     status = EXIT_FAILURE;
62     }
63     } while (*++argv);
64    
65     return status;
66     }