Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/showmount/showmount.c
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/file.h> | #include <sys/file.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/socketvar.h> | #include <sys/socketvar.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <getopt.h> | |||||
#include <netdb.h> | #include <netdb.h> | ||||
#include <rpc/rpc.h> | #include <rpc/rpc.h> | ||||
#include <rpc/pmap_clnt.h> | #include <rpc/pmap_clnt.h> | ||||
#include <rpc/pmap_prot.h> | #include <rpc/pmap_prot.h> | ||||
#include <rpcsvc/mount.h> | #include <rpcsvc/mount.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
Show All 33 Lines | |||||
void print_dump(struct mountlist *); | void print_dump(struct mountlist *); | ||||
static void usage(void); | static void usage(void); | ||||
int xdr_mntdump(XDR *, struct mountlist **); | int xdr_mntdump(XDR *, struct mountlist **); | ||||
int xdr_exportslist(XDR *, struct exportslist **); | int xdr_exportslist(XDR *, struct exportslist **); | ||||
int tcp_callrpc(const char *host, int prognum, int versnum, int procnum, | int tcp_callrpc(const char *host, int prognum, int versnum, int procnum, | ||||
xdrproc_t inproc, char *in, xdrproc_t outproc, char *out); | xdrproc_t inproc, char *in, xdrproc_t outproc, char *out); | ||||
static const struct option long_opts[] = { | |||||
{ "all", no_argument, NULL, 'a' }, | |||||
{ "directories", no_argument, NULL, 'd' }, | |||||
{ "exports-script", no_argument, NULL, 'E' }, | |||||
{ "exports", no_argument, NULL, 'e' }, | |||||
{ NULL, 0, NULL, 0 }, | |||||
}; | |||||
/* | /* | ||||
* This command queries the NFS mount daemon for it's mount list and/or | * This command queries the NFS mount daemon for it's mount list and/or | ||||
* it's exports list and prints them out. | * it's exports list and prints them out. | ||||
* See "NFS: Network File System Protocol Specification, RFC1094, Appendix A" | * See "NFS: Network File System Protocol Specification, RFC1094, Appendix A" | ||||
* and the "Network File System Protocol XXX.." | * and the "Network File System Protocol XXX.." | ||||
* for detailed information on the protocol. | * for detailed information on the protocol. | ||||
*/ | */ | ||||
int | int | ||||
main(int argc, char **argv) | main(int argc, char **argv) | ||||
{ | { | ||||
char strvised[MNTPATHLEN * 4 + 1]; | char strvised[MNTPATHLEN * 4 + 1]; | ||||
register struct exportslist *exp; | register struct exportslist *exp; | ||||
register struct grouplist *grp; | register struct grouplist *grp; | ||||
register int rpcs = 0, mntvers = 3; | register int rpcs = 0, mntvers = 3; | ||||
const char *host; | const char *host; | ||||
int ch, estat, nbytes; | int ch, estat, nbytes; | ||||
while ((ch = getopt(argc, argv, "adEe13")) != -1) | while ((ch = getopt_long(argc, argv, "+adEe13", long_opts, NULL)) != -1) | ||||
kevans: Generally when converting to long opts, we should use the '+' leading specifier to maintain… | |||||
switch (ch) { | switch (ch) { | ||||
case 'a': | case 'a': | ||||
if (type == 0) { | if (type == 0) { | ||||
type = ALL; | type = ALL; | ||||
rpcs |= DODUMP; | rpcs |= DODUMP; | ||||
} else | } else | ||||
usage(); | usage(); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |
Generally when converting to long opts, we should use the '+' leading specifier to maintain preexisting behavior of getopt(3) of halting at the first non-option argument, unless it's really advantageous and we've documented the behavior change.