>Date: Mon, 09 Jul 2007 15:00:21 +0800
>From: LI Xin <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>Subject: Re: add closefrom() call
>To: Robert Watson <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org
<mailto:freebsd-hackers@freebsd.org>>, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>,
Julian Elischer <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>, Ed Schouten <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>Message-ID: <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
>Content-Type: text/plain; charset="iso-8859-1"
LI Xin wrote:
>Nope.
>
>I will try to see if we have some way to expose lastfile to userland, or
>whether we have some better approach to implement this in userland next
>week if I would have some spare time...
F_MAXFD is easy to implement... Attached is a diff that should work for
CURRENT.
I'm working on a 6-STABLE.
See closefrom.c for an implementation based on F_MAXFD.
Still, it doesn't pay to implement it this way...
Calling F_MAXFD everytime we close a file descriptor would be heavy
having too much fd's.
On the other hand, it wouldn't make much a difference to just start from
getdtablesize() - 1.
>Cheers,
>--
>Xin LI <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
http://www.delphij.net/
>FreeBSD - The Power to Serve!
--- src/sys/kern/kern_descrip.c.orig Tue Jul 3 22:27:19 2007
+++ src/sys/kern/kern_descrip.c Mon Jul 9 22:19:35 2007
@@ -623,6 +623,13 @@
vfslocked = 0;
fdrop(fp, td);
break;
+
+ case F_MAXFD:
+ FILEDESC_SLOCK(fdp);
+ td->td_retval[0] = fdp->fd_lastfile;
+ FILEDESC_SUNLOCK(fdp);
+ break;
+
default:
error = EINVAL;
break;
--- src/sys/sys/fcntl.h.orig Wed Apr 7 00:19:49 2004
+++ src/sys/sys/fcntl.h Mon Jul 9 22:26:27 2007
@@ -176,6 +176,9 @@
#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 */
+#if __BSD_VISIBLE
+#define F_MAXFD 11 /* return the max open fd (NetBSD) */
+#endif
/* file descriptor flags (F_GETFD, F_SETFD) */
#define FD_CLOEXEC 1 /* close-on-exec flag */
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"