Code cleanup for nfs4 utilities:
- Mark internal routines as static; - Eliminate unused parameters where possible, mark __unused for others; - Remove unused variables; - Use %jd for int64_t values in printf(); - Add appropriate %d for printf to match its parameter; - Rename a variable to resolve conflict with revoke(2); Reviewed by: rmacklem Tested with: make universe (bugs are mine)
This commit is contained in:
parent
f171eb9b8a
commit
9964058e79
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=193070
@ -73,13 +73,13 @@ int debug = 0;
|
|||||||
|
|
||||||
pid_t children;
|
pid_t children;
|
||||||
|
|
||||||
void nonfs(int);
|
static void nonfs(int);
|
||||||
void reapchild(int);
|
static void reapchild(int);
|
||||||
void usage(void);
|
static void usage(void);
|
||||||
void cleanup(int);
|
static void cleanup(int);
|
||||||
void child_cleanup(int);
|
static void child_cleanup(int);
|
||||||
void nfscbd_exit(int);
|
static void nfscbd_exit(int);
|
||||||
void killchildren(void);
|
static void killchildren(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Nfs callback server daemon.
|
* Nfs callback server daemon.
|
||||||
@ -95,23 +95,18 @@ void killchildren(void);
|
|||||||
* socket from accept, pass the msgsock into the kernel via. nfssvc().
|
* socket from accept, pass the msgsock into the kernel via. nfssvc().
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[], char **envp)
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct group *grp;
|
|
||||||
struct nfscbd_args nfscbdargs;
|
struct nfscbd_args nfscbdargs;
|
||||||
struct nfsd_nfscbd_args nfscbdargs2;
|
struct nfsd_nfscbd_args nfscbdargs2;
|
||||||
struct passwd *pwd;
|
|
||||||
struct ucred *cr;
|
|
||||||
struct sockaddr_in inetaddr, inetpeer;
|
struct sockaddr_in inetaddr, inetpeer;
|
||||||
struct timeval ktv;
|
|
||||||
fd_set ready, sockbits;
|
fd_set ready, sockbits;
|
||||||
int ch, connect_type_cnt, i, len, maxsock, msgsock, error;
|
int ch, connect_type_cnt, len, maxsock, msgsock, error;
|
||||||
int nfssvc_flag, on, sock, tcpsock, ret, mustfreeai = 0;
|
int nfssvc_flag, on, sock, tcpsock, ret, mustfreeai = 0;
|
||||||
char *cp, **cpp, princname[128];
|
char *cp, princname[128];
|
||||||
char myname[MAXHOSTNAMELEN], *myfqdnname = NULL;
|
char myname[MAXHOSTNAMELEN], *myfqdnname = NULL;
|
||||||
struct addrinfo *aip, hints;
|
struct addrinfo *aip, hints;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
sigset_t signew;
|
|
||||||
short myport = NFSV4_CBPORT;
|
short myport = NFSV4_CBPORT;
|
||||||
|
|
||||||
if (modfind("nfscl") < 0) {
|
if (modfind("nfscl") < 0) {
|
||||||
@ -320,24 +315,23 @@ main(int argc, char *argv[], char **envp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
errx(1, "usage: nfscbd %s", USAGE);
|
errx(1, "usage: nfscbd %s", USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
nonfs(int signo)
|
nonfs(int signo __unused)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "missing system call: NFS not available");
|
syslog(LOG_ERR, "missing system call: NFS not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
reapchild(int signo)
|
reapchild(int signo __unused)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int i;
|
|
||||||
|
|
||||||
while ((pid = wait3(NULL, WNOHANG, NULL)) > 0) {
|
while ((pid = wait3(NULL, WNOHANG, NULL)) > 0) {
|
||||||
if (pid == children)
|
if (pid == children)
|
||||||
@ -345,10 +339,9 @@ reapchild(int signo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
killchildren(void)
|
killchildren(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (children > 0)
|
if (children > 0)
|
||||||
kill(children, SIGKILL);
|
kill(children, SIGKILL);
|
||||||
@ -357,8 +350,8 @@ killchildren(void)
|
|||||||
/*
|
/*
|
||||||
* Cleanup master after SIGUSR1.
|
* Cleanup master after SIGUSR1.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
cleanup(int signo)
|
cleanup(int signo __unused)
|
||||||
{
|
{
|
||||||
nfscbd_exit(0);
|
nfscbd_exit(0);
|
||||||
}
|
}
|
||||||
@ -366,14 +359,14 @@ cleanup(int signo)
|
|||||||
/*
|
/*
|
||||||
* Cleanup child after SIGUSR1.
|
* Cleanup child after SIGUSR1.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
child_cleanup(int signo)
|
child_cleanup(int signo __unused)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
nfscbd_exit(int status)
|
nfscbd_exit(int status __unused)
|
||||||
{
|
{
|
||||||
killchildren();
|
killchildren();
|
||||||
exit(status);
|
exit(status);
|
||||||
|
@ -194,7 +194,7 @@ dump_lockstate(char *fname)
|
|||||||
lp[cnt].ndlck_stateid.other[1],
|
lp[cnt].ndlck_stateid.other[1],
|
||||||
lp[cnt].ndlck_stateid.other[2]);
|
lp[cnt].ndlck_stateid.other[2]);
|
||||||
else
|
else
|
||||||
printf("%-11s %17lld %17lld ",
|
printf("%-11s %17jd %17jd ",
|
||||||
lock_flags(lp[cnt].ndlck_flags),
|
lock_flags(lp[cnt].ndlck_flags),
|
||||||
lp[cnt].ndlck_first,
|
lp[cnt].ndlck_first,
|
||||||
lp[cnt].ndlck_end);
|
lp[cnt].ndlck_end);
|
||||||
|
@ -57,8 +57,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void usage(void);
|
static void usage(void);
|
||||||
extern int errno;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@ -66,7 +65,7 @@ main(int argc, char **argv)
|
|||||||
char *cp;
|
char *cp;
|
||||||
u_char val;
|
u_char val;
|
||||||
int cnt, even;
|
int cnt, even;
|
||||||
struct nfsd_clid revoke;
|
struct nfsd_clid revoke_handle;
|
||||||
|
|
||||||
if (modfind("nfsd") < 0)
|
if (modfind("nfsd") < 0)
|
||||||
errx(1, "nfsd not loaded - self terminating");
|
errx(1, "nfsd not loaded - self terminating");
|
||||||
@ -80,7 +79,7 @@ main(int argc, char **argv)
|
|||||||
even = 1;
|
even = 1;
|
||||||
val = 0;
|
val = 0;
|
||||||
while (*cp) {
|
while (*cp) {
|
||||||
if (*cp >= '0' & *cp <= '9')
|
if (*cp >= '0' && *cp <= '9')
|
||||||
val += (u_char)(*cp - '0');
|
val += (u_char)(*cp - '0');
|
||||||
else if (*cp >= 'A' && *cp <= 'F')
|
else if (*cp >= 'A' && *cp <= 'F')
|
||||||
val += ((u_char)(*cp - 'A')) + 0xa;
|
val += ((u_char)(*cp - 'A')) + 0xa;
|
||||||
@ -92,7 +91,7 @@ main(int argc, char **argv)
|
|||||||
val <<= 4;
|
val <<= 4;
|
||||||
even = 0;
|
even = 0;
|
||||||
} else {
|
} else {
|
||||||
revoke.nclid_id[cnt++] = val;
|
revoke_handle.nclid_id[cnt++] = val;
|
||||||
if (cnt > NFSV4_OPAQUELIMIT)
|
if (cnt > NFSV4_OPAQUELIMIT)
|
||||||
errx(1, "Clientid %s, loo long", argv[1]);
|
errx(1, "Clientid %s, loo long", argv[1]);
|
||||||
val = 0;
|
val = 0;
|
||||||
@ -104,19 +103,19 @@ main(int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Do the revocation system call.
|
* Do the revocation system call.
|
||||||
*/
|
*/
|
||||||
revoke.nclid_idlen = cnt;
|
revoke_handle.nclid_idlen = cnt;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Idlen=%d\n", revoke.nclid_idlen);
|
printf("Idlen=%d\n", revoke_handle.nclid_idlen);
|
||||||
for (cnt = 0; cnt < revoke.nclid_idlen; cnt++)
|
for (cnt = 0; cnt < revoke_handle.nclid_idlen; cnt++)
|
||||||
printf("%02x", revoke.nclid_id[cnt]);
|
printf("%02x", revoke_handle.nclid_id[cnt]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#else
|
#else
|
||||||
if (nfssvc(NFSSVC_ADMINREVOKE, &revoke) < 0)
|
if (nfssvc(NFSSVC_ADMINREVOKE, &revoke_handle) < 0)
|
||||||
err(1, "Admin revoke failed");
|
err(1, "Admin revoke failed");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
PROG= nfsuserd
|
PROG= nfsuserd
|
||||||
MAN= nfsuserd.8
|
MAN= nfsuserd.8
|
||||||
|
WARNS?= 3
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -66,12 +66,12 @@ __FBSDID("$FreeBSD$");
|
|||||||
* for NFS V4.
|
* for NFS V4.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cleanup_term(int);
|
static void cleanup_term(int);
|
||||||
void usage(void);
|
static void usage(void);
|
||||||
void nfsuserdsrv(struct svc_req *, SVCXPRT *);
|
static void nfsuserdsrv(struct svc_req *, SVCXPRT *);
|
||||||
bool_t xdr_getid(XDR *, caddr_t);
|
static bool_t xdr_getid(XDR *, caddr_t);
|
||||||
bool_t xdr_getname(XDR *, caddr_t);
|
static bool_t xdr_getname(XDR *, caddr_t);
|
||||||
bool_t xdr_retval(XDR *, caddr_t);
|
static bool_t xdr_retval(XDR *, caddr_t);
|
||||||
|
|
||||||
#define MAXNAME 1024
|
#define MAXNAME 1024
|
||||||
#define MAXNFSUSERD 20
|
#define MAXNFSUSERD 20
|
||||||
@ -94,7 +94,7 @@ int defusertimeout = DEFUSERTIMEOUT;
|
|||||||
pid_t slaves[MAXNFSUSERD];
|
pid_t slaves[MAXNFSUSERD];
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[], char *envp[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int error, len, mustfreeai = 0;
|
int error, len, mustfreeai = 0;
|
||||||
@ -102,11 +102,10 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
struct group *grp;
|
struct group *grp;
|
||||||
int sock, one = 1;
|
int sock, one = 1;
|
||||||
SVCXPRT *udptransp, *tcptransp;
|
SVCXPRT *udptransp;
|
||||||
struct passwd *pw;
|
|
||||||
u_short portnum;
|
u_short portnum;
|
||||||
sigset_t signew;
|
sigset_t signew;
|
||||||
char hostname[MAXHOSTNAMELEN + 1], *cp, **aliases;
|
char hostname[MAXHOSTNAMELEN + 1], *cp;
|
||||||
struct addrinfo *aip, hints;
|
struct addrinfo *aip, hints;
|
||||||
|
|
||||||
if (modfind("nfscommon") < 0) {
|
if (modfind("nfscommon") < 0) {
|
||||||
@ -166,7 +165,7 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
i = atoi(*argv);
|
i = atoi(*argv);
|
||||||
if (i < 10 || i > 100000) {
|
if (i < 10 || i > 100000) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usermax out of range 10<->100000\n", i);
|
"usermax %d out of range 10<->100000\n", i);
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
nid.nid_usermax = i;
|
nid.nid_usermax = i;
|
||||||
@ -178,7 +177,7 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
i = atoi(*argv);
|
i = atoi(*argv);
|
||||||
if (i < 0 || i > 100000) {
|
if (i < 0 || i > 100000) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usertimeout out of range 0<->100000\n",
|
"usertimeout %d out of range 0<->100000\n",
|
||||||
i);
|
i);
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -409,11 +408,9 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
/*
|
/*
|
||||||
* The nfsuserd rpc service
|
* The nfsuserd rpc service
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
|
nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
char *cp;
|
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
struct group *grp;
|
struct group *grp;
|
||||||
int error;
|
int error;
|
||||||
@ -577,7 +574,7 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
|
|||||||
/*
|
/*
|
||||||
* Xdr routine to get an id number
|
* Xdr routine to get an id number
|
||||||
*/
|
*/
|
||||||
bool_t
|
static bool_t
|
||||||
xdr_getid(XDR *xdrsp, caddr_t cp)
|
xdr_getid(XDR *xdrsp, caddr_t cp)
|
||||||
{
|
{
|
||||||
struct info *ifp = (struct info *)cp;
|
struct info *ifp = (struct info *)cp;
|
||||||
@ -588,7 +585,7 @@ xdr_getid(XDR *xdrsp, caddr_t cp)
|
|||||||
/*
|
/*
|
||||||
* Xdr routine to get a user name
|
* Xdr routine to get a user name
|
||||||
*/
|
*/
|
||||||
bool_t
|
static bool_t
|
||||||
xdr_getname(XDR *xdrsp, caddr_t cp)
|
xdr_getname(XDR *xdrsp, caddr_t cp)
|
||||||
{
|
{
|
||||||
struct info *ifp = (struct info *)cp;
|
struct info *ifp = (struct info *)cp;
|
||||||
@ -607,7 +604,7 @@ xdr_getname(XDR *xdrsp, caddr_t cp)
|
|||||||
/*
|
/*
|
||||||
* Xdr routine to return the value.
|
* Xdr routine to return the value.
|
||||||
*/
|
*/
|
||||||
bool_t
|
static bool_t
|
||||||
xdr_retval(XDR *xdrsp, caddr_t cp)
|
xdr_retval(XDR *xdrsp, caddr_t cp)
|
||||||
{
|
{
|
||||||
struct info *ifp = (struct info *)cp;
|
struct info *ifp = (struct info *)cp;
|
||||||
@ -620,8 +617,8 @@ xdr_retval(XDR *xdrsp, caddr_t cp)
|
|||||||
/*
|
/*
|
||||||
* cleanup_term() called via SIGUSR1.
|
* cleanup_term() called via SIGUSR1.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
cleanup_term(int signo)
|
cleanup_term(int signo __unused)
|
||||||
{
|
{
|
||||||
int i, cnt;
|
int i, cnt;
|
||||||
|
|
||||||
@ -656,7 +653,7 @@ cleanup_term(int signo)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user