Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jul 2007 20:27:49 -0400
From:      "Ighighi Ighighi" <ighighi@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   add closefrom() call
Message-ID:  <de5dfb5a0707041727j3e3518f9l5a019717a9f90aa@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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
http://fxr.watson.org/fxr/ident?v=NETBSD4;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):
http://www.freebsd.org/cgi/man.cgi?query=fcntl&apropos=0&sektion=0&manpath=NetBSD+3.0&format=html

NetBSD's & Solaris' closefrom(3):
http://www.freebsd.org/cgi/man.cgi?query=closefrom&apropos=0&sektion=0&manpath=NetBSD+3.0&format=html
http://www.freebsd.org/cgi/man.cgi?query=closefrom&apropos=0&sektion=0&manpath=SunOS+5.9&format=html

Cheers,
Igh.



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