add closefrom() call

Ighighi Ighighi ighighi at
Thu Jul 5 00:56:48 UTC 2007

The closefrom() call, available in Solaris, is present in NetBSD since
version 3.0.
It is implemented with the F_CLOSEM fcntl() available since version 2.0.

These 2 fcntl would be cool to have in FreeBSD:

     F_CLOSEM   Close all file descriptors greater than or equal to fd.

     F_MAXFD    Return the maximum file descriptor number currently open by
                the process.

I know that by using kern.file sysctl I could implement both, but it'd
be nice if the whole
closefrom() is done in kernel space.  Another problem with using
kern.file is that
"struct xfile" may change...

By checking;i=F_MAXFD
I see that it's fairly straightforward to add the F_MAXFD bit.  For
the F_CLOSEM fcntl,
which call is the best to replace the fdrelease() used by NetBSD in
kern/kern_descrip.c ?
Can someone add these to FreeBSD ?

NetBSD's fcntl(2):

NetBSD's & Solaris' closefrom(3):


More information about the freebsd-hackers mailing list