Re: New compilation error for 2.0.34 !

Jon Lewis (jlewis@inorganic5.fdt.net)
Thu, 4 Jun 1998 09:35:56 -0400 (EDT)


On Thu, 4 Jun 1998, Alan Cox wrote:

> > Another question : I've to change number of filedescriptor !! I can just
> > change it in /usr/include/gnu/types.h ??? or i've to apply a patch to the
> > kernel ???
>
> There is a 3000 fd kernel patch on www.linuxhq.com. I dont know if its been
> updated to .34 yet but if not it shouldnt need much tweaking

I stuck an old copy of that patch into 2.0.34pre15, and there actually
were some changes necessary. It was non-trivial enough (at least to me)
that I checked with the patch's original author to make sure I'd gotten it
right.

Here's what I'm using.

diff -ruN --exclude *.orig --exclude *.rej --exclude *~ linux-2.0.34pre15-secure/fs/select.c linux-2.0.34pre15-secure-3000/fs/select.c
--- linux-2.0.34pre15-secure/fs/select.c Thu May 21 13:52:38 1998
+++ linux-2.0.34pre15-secure-3000/fs/select.c Thu May 21 14:12:05 1998
@@ -21,6 +21,7 @@
#include <linux/errno.h>
#include <linux/personality.h>
#include <linux/mm.h>
+#include <linux/malloc.h>
#include <linux/file.h>

#include <asm/segment.h>
@@ -308,23 +309,54 @@
* Update: ERESTARTSYS breaks at least the xview clock binary, so
* I'm trying ERESTARTNOHAND which restart only when you want to.
*/
+
+#define roundbit(n, type) (((n) + sizeof(type)*8 - 1) & ~(sizeof(type)*8-1))
+
+static unsigned long * save_fds[100] = {NULL, };
+static int fds_index = 0;
+
asmlinkage int sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp)
{
+ unsigned long * fds = 0;
int error;
- limited_fd_set res_in, in;
- limited_fd_set res_out, out;
- limited_fd_set res_ex, ex;
- limited_fd_set locked;
+ limited_fd_set *res_in, *in;
+ limited_fd_set *res_out, *out;
+ limited_fd_set *res_ex, *ex;
+ limited_fd_set *locked;
unsigned long timeout;
-
+ int size;
+
error = -EINVAL;
if (n < 0)
goto out;
if (n > NR_OPEN)
n = NR_OPEN;
- if ((error = get_fd_set(n, inp, &in)) ||
- (error = get_fd_set(n, outp, &out)) ||
- (error = get_fd_set(n, exp, &ex))) goto out;
+
+ size = roundbit(NR_OPEN, unsigned long) / 8;
+ if (save_fds[fds_index]) {
+ fds = save_fds[fds_index];
+ save_fds[fds_index] = NULL;
+ if (fds_index > 0)
+ --fds_index;
+ } else {
+ fds = kmalloc(7 * size, GFP_KERNEL);
+ printk("select kmalloc\n");
+ }
+ if (!fds) {
+ error = -ENOMEM;
+ goto out;
+ }
+ in = (limited_fd_set *) fds;
+ out = (limited_fd_set *) (((char*)fds) + size);
+ ex = (limited_fd_set *) (((char*)fds) + size*2);
+ res_in = (limited_fd_set *) (((char*)fds) + size*3);
+ res_out = (limited_fd_set *) (((char*)fds) + size*4);
+ res_ex = (limited_fd_set *) (((char*)fds) + size*5);
+ locked = (limited_fd_set *) (((char*)fds) + size*6);
+
+ if ((error = get_fd_set(n, inp, in)) ||
+ (error = get_fd_set(n, outp, out)) ||
+ (error = get_fd_set(n, exp, ex))) goto out;
timeout = ~0UL;
if (tvp) {
error = verify_area(VERIFY_WRITE, tvp, sizeof(*tvp));
@@ -335,18 +367,18 @@
if (timeout)
timeout += jiffies + 1;
}
- zero_fd_set(n, &res_in);
- zero_fd_set(n, &res_out);
- zero_fd_set(n, &res_ex);
+ zero_fd_set(n, res_in);
+ zero_fd_set(n, res_out);
+ zero_fd_set(n, res_ex);
current->timeout = timeout;
error = do_select(n,
- (fd_set *) &in,
- (fd_set *) &out,
- (fd_set *) &ex,
- (fd_set *) &res_in,
- (fd_set *) &res_out,
- (fd_set *) &res_ex,
- (fd_set *) &locked);
+ (fd_set *) in,
+ (fd_set *) out,
+ (fd_set *) ex,
+ (fd_set *) res_in,
+ (fd_set *) res_out,
+ (fd_set *) res_ex,
+ (fd_set *) locked);
timeout = current->timeout - jiffies - 1;
current->timeout = 0;
if ((long) timeout < 0)
@@ -365,9 +397,19 @@
goto out;
error = 0;
}
- set_fd_set(n, inp, &res_in);
- set_fd_set(n, outp, &res_out);
- set_fd_set(n, exp, &res_ex);
+ set_fd_set(n, inp, res_in);
+ set_fd_set(n, outp, res_out);
+ set_fd_set(n, exp, res_ex);
out:
+ if (fds) {
+ if (fds_index < 95) {
+ if (save_fds[fds_index])
+ ++fds_index;
+ save_fds[fds_index] = fds;
+ } else {
+ kfree(fds);
+ printk("select kfree\n");
+ }
+ }
return error;
}
diff -ruN --exclude *.orig --exclude *.rej --exclude *~ linux-2.0.34pre15-secure/include/linux/fs.h linux-2.0.34pre15-secure-3000/include/linux/fs.h
--- linux-2.0.34pre15-secure/include/linux/fs.h Thu May 21 13:52:40 1998
+++ linux-2.0.34pre15-secure-3000/include/linux/fs.h Thu May 21 13:30:22 1998
@@ -27,7 +27,7 @@

/* Fixed constants first: */
#undef NR_OPEN
-#define NR_OPEN 256
+#define NR_OPEN 3000

#define NR_SUPER 64
#define BLOCK_SIZE 1024
diff -ruN --exclude *.orig --exclude *.rej --exclude *~ linux-2.0.34pre15-secure/include/linux/limits.h linux-2.0.34pre15-secure-3000/include/linux/limits.h
--- linux-2.0.34pre15-secure/include/linux/limits.h Wed Jul 17 08:10:03 1996
+++ linux-2.0.34pre15-secure-3000/include/linux/limits.h Thu May 21 13:30:22 1998
@@ -1,7 +1,7 @@
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H

-#define NR_OPEN 256
+#define NR_OPEN 3000

#define NGROUPS_MAX 32 /* supplemental group IDs are available */
#define ARG_MAX 131072 /* # bytes of args + environ for exec() */
diff -ruN --exclude *.orig --exclude *.rej --exclude *~ linux-2.0.34pre15-secure/include/linux/posix_types.h linux-2.0.34pre15-secure-3000/include/linux/posix_types.h
--- linux-2.0.34pre15-secure/include/linux/posix_types.h Sat Oct 25 09:35:58 1997
+++ linux-2.0.34pre15-secure-3000/include/linux/posix_types.h Thu May 21 13:30:22 1998
@@ -30,7 +30,7 @@
#define __NFDBITS (8 * sizeof(unsigned long))

#undef __FD_SETSIZE
-#define __FD_SETSIZE 1024
+#define __FD_SETSIZE 4096

#undef __FDSET_LONGS
#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)

------------------------------------------------------------------
Jon Lewis <jlewis@fdt.net> | Spammers will be winnuked or
Network Administrator | drawn and quartered...whichever
Florida Digital Turnpike | is more convenient.
______http://inorganic5.fdt.net/~jlewis/pgp for PGP public key____

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu