| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_descrip.c,v 1.192 2009/05/24 21:41:26 ad Exp $ */ | | 1 | /* $NetBSD: kern_descrip.c,v 1.193 2009/05/26 00:42:33 ad Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -60,27 +60,27 @@ | | | @@ -60,27 +60,27 @@ |
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
63 | * SUCH DAMAGE. | | 63 | * SUCH DAMAGE. |
64 | * | | 64 | * |
65 | * @(#)kern_descrip.c 8.8 (Berkeley) 2/14/95 | | 65 | * @(#)kern_descrip.c 8.8 (Berkeley) 2/14/95 |
66 | */ | | 66 | */ |
67 | | | 67 | |
68 | /* | | 68 | /* |
69 | * File descriptor management. | | 69 | * File descriptor management. |
70 | */ | | 70 | */ |
71 | | | 71 | |
72 | #include <sys/cdefs.h> | | 72 | #include <sys/cdefs.h> |
73 | __KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.192 2009/05/24 21:41:26 ad Exp $"); | | 73 | __KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.193 2009/05/26 00:42:33 ad Exp $"); |
74 | | | 74 | |
75 | #include <sys/param.h> | | 75 | #include <sys/param.h> |
76 | #include <sys/systm.h> | | 76 | #include <sys/systm.h> |
77 | #include <sys/filedesc.h> | | 77 | #include <sys/filedesc.h> |
78 | #include <sys/kernel.h> | | 78 | #include <sys/kernel.h> |
79 | #include <sys/proc.h> | | 79 | #include <sys/proc.h> |
80 | #include <sys/file.h> | | 80 | #include <sys/file.h> |
81 | #include <sys/socket.h> | | 81 | #include <sys/socket.h> |
82 | #include <sys/socketvar.h> | | 82 | #include <sys/socketvar.h> |
83 | #include <sys/stat.h> | | 83 | #include <sys/stat.h> |
84 | #include <sys/ioctl.h> | | 84 | #include <sys/ioctl.h> |
85 | #include <sys/fcntl.h> | | 85 | #include <sys/fcntl.h> |
86 | #include <sys/pool.h> | | 86 | #include <sys/pool.h> |
| @@ -1400,27 +1400,26 @@ fd_copy(void) | | | @@ -1400,27 +1400,26 @@ fd_copy(void) |
1400 | } | | 1400 | } |
1401 | newfdp->fd_freefile = fdp->fd_freefile; | | 1401 | newfdp->fd_freefile = fdp->fd_freefile; |
1402 | newfdp->fd_exclose = fdp->fd_exclose; | | 1402 | newfdp->fd_exclose = fdp->fd_exclose; |
1403 | | | 1403 | |
1404 | ffp = fdp->fd_dt->dt_ff; | | 1404 | ffp = fdp->fd_dt->dt_ff; |
1405 | nffp = newdt->dt_ff; | | 1405 | nffp = newdt->dt_ff; |
1406 | newlast = -1; | | 1406 | newlast = -1; |
1407 | for (i = 0; i <= (int)lastfile; i++, ffp++, nffp++) { | | 1407 | for (i = 0; i <= (int)lastfile; i++, ffp++, nffp++) { |
1408 | KASSERT(i >= NDFDFILE || | | 1408 | KASSERT(i >= NDFDFILE || |
1409 | *nffp == (fdfile_t *)newfdp->fd_dfdfile[i]); | | 1409 | *nffp == (fdfile_t *)newfdp->fd_dfdfile[i]); |
1410 | ff = *ffp; | | 1410 | ff = *ffp; |
1411 | if (ff == NULL || (fp = ff->ff_file) == NULL) { | | 1411 | if (ff == NULL || (fp = ff->ff_file) == NULL) { |
1412 | /* Descriptor unused, or descriptor half open. */ | | 1412 | /* Descriptor unused, or descriptor half open. */ |
1413 | KASSERT(!fd_isused(fdp, i)); | | | |
1414 | KASSERT(!fd_isused(newfdp, i)); | | 1413 | KASSERT(!fd_isused(newfdp, i)); |
1415 | continue; | | 1414 | continue; |
1416 | } | | 1415 | } |
1417 | if (__predict_false(fp->f_type == DTYPE_KQUEUE)) { | | 1416 | if (__predict_false(fp->f_type == DTYPE_KQUEUE)) { |
1418 | /* kqueue descriptors cannot be copied. */ | | 1417 | /* kqueue descriptors cannot be copied. */ |
1419 | continue; | | 1418 | continue; |
1420 | } | | 1419 | } |
1421 | /* It's active: add a reference to the file. */ | | 1420 | /* It's active: add a reference to the file. */ |
1422 | mutex_enter(&fp->f_lock); | | 1421 | mutex_enter(&fp->f_lock); |
1423 | fp->f_count++; | | 1422 | fp->f_count++; |
1424 | mutex_exit(&fp->f_lock); | | 1423 | mutex_exit(&fp->f_lock); |
1425 | | | 1424 | |
1426 | /* Allocate an fdfile_t to represent it. */ | | 1425 | /* Allocate an fdfile_t to represent it. */ |