chown: Update program usage and manpage
This commit is contained in:
parent
16719ea6e1
commit
aa6ac30b81
23
chown.1
23
chown.1
@ -1,4 +1,4 @@
|
|||||||
.Dd January 30, 2015
|
.Dd Feburary 17, 2015
|
||||||
.Dt CHOWN 1
|
.Dt CHOWN 1
|
||||||
.Os sbase
|
.Os sbase
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -6,10 +6,11 @@
|
|||||||
.Nd change file ownership
|
.Nd change file ownership
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl Rr
|
.Op Fl h
|
||||||
.Op Fl H
|
.Oo
|
||||||
.Op Fl L
|
.Fl R
|
||||||
.Op Fl P
|
.Op Fl H | L | P
|
||||||
|
.Oc
|
||||||
.Op Ar owner Op Ar :group
|
.Op Ar owner Op Ar :group
|
||||||
.Op Ar file ...
|
.Op Ar file ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
@ -18,9 +19,11 @@ changes the user or group ownership for the given
|
|||||||
.Ar files .
|
.Ar files .
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
|
.It Fl h
|
||||||
|
Change the user ID and/or group ID of the symlink itself. This flag cannot be used
|
||||||
|
with
|
||||||
|
.Op Fl R .
|
||||||
.It Fl R
|
.It Fl R
|
||||||
Equivalent to \-r.
|
|
||||||
.It Fl r
|
|
||||||
Change directory ownership recursively.
|
Change directory ownership recursively.
|
||||||
.It Fl H
|
.It Fl H
|
||||||
Only dereference symbolic links that are passed as command line arguments when
|
Only dereference symbolic links that are passed as command line arguments when
|
||||||
@ -32,3 +35,9 @@ Don't dereference symbolic links (default).
|
|||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr chown 2
|
.Xr chown 2
|
||||||
|
.Sh STANDARDS
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility is compliant with the
|
||||||
|
.St -p1003.1-2008
|
||||||
|
specification.
|
||||||
|
14
chown.c
14
chown.c
@ -9,7 +9,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static int rflag = 0;
|
static int rflag = 0;
|
||||||
static int fflag = 'P';
|
static int HLPflag = 'P';
|
||||||
static uid_t uid = -1;
|
static uid_t uid = -1;
|
||||||
static gid_t gid = -1;
|
static gid_t gid = -1;
|
||||||
static int ret = 0;
|
static int ret = 0;
|
||||||
@ -17,20 +17,20 @@ static char *chown_f_name = "chown";
|
|||||||
static int (*chown_f)(const char *, uid_t, gid_t) = chown;
|
static int (*chown_f)(const char *, uid_t, gid_t) = chown;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chownpwgr(const char *path, int fflag)
|
chownpwgr(const char *path, int HLPflag)
|
||||||
{
|
{
|
||||||
if (chown_f(path, uid, gid) < 0) {
|
if (chown_f(path, uid, gid) < 0) {
|
||||||
weprintf("%s %s:", chown_f_name, path);
|
weprintf("%s %s:", chown_f_name, path);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
if (rflag)
|
if (rflag)
|
||||||
recurse(path, chownpwgr, fflag);
|
recurse(path, chownpwgr, HLPflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-hRr] [owner][:[group]] file...\n", argv0);
|
eprintf("usage: %s [-h] [-R [-H | -L | -P]] [owner][:[group]] file...\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -45,14 +45,14 @@ main(int argc, char *argv[])
|
|||||||
chown_f_name = "lchown";
|
chown_f_name = "lchown";
|
||||||
chown_f = lchown;
|
chown_f = lchown;
|
||||||
break;
|
break;
|
||||||
case 'R':
|
|
||||||
case 'r':
|
case 'r':
|
||||||
|
case 'R':
|
||||||
rflag = 1;
|
rflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'L':
|
case 'L':
|
||||||
case 'P':
|
case 'P':
|
||||||
fflag = ARGC();
|
HLPflag = ARGC();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
@ -94,7 +94,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (; argc > 0; argc--, argv++)
|
for (; argc > 0; argc--, argv++)
|
||||||
chownpwgr(argv[0], fflag);
|
chownpwgr(argv[0], HLPflag);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user