+ while ((c = getopt_long(argc, argv, "hp:v", longopts, NULL)) != EOF) {
+ switch (c) {
+ case '?':
+ case 'h':
+ usage(argv[0], 0);
+ break;
+ case 'p':
+ port = atoi(optarg);
+ if (port < 1 || port > 65535) {
+ fprintf(stderr, "%s: bad port number: %s\n",
+ argv[0], optarg);
+ usage(argv[0], 1);
+ }
+ break;
+ case 'v':
+ printf("rquotad %s\n", VERSION);
+ exit(0);
+ default:
+ usage(argv[0], 1);
+ }
+ }
+
+ if (chdir(NFS_STATEDIR)) {
+ fprintf(stderr, "%s: chdir(%s) failed: %s\n",
+ argv [0], NFS_STATEDIR, strerror(errno));
+
+ exit(1);
+ }
+
+ /* WARNING: the following works on Linux and SysV, but not BSD! */
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGCHLD, &sa, NULL);
+
+ sa.sa_handler = killer;
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+
+ if (port)
+ transp = svcudp_create(makesock(port, IPPROTO_UDP));
+ else
+ transp = svcudp_create(svcudp_socket (RQUOTAPROG, 1));