~mmach/netext73/busybox

« back to all changes in this revision

Viewing changes to coreutils/chown.c

  • Committer: mmach
  • Date: 2022-08-22 15:28:31 UTC
  • Revision ID: netbit73@gmail.com-20220822152831-vrsxgw6c75b03ujx
1.35.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
//usage:#define chown_trivial_usage
29
29
//usage:       "[-Rh"IF_DESKTOP("LHPcvf")"]... USER[:[GRP]] FILE..."
30
30
//usage:#define chown_full_usage "\n\n"
31
 
//usage:       "Change the owner and/or group of each FILE to USER and/or GRP\n"
32
 
//usage:     "\n        -R      Recurse"
 
31
//usage:       "Change the owner and/or group of FILEs to USER and/or GRP"
 
32
//usage:     "\n"
33
33
//usage:     "\n        -h      Affect symlinks instead of symlink targets"
34
34
//usage:        IF_DESKTOP(
35
35
//usage:     "\n        -L      Traverse all symlinks to directories"
36
36
//usage:     "\n        -H      Traverse symlinks on command line only"
37
37
//usage:     "\n        -P      Don't traverse symlinks (default)"
 
38
//usage:        )
 
39
//next 4 options are the same for chmod/chown/chgrp:
 
40
//usage:     "\n        -R      Recurse"
 
41
//usage:        IF_DESKTOP(
38
42
//usage:     "\n        -c      List changed files"
39
 
//usage:     "\n        -v      List all files"
 
43
//usage:     "\n        -v      Verbose"
40
44
//usage:     "\n        -f      Hide errors"
41
45
//usage:        )
42
46
//usage:
97
101
        chown_fptr chown_func;
98
102
};
99
103
 
100
 
static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf,
101
 
                void *vparam, int depth UNUSED_PARAM)
 
104
static int FAST_FUNC fileAction(struct recursive_state *state UNUSED_PARAM,
 
105
                const char *fileName, struct stat *statbuf)
102
106
{
103
 
#define param  (*(struct param_t*)vparam)
 
107
#define param  (*(struct param_t*)state->userData)
104
108
#define opt option_mask32
105
109
        uid_t u = (param.ugid.uid == (uid_t)-1L) ? statbuf->st_uid : param.ugid.uid;
106
110
        gid_t g = (param.ugid.gid == (gid_t)-1L) ? statbuf->st_gid : param.ugid.gid;
159
163
                                flags,          /* flags */
160
164
                                fileAction,     /* file action */
161
165
                                fileAction,     /* dir action */
162
 
                                &param,         /* user data */
163
 
                                0)              /* depth */
 
166
                                &param)         /* user data */
164
167
                ) {
165
168
                        retval = EXIT_FAILURE;
166
169
                }