kern_descrip.c (109526) | kern_descrip.c (109623) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 |
39 * $FreeBSD: head/sys/kern/kern_descrip.c 109526 2003-01-19 11:03:07Z phk $ | 39 * $FreeBSD: head/sys/kern/kern_descrip.c 109623 2003-01-21 08:56:16Z alfred $ |
40 */ 41 42#include "opt_compat.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/syscallsubr.h> 47#include <sys/sysproto.h> --- 614 unchanged lines hidden (view full) --- 662 if (pgid == 0) { 663 funsetown(sigiop); 664 return (0); 665 } 666 667 ret = 0; 668 669 /* Allocate and fill in the new sigio out of locks. */ | 40 */ 41 42#include "opt_compat.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/syscallsubr.h> 47#include <sys/sysproto.h> --- 614 unchanged lines hidden (view full) --- 662 if (pgid == 0) { 663 funsetown(sigiop); 664 return (0); 665 } 666 667 ret = 0; 668 669 /* Allocate and fill in the new sigio out of locks. */ |
670 MALLOC(sigio, struct sigio *, sizeof(struct sigio), M_SIGIO, M_WAITOK); | 670 MALLOC(sigio, struct sigio *, sizeof(struct sigio), M_SIGIO, 0); |
671 sigio->sio_pgid = pgid; 672 sigio->sio_ucred = crhold(curthread->td_ucred); 673 sigio->sio_myref = sigiop; 674 675 sx_slock(&proctree_lock); 676 if (pgid > 0) { 677 proc = pfind(pgid); 678 if (proc == NULL) { --- 368 unchanged lines hidden (view full) --- 1047 while (nfiles < want) 1048 nfiles <<= 1; 1049 FILEDESC_UNLOCK(fdp); 1050 /* 1051 * XXX malloc() calls uma_large_malloc() for sizes larger 1052 * than KMEM_ZMAX bytes. uma_large_malloc() requires Giant. 1053 */ 1054 mtx_lock(&Giant); | 671 sigio->sio_pgid = pgid; 672 sigio->sio_ucred = crhold(curthread->td_ucred); 673 sigio->sio_myref = sigiop; 674 675 sx_slock(&proctree_lock); 676 if (pgid > 0) { 677 proc = pfind(pgid); 678 if (proc == NULL) { --- 368 unchanged lines hidden (view full) --- 1047 while (nfiles < want) 1048 nfiles <<= 1; 1049 FILEDESC_UNLOCK(fdp); 1050 /* 1051 * XXX malloc() calls uma_large_malloc() for sizes larger 1052 * than KMEM_ZMAX bytes. uma_large_malloc() requires Giant. 1053 */ 1054 mtx_lock(&Giant); |
1055 newofile = malloc(nfiles * OFILESIZE, M_FILEDESC, M_WAITOK); | 1055 newofile = malloc(nfiles * OFILESIZE, M_FILEDESC, 0); |
1056 mtx_unlock(&Giant); 1057 1058 /* 1059 * Deal with file-table extend race that might have 1060 * occurred while filedesc was unlocked. 1061 */ 1062 FILEDESC_LOCK(fdp); 1063 if (fdp->fd_nfiles >= nfiles) { --- 74 unchanged lines hidden (view full) --- 1138 struct thread *td; 1139 struct file **resultfp; 1140 int *resultfd; 1141{ 1142 struct proc *p = td->td_proc; 1143 struct file *fp, *fq; 1144 int error, i; 1145 | 1056 mtx_unlock(&Giant); 1057 1058 /* 1059 * Deal with file-table extend race that might have 1060 * occurred while filedesc was unlocked. 1061 */ 1062 FILEDESC_LOCK(fdp); 1063 if (fdp->fd_nfiles >= nfiles) { --- 74 unchanged lines hidden (view full) --- 1138 struct thread *td; 1139 struct file **resultfp; 1140 int *resultfd; 1141{ 1142 struct proc *p = td->td_proc; 1143 struct file *fp, *fq; 1144 int error, i; 1145 |
1146 fp = uma_zalloc(file_zone, M_WAITOK | M_ZERO); | 1146 fp = uma_zalloc(file_zone, M_ZERO); |
1147 sx_xlock(&filelist_lock); 1148 if (nfiles >= maxfiles) { 1149 sx_xunlock(&filelist_lock); 1150 uma_zfree(file_zone, fp); 1151 tablefull("file"); 1152 return (ENFILE); 1153 } 1154 nfiles++; --- 53 unchanged lines hidden (view full) --- 1208 */ 1209struct filedesc * 1210fdinit(fdp) 1211 struct filedesc *fdp; 1212{ 1213 struct filedesc0 *newfdp; 1214 1215 MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0), | 1147 sx_xlock(&filelist_lock); 1148 if (nfiles >= maxfiles) { 1149 sx_xunlock(&filelist_lock); 1150 uma_zfree(file_zone, fp); 1151 tablefull("file"); 1152 return (ENFILE); 1153 } 1154 nfiles++; --- 53 unchanged lines hidden (view full) --- 1208 */ 1209struct filedesc * 1210fdinit(fdp) 1211 struct filedesc *fdp; 1212{ 1213 struct filedesc0 *newfdp; 1214 1215 MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0), |
1216 M_FILEDESC, M_WAITOK | M_ZERO); | 1216 M_FILEDESC, M_ZERO); |
1217 mtx_init(&newfdp->fd_fd.fd_mtx, FILEDESC_LOCK_DESC, NULL, MTX_DEF); 1218 newfdp->fd_fd.fd_cdir = fdp->fd_cdir; 1219 if (newfdp->fd_fd.fd_cdir) 1220 VREF(newfdp->fd_fd.fd_cdir); 1221 newfdp->fd_fd.fd_rdir = fdp->fd_rdir; 1222 if (newfdp->fd_fd.fd_rdir) 1223 VREF(newfdp->fd_fd.fd_rdir); 1224 newfdp->fd_fd.fd_jdir = fdp->fd_jdir; --- 39 unchanged lines hidden (view full) --- 1264 /* Certain daemons might not have file descriptors. */ 1265 if (fdp == NULL) 1266 return (NULL); 1267 1268 FILEDESC_LOCK_ASSERT(fdp, MA_OWNED); 1269 1270 FILEDESC_UNLOCK(fdp); 1271 MALLOC(newfdp, struct filedesc *, sizeof(struct filedesc0), | 1217 mtx_init(&newfdp->fd_fd.fd_mtx, FILEDESC_LOCK_DESC, NULL, MTX_DEF); 1218 newfdp->fd_fd.fd_cdir = fdp->fd_cdir; 1219 if (newfdp->fd_fd.fd_cdir) 1220 VREF(newfdp->fd_fd.fd_cdir); 1221 newfdp->fd_fd.fd_rdir = fdp->fd_rdir; 1222 if (newfdp->fd_fd.fd_rdir) 1223 VREF(newfdp->fd_fd.fd_rdir); 1224 newfdp->fd_fd.fd_jdir = fdp->fd_jdir; --- 39 unchanged lines hidden (view full) --- 1264 /* Certain daemons might not have file descriptors. */ 1265 if (fdp == NULL) 1266 return (NULL); 1267 1268 FILEDESC_LOCK_ASSERT(fdp, MA_OWNED); 1269 1270 FILEDESC_UNLOCK(fdp); 1271 MALLOC(newfdp, struct filedesc *, sizeof(struct filedesc0), |
1272 M_FILEDESC, M_WAITOK); | 1272 M_FILEDESC, 0); |
1273 FILEDESC_LOCK(fdp); 1274 bcopy(fdp, newfdp, sizeof(struct filedesc)); 1275 FILEDESC_UNLOCK(fdp); 1276 bzero(&newfdp->fd_mtx, sizeof(newfdp->fd_mtx)); 1277 mtx_init(&newfdp->fd_mtx, FILEDESC_LOCK_DESC, NULL, MTX_DEF); 1278 if (newfdp->fd_cdir) 1279 VREF(newfdp->fd_cdir); 1280 if (newfdp->fd_rdir) --- 23 unchanged lines hidden (view full) --- 1304 * allowing the table to shrink. 1305 */ 1306retry: 1307 i = newfdp->fd_nfiles; 1308 while (i > 2 * NDEXTENT && i > newfdp->fd_lastfile * 2) 1309 i /= 2; 1310 FILEDESC_UNLOCK(fdp); 1311 MALLOC(newfdp->fd_ofiles, struct file **, i * OFILESIZE, | 1273 FILEDESC_LOCK(fdp); 1274 bcopy(fdp, newfdp, sizeof(struct filedesc)); 1275 FILEDESC_UNLOCK(fdp); 1276 bzero(&newfdp->fd_mtx, sizeof(newfdp->fd_mtx)); 1277 mtx_init(&newfdp->fd_mtx, FILEDESC_LOCK_DESC, NULL, MTX_DEF); 1278 if (newfdp->fd_cdir) 1279 VREF(newfdp->fd_cdir); 1280 if (newfdp->fd_rdir) --- 23 unchanged lines hidden (view full) --- 1304 * allowing the table to shrink. 1305 */ 1306retry: 1307 i = newfdp->fd_nfiles; 1308 while (i > 2 * NDEXTENT && i > newfdp->fd_lastfile * 2) 1309 i /= 2; 1310 FILEDESC_UNLOCK(fdp); 1311 MALLOC(newfdp->fd_ofiles, struct file **, i * OFILESIZE, |
1312 M_FILEDESC, M_WAITOK); | 1312 M_FILEDESC, 0); |
1313 FILEDESC_LOCK(fdp); 1314 newfdp->fd_lastfile = fdp->fd_lastfile; 1315 newfdp->fd_nfiles = fdp->fd_nfiles; 1316 j = newfdp->fd_nfiles; 1317 while (j > 2 * NDEXTENT && j > newfdp->fd_lastfile * 2) 1318 j /= 2; 1319 if (i != j) { 1320 /* --- 943 unchanged lines hidden --- | 1313 FILEDESC_LOCK(fdp); 1314 newfdp->fd_lastfile = fdp->fd_lastfile; 1315 newfdp->fd_nfiles = fdp->fd_nfiles; 1316 j = newfdp->fd_nfiles; 1317 while (j > 2 * NDEXTENT && j > newfdp->fd_lastfile * 2) 1318 j /= 2; 1319 if (i != j) { 1320 /* --- 943 unchanged lines hidden --- |