Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/coreutils/mkdir.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/coreutils/mkdir.c
r821 r1770 5 5 * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu> 6 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 21 8 */ 22 9 … … 30 17 */ 31 18 32 #include <stdlib.h> 33 #include <unistd.h> 19 /* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support. 20 */ 21 34 22 #include <getopt.h> /* struct option */ 35 #include "busybox.h" 23 #include "libbb.h" 24 25 /* This is a NOFORK applet. Be very careful! */ 36 26 37 27 #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS 38 static const struct option mkdir_long_options[] = { 39 { "mode", 1, NULL, 'm' }, 40 { "parents", 0, NULL, 'p' }, 41 { 0, 0, 0, 0 } 42 }; 28 static const char mkdir_longopts[] ALIGN1 = 29 "mode\0" Required_argument "m" 30 "parents\0" No_argument "p" 31 #if ENABLE_SELINUX 32 "context\0" Required_argument "Z" 33 #endif 34 ; 43 35 #endif 44 36 45 int mkdir_main (int argc, char **argv) 37 int mkdir_main(int argc, char **argv); 38 int mkdir_main(int argc, char **argv) 46 39 { 47 40 mode_t mode = (mode_t)(-1); 48 41 int status = EXIT_SUCCESS; 49 42 int flags = 0; 50 unsigned longopt;43 unsigned opt; 51 44 char *smode; 45 #if ENABLE_SELINUX 46 security_context_t scontext; 47 #endif 52 48 53 49 #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS 54 bb_applet_long_options = mkdir_long_options;50 applet_long_options = mkdir_longopts; 55 51 #endif 56 opt = bb_getopt_ulflags(argc, argv, "m:p", &smode);57 if (opt & 1) {58 59 if (!bb_parse_mode 60 bb_error_msg_and_die ("invalid mode `%s'", smode);52 opt = getopt32(argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext)); 53 if (opt & 1) { 54 mode = 0777; 55 if (!bb_parse_mode(smode, &mode)) { 56 bb_error_msg_and_die("invalid mode '%s'", smode); 61 57 } 62 58 } 63 if (opt & 2)59 if (opt & 2) 64 60 flags |= FILEUTILS_RECUR; 61 #if ENABLE_SELINUX 62 if (opt & 4) { 63 selinux_or_die(); 64 setfscreatecon_or_die(scontext); 65 } 66 #endif 65 67 66 68 if (optind == argc) {
Note:
See TracChangeset
for help on using the changeset viewer.