summaryrefslogtreecommitdiff
path: root/src/chown.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-10-16 07:56:02 +0000
committerJim Meyering <jim@meyering.net>2003-10-16 07:56:02 +0000
commit9a35ea11d44a6427dbf568e33e209eddb7da4b8b (patch)
tree312ebaa9a1c04708ace29676f16dec7e36f9d76d /src/chown.c
parent029d5937c4b730f2380a729bf9abd67b41861906 (diff)
downloadcoreutils-9a35ea11d44a6427dbf568e33e209eddb7da4b8b.tar.xz
(main): Simply assign to bit_flags.
Don't bother with bit arithmetic. Rename a couple of local variables. Remove unnecessary casts.
Diffstat (limited to 'src/chown.c')
-rw-r--r--src/chown.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/chown.c b/src/chown.c
index debd020f4..3ebff168b 100644
--- a/src/chown.c
+++ b/src/chown.c
@@ -148,12 +148,17 @@ as symbolic.\n\
int
main (int argc, char **argv)
{
- uid_t uid = (uid_t) -1; /* New uid; -1 if not to be changed. */
- gid_t gid = (uid_t) -1; /* New gid; -1 if not to be changed. */
- uid_t old_uid = (uid_t) -1; /* Old uid; -1 if unrestricted. */
- gid_t old_gid = (uid_t) -1; /* Old gid; -1 if unrestricted. */
+ uid_t uid = -1; /* Specified uid; -1 if not to be changed. */
+ gid_t gid = -1; /* Specified gid; -1 if not to be changed. */
+
+ /* Change the owner (group) of a file only if it has this uid (gid).
+ -1 means there's no restriction. */
+ uid_t required_uid = -1;
+ gid_t required_gid = -1;
+
/* Bit flags that control how fts works. */
int bit_flags = FTS_PHYSICAL;
+
struct Chown_option chopt;
int fail = 0;
int optc;
@@ -177,18 +182,15 @@ main (int argc, char **argv)
break;
case 'H': /* Traverse command-line symlinks-to-directories. */
- bit_flags |= FTS_COMFOLLOW;
+ bit_flags = FTS_COMFOLLOW;
break;
case 'L': /* Traverse all symlinks-to-directories. */
- bit_flags &= ~FTS_PHYSICAL;
- bit_flags |= FTS_LOGICAL;
+ bit_flags = FTS_LOGICAL;
break;
case 'P': /* Traverse no symlinks-to-directories. */
- bit_flags |= FTS_PHYSICAL;
- bit_flags &= ~FTS_LOGICAL;
- bit_flags &= ~FTS_COMFOLLOW;
+ bit_flags = FTS_PHYSICAL;
break;
case 'h': /* --no-dereference: affect symlinks */
@@ -208,7 +210,7 @@ main (int argc, char **argv)
{
char *u_dummy, *g_dummy;
const char *e = parse_user_spec (optarg,
- &old_uid, &old_gid,
+ &required_uid, &required_gid,
&u_dummy, &g_dummy);
if (e)
error (EXIT_FAILURE, 0, "%s: %s", quote (optarg), e);
@@ -272,7 +274,7 @@ main (int argc, char **argv)
fail = chown_files (argv + optind, bit_flags,
uid, gid,
- old_uid, old_gid, &chopt);
+ required_uid, required_gid, &chopt);
chopt_free (&chopt);