Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/coreutils/mkdir.c

    r821 r1765  
    55 * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
    66 *
    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.
    218 */
    229
     
    3017 */
    3118
    32 #include <stdlib.h>
    33 #include <unistd.h>
     19/* Nov 28, 2006      Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
     20 */
     21
    3422#include <getopt.h> /* struct option */
    35 #include "busybox.h"
     23#include "libbb.h"
     24
     25/* This is a NOFORK applet. Be very careful! */
    3626
    3727#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 };
     28static 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    ;
    4335#endif
    4436
    45 int mkdir_main (int argc, char **argv)
     37int mkdir_main(int argc, char **argv);
     38int mkdir_main(int argc, char **argv)
    4639{
    4740    mode_t mode = (mode_t)(-1);
    4841    int status = EXIT_SUCCESS;
    4942    int flags = 0;
    50     unsigned long opt;
     43    unsigned opt;
    5144    char *smode;
     45#if ENABLE_SELINUX
     46    security_context_t scontext;
     47#endif
    5248
    5349#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
    54     bb_applet_long_options = mkdir_long_options;
     50    applet_long_options = mkdir_longopts;
    5551#endif
    56     opt = bb_getopt_ulflags(argc, argv, "m:p", &smode);
    57     if(opt & 1) {
    58             mode = 0777;
    59         if (!bb_parse_mode (smode, &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);
    6157        }
    6258    }
    63     if(opt & 2)
     59    if (opt & 2)
    6460        flags |= FILEUTILS_RECUR;
     61#if ENABLE_SELINUX
     62    if (opt & 4) {
     63        selinux_or_die();
     64        setfscreatecon_or_die(scontext);
     65    }
     66#endif
    6567
    6668    if (optind == argc) {
Note: See TracChangeset for help on using the changeset viewer.