Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/coreutils/chown.c

    r1765 r2725  
    55 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
    66 *
    7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
    99
    1010/* BB_AUDIT SUSv3 defects - none? */
    11 /* BB_AUDIT GNU defects - unsupported long options. */
    1211/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
    1312
     
    1716
    1817
    19 #define OPT_STR     ("Rh" USE_DESKTOP("vcfLHP"))
     18#define OPT_STR     ("Rh" IF_DESKTOP("vcfLHP"))
    2019#define BIT_RECURSE 1
    21 #define OPT_RECURSE (option_mask32 & 1)
    22 #define OPT_NODEREF (option_mask32 & 2)
    23 #define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 0x04) SKIP_DESKTOP(0))
    24 #define OPT_CHANGED (USE_DESKTOP(option_mask32 & 0x08) SKIP_DESKTOP(0))
    25 #define OPT_QUIET   (USE_DESKTOP(option_mask32 & 0x10) SKIP_DESKTOP(0))
     20#define OPT_RECURSE (opt & 1)
     21#define OPT_NODEREF (opt & 2)
     22#define OPT_VERBOSE (IF_DESKTOP(opt & 0x04) IF_NOT_DESKTOP(0))
     23#define OPT_CHANGED (IF_DESKTOP(opt & 0x08) IF_NOT_DESKTOP(0))
     24#define OPT_QUIET   (IF_DESKTOP(opt & 0x10) IF_NOT_DESKTOP(0))
    2625/* POSIX options
    2726 * -L traverse every symbolic link to a directory encountered
     
    3332/* -L */
    3433#define BIT_TRAVERSE 0x20
    35 #define OPT_TRAVERSE (USE_DESKTOP(option_mask32 & BIT_TRAVERSE) SKIP_DESKTOP(0))
     34#define OPT_TRAVERSE (IF_DESKTOP(opt & BIT_TRAVERSE) IF_NOT_DESKTOP(0))
    3635/* -H or -L */
    3736#define BIT_TRAVERSE_TOP (0x20|0x40)
    38 #define OPT_TRAVERSE_TOP (USE_DESKTOP(option_mask32 & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0))
     37#define OPT_TRAVERSE_TOP (IF_DESKTOP(opt & BIT_TRAVERSE_TOP) IF_NOT_DESKTOP(0))
     38
     39#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
     40static const char chown_longopts[] ALIGN1 =
     41    "recursive\0"        No_argument   "R"
     42    "dereference\0"      No_argument   "\xff"
     43    "no-dereference\0"   No_argument   "h"
     44# if ENABLE_DESKTOP
     45    "changes\0"          No_argument   "c"
     46    "silent\0"           No_argument   "f"
     47    "quiet\0"            No_argument   "f"
     48    "verbose\0"          No_argument   "v"
     49# endif
     50    ;
     51#endif
    3952
    4053typedef int (*chown_fptr)(const char *, uid_t, gid_t);
    4154
    42 static struct bb_uidgid_t ugid = { -1, -1 };
     55struct param_t {
     56    struct bb_uidgid_t ugid;
     57    chown_fptr chown_func;
     58};
    4359
    44 static int fileAction(const char *fileName, struct stat *statbuf,
    45         void *cf, int depth)
     60static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf,
     61        void *vparam, int depth UNUSED_PARAM)
    4662{
    47     uid_t u = (ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid;
    48     gid_t g = (ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid;
     63#define param  (*(struct param_t*)vparam)
     64#define opt option_mask32
     65    uid_t u = (param.ugid.uid == (uid_t)-1L) ? statbuf->st_uid : param.ugid.uid;
     66    gid_t g = (param.ugid.gid == (gid_t)-1L) ? statbuf->st_gid : param.ugid.gid;
    4967
    50     if (!((chown_fptr)cf)(fileName, u, g)) {
     68    if (param.chown_func(fileName, u, g) == 0) {
    5169        if (OPT_VERBOSE
    5270         || (OPT_CHANGED && (statbuf->st_uid != u || statbuf->st_gid != g))
     
    5876    }
    5977    if (!OPT_QUIET)
    60         bb_perror_msg("%s", fileName);  /* A filename can have % in it... */
     78        bb_simple_perror_msg(fileName);
    6179    return FALSE;
     80#undef opt
     81#undef param
    6282}
    6383
    64 int chown_main(int argc, char **argv);
    65 int chown_main(int argc, char **argv)
     84int chown_main(int argc UNUSED_PARAM, char **argv)
    6685{
    6786    int retval = EXIT_SUCCESS;
    68     int flags;
    69     chown_fptr chown_func;
     87    int opt, flags;
     88    struct param_t param;
    7089
     90    /* Just -1 might not work: uid_t may be unsigned long */
     91    param.ugid.uid = -1L;
     92    param.ugid.gid = -1L;
     93
     94#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
     95    applet_long_options = chown_longopts;
     96#endif
    7197    opt_complementary = "-2";
    72     getopt32(argv, OPT_STR);
     98    opt = getopt32(argv, OPT_STR);
    7399    argv += optind;
    74100
    75101    /* This matches coreutils behavior (almost - see below) */
    76     chown_func = chown;
     102    param.chown_func = chown;
    77103    if (OPT_NODEREF
    78104        /* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
    79         USE_DESKTOP( || (option_mask32 & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
     105        IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
    80106    ) {
    81         chown_func = lchown;
     107        param.chown_func = lchown;
    82108    }
    83109
     
    90116        flags |= ACTION_FOLLOWLINKS; /* follow links if -L */
    91117
    92     parse_chown_usergroup_or_die(&ugid, argv[0]);
     118    parse_chown_usergroup_or_die(&param.ugid, argv[0]);
    93119
    94120    /* Ok, ready to do the deed now */
    95     argv++;
    96     do {
     121    while (*++argv) {
    97122        if (!recursive_action(*argv,
    98123                flags,          /* flags */
    99124                fileAction,     /* file action */
    100125                fileAction,     /* dir action */
    101                 chown_func,     /* user data */
     126                &param,         /* user data */
    102127                0)              /* depth */
    103128        ) {
    104129            retval = EXIT_FAILURE;
    105130        }
    106     } while (*++argv);
     131    }
    107132
    108133    return retval;
Note: See TracChangeset for help on using the changeset viewer.