Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 16  Line 16 
16   * conjunction with -m.   * conjunction with -m.
17   */   */
18    
19  #include <stdlib.h>  /* Nov 28, 2006      Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
20  #include <unistd.h>   */
21  #include <getopt.h> /* struct option */  
22  #include "busybox.h"  #include "libbb.h"
23    
24    /* This is a NOFORK applet. Be very careful! */
25    
26  #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS  #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
27  static const struct option mkdir_long_options[] = {  static const char mkdir_longopts[] ALIGN1 =
28   { "mode", 1, NULL, 'm' },   "mode\0"    Required_argument "m"
29   { "parents", 0, NULL, 'p' },   "parents\0" No_argument       "p"
30   { 0, 0, 0, 0 }  #if ENABLE_SELINUX
31  };   "context\0" Required_argument "Z"
32    #endif
33     ;
34  #endif  #endif
35    
36    int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
37  int mkdir_main(int argc, char **argv)  int mkdir_main(int argc, char **argv)
38  {  {
39   mode_t mode = (mode_t)(-1);   mode_t mode = (mode_t)(-1);
# Line 36  int mkdir_main(int argc, char **argv) Line 41  int mkdir_main(int argc, char **argv)
41   int flags = 0;   int flags = 0;
42   unsigned opt;   unsigned opt;
43   char *smode;   char *smode;
44    #if ENABLE_SELINUX
45     security_context_t scontext;
46    #endif
47    
48  #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS  #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
49   applet_long_options = mkdir_long_options;   applet_long_options = mkdir_longopts;
50  #endif  #endif
51   opt = getopt32(argc, argv, "m:p", &smode);   opt = getopt32(argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
52   if (opt & 1) {   if (opt & 1) {
53   mode = 0777;   mode = 0777;
54   if (!bb_parse_mode(smode, &mode)) {   if (!bb_parse_mode(smode, &mode)) {
# Line 49  int mkdir_main(int argc, char **argv) Line 57  int mkdir_main(int argc, char **argv)
57   }   }
58   if (opt & 2)   if (opt & 2)
59   flags |= FILEUTILS_RECUR;   flags |= FILEUTILS_RECUR;
60    #if ENABLE_SELINUX
61     if (opt & 4) {
62     selinux_or_die();
63     setfscreatecon_or_die(scontext);
64     }
65    #endif
66    
67   if (optind == argc) {   if (optind == argc) {
68   bb_show_usage();   bb_show_usage();

Legend:
Removed from v.532  
changed lines
  Added in v.816