bin/67317: patch to nfsd.c to make it slightly more dynamic
Michael Conlen
meconlen at obfuscated.net
Fri May 28 19:01:04 PDT 2004
>Number: 67317
>Category: bin
>Synopsis: patch to nfsd.c to make it slightly more dynamic
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Fri May 28 19:00:43 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator: Michael Conlen
>Release: FreeBSD 5.2.1-RELEASE-p8 i386
>Organization:
Obfuscated Networking
>Environment:
System: FreeBSD host 5.2.1-RELEASE-p8 FreeBSD 5.2.1-RELEASE-p8 #0: Thu May 27 04:36:03 EDT 2004 meconlen at obfuscated.net:/usr/obj/usr/src/sys/NFS i386
>Description:
nfsd.c defines a static number of max proceses and creates an
array at that size at compile time so that signal handlers can
access it easily. Problme is, if you need more procs you need
to edit the source and rebuild. I hacked it up so that the
variables are not global and the array is not static so
you can create as many processes as you want.
>How-To-Repeat:
to repeat:
nfsd -n 21
>Fix:
Apply the following patch rebuild and voila nfsd -n <very large number like 512)
7a8,9
> * Modified by Michael Conlen May 28, 2004
> *
75a78,80
>
> #include <stdarg.h>
>
84d88
< #define MAXNFSDCNT 20
86,87d89
< pid_t children[MAXNFSDCNT]; /* PIDs of children */
< int nfsdcnt; /* number of children */
91c93
< void killchildren(void);
---
> void killchildren(int, ...);
94c96
< void reapchild(int);
---
> void reapchild(int, ...);
139a142,143
> pid_t *children;
> int nfsdcnt;
159,163d162
< if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
< warnx("nfsd count %d; reset to %d", nfsdcnt,
< DEFNFSDCNT);
< nfsdcnt = DEFNFSDCNT;
< }
203,207d201
< if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
< warnx("nfsd count %d; reset to %d", nfsdcnt,
< DEFNFSDCNT);
< nfsdcnt = DEFNFSDCNT;
< }
335a330,339
>
> /* allocate children */
> children = calloc(nfsdcnt, sizeof(pid_t));
> if(children == NULL ) {
> syslog(LOG_ERR, "malloc: %m");
> nfsd_exit(1);
> }
> reapchild(0, children, nfsdcnt);
> killchildren(0, children, nfsdcnt);
>
770,771c774
< reapchild(signo)
< int signo;
---
> reapchild(int signo, ...)
775a779,791
> va_list argp;
> pid_t *children;
> int nfsdcnt;
>
> if(signo == 0) {
> va_start(argp, signo);
> children = va_arg(argp, pid_t *);
> nfsdcnt = va_arg(argp, int);
> va_end(argp);
> return;
> }
>
>
791,792c807,809
< void
< killchildren()
---
> /* we need something before the ..., better hack than globals */
>
> void killchildren(int signo, ...)
795a813,826
>
> va_list argp;
> pid_t *children;
> int nfsdcnt;
>
> if(signo == 0) {
> va_start(argp, signo);
> children = va_arg(argp, pid_t *);
> nfsdcnt = va_arg(argp, int);
> va_end(argp);
> return;
> }
>
>
823c854
< killchildren();
---
> killchildren(0);
842a874
>
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list