summaryrefslogtreecommitdiff
path: root/chmod_chown_chgrp.c
diff options
context:
space:
mode:
Diffstat (limited to 'chmod_chown_chgrp.c')
-rw-r--r--chmod_chown_chgrp.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c
index 5c2adab..f3d8ce2 100644
--- a/chmod_chown_chgrp.c
+++ b/chmod_chown_chgrp.c
@@ -49,20 +49,17 @@ static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n"
-static int fileAction(const char *fileName)
+static int fileAction(const char *fileName, struct stat* statbuf)
{
- struct stat statBuf;
- if (stat(fileName, &statBuf) < 0) {
- switch (whichApp) {
- case CHGRP_APP:
- case CHOWN_APP:
- if (chown(fileName, ((whichApp==CHOWN_APP)? uid: statBuf.st_uid), gid) < 0)
- return( TRUE);
- case CHMOD_APP:
- fprintf(stderr, "%s, %d\n", fileName, mode);
- if (chmod(fileName, mode))
- return( TRUE);
- }
+ switch (whichApp) {
+ case CHGRP_APP:
+ case CHOWN_APP:
+ if (chown(fileName, ((whichApp==CHOWN_APP)? uid: statbuf->st_uid), gid) < 0)
+ return( TRUE);
+ case CHMOD_APP:
+ fprintf(stderr, "%s, %d\n", fileName, mode);
+ if (chmod(fileName, mode))
+ return( TRUE);
}
perror(fileName);
return( FALSE);