patch-2.2.12 linux/fs/select.c
Next file: linux/include/asm-alpha/core_cia.h
Previous file: linux/fs/proc/array.c
Back to the patch index
Back to the overall index
- Lines: 63
- Date:
Wed Aug 25 17:29:49 1999
- Orig file:
v2.2.11/linux/fs/select.c
- Orig date:
Sun May 23 23:54:52 1999
diff -u --recursive --new-file v2.2.11/linux/fs/select.c linux/fs/select.c
@@ -107,7 +107,7 @@
/* handle last in-complete long-word first */
set = ~(~0UL << (n & (__NFDBITS-1)));
n /= __NFDBITS;
- open_fds = current->files->open_fds.fds_bits+n;
+ open_fds = current->files->open_fds->fds_bits+n;
max = 0;
if (set) {
set &= BITS(fds, n);
@@ -264,21 +264,31 @@
if ((unsigned long) sec < MAX_SELECT_SECONDS) {
timeout = ROUND_UP(usec, 1000000/HZ);
timeout += sec * (unsigned long) HZ;
+
+ if (timeout < 0) {
+ ret = -EINVAL;
+ goto out_nofds;
+ }
}
}
ret = -EINVAL;
+
+ /*
+ * We ought to optimise the n=0 case - it is used enough..
+ */
+
if (n < 0)
goto out_nofds;
-
- if (n > KFDS_NR)
- n = KFDS_NR;
-
+ if (n > current->files->max_fdset)
+ n = current->files->max_fdset;
+
/*
* We need 6 bitmaps (in/out/ex for both incoming and outgoing),
* since we used fdset we need to allocate memory in units of
- * long-words.
+ * long-words.
*/
+
ret = -ENOMEM;
size = FDS_BYTES(n);
bits = kmalloc(6 * size, GFP_KERNEL);
@@ -383,13 +393,13 @@
lock_kernel();
/* Do a sanity check on nfds ... */
err = -EINVAL;
- if (nfds > NR_OPEN)
+ if (nfds > current->files->max_fds)
goto out;
if (timeout) {
- /* Carefula about overflow in the intermediate values */
+ /* Careful about overflow in the intermediate values */
if ((unsigned long) timeout < MAX_SCHEDULE_TIMEOUT / HZ)
- timeout = (unsigned long)(timeout*HZ+999)/1000+1;
+ timeout = (timeout*HZ+999)/1000+1;
else /* Negative or overflow */
timeout = MAX_SCHEDULE_TIMEOUT;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)