Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jan 2001 20:49:40 +0100
From:      mouss <usebsd@free.fr>
To:        Matt Dillon <dillon@earth.backplane.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: [kernel patch] fcntl(...) to close many descriptors
Message-ID:  <4.3.0.20010126204903.06d58910@pop.free.fr>
In-Reply-To: <200101261833.f0QIXi434137@earth.backplane.com>
References:  <4.3.0.20010126193228.06e2a200@bluesun>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/fcntl.h>

  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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.3.0.20010126204903.06d58910>