From owner-freebsd-hackers Fri Jan 26 11:37:51 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp.nettoll.com (matrix.nettoll.net [212.155.143.61]) by hub.freebsd.org (Postfix) with ESMTP id 03B2A37B404 for ; Fri, 26 Jan 2001 11:37:32 -0800 (PST) Received: by smtp.nettoll.com; Fri, 26 Jan 2001 20:36:20 +0100 (MET) Message-Id: <4.3.0.20010126204903.06d58910@pop.free.fr> X-Sender: usebsd@pop.free.fr X-Mailer: QUALCOMM Windows Eudora Version 4.3 Date: Fri, 26 Jan 2001 20:49:40 +0100 To: Matt Dillon From: mouss Subject: Re: [kernel patch] fcntl(...) to close many descriptors Cc: hackers@FreeBSD.ORG In-Reply-To: <200101261833.f0QIXi434137@earth.backplane.com> References: <4.3.0.20010126193228.06e2a200@bluesun> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG At 10:33 26/01/01 -0800, Matt Dillon wrote: > I think it is worth doing. A quick google search shows that > the linux folks discussed the AIX thingy in March 1999, but > I don't think they actually implemented. From the discussion, > it appears that the fcntl would be useful and (not having seen > your patches), almost certainly trivial to implement. you're right. (I can resend it as a tar file...) *** kern_descrip.c Fri Jan 26 19:42:18 2001 --- kern_descrip.c.new Fri Jan 26 20:24:07 2001 *************** *** 364,369 **** --- 364,387 ---- (caddr_t)(intptr_t)uap->arg, sizeof(fl)); } return(error); + + /* close all descriptors starting from a given value */ + case F_CLOSEM: + { + i = uap->fd; + + p->p_retval[0] = 0; + if ((unsigned)i >= fdp->fd_nfiles) { + return (EBADF); + } + for (; i<=fdp->fd_lastfile; i++) { + struct close_args uap; /* XXX. requires _SYS_SYSPROTO_H_ */ + uap.fd = i; + close(p, &uap); + } + return 0; + } + default: return (EINVAL); } The F_CLOSEM is added to fcntl.diff *** fcntl.h Fri Jan 26 20:24:45 2001 --- fcntl.h.new Fri Jan 26 20:25:39 2001 *************** *** 156,161 **** --- 156,162 ---- #define F_GETLK 7 /* get record locking information */ #define F_SETLK 8 /* set record locking information */ #define F_SETLKW 9 /* F_SETLK; wait if blocked */ + #define F_CLOSEM 10 /* close open fd's larger >= arg */ /* file descriptor flags (F_GETFD, F_SETFD) */ #define FD_CLOEXEC 1 /* close-on-exec flag */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message