Deleted Added
full compact
kern_descrip.c (155362) kern_descrip.c (156861)
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.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
35 */
36
37#include <sys/cdefs.h>
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.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/kern_descrip.c 155362 2006-02-05 23:57:32Z wsalamon $");
38__FBSDID("$FreeBSD: head/sys/kern/kern_descrip.c 156861 2006-03-18 23:27:21Z csjp $");
39
40#include "opt_compat.h"
41#include "opt_ddb.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45
46#include <sys/conf.h>

--- 1205 unchanged lines hidden (view full) ---

1252fdalloc(struct thread *td, int minfd, int *result)
1253{
1254 struct proc *p = td->td_proc;
1255 struct filedesc *fdp = p->p_fd;
1256 int fd = -1, maxfd;
1257
1258 FILEDESC_LOCK_ASSERT(fdp, MA_OWNED);
1259
39
40#include "opt_compat.h"
41#include "opt_ddb.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45
46#include <sys/conf.h>

--- 1205 unchanged lines hidden (view full) ---

1252fdalloc(struct thread *td, int minfd, int *result)
1253{
1254 struct proc *p = td->td_proc;
1255 struct filedesc *fdp = p->p_fd;
1256 int fd = -1, maxfd;
1257
1258 FILEDESC_LOCK_ASSERT(fdp, MA_OWNED);
1259
1260 if (fdp->fd_freefile > minfd)
1261 minfd = fdp->fd_freefile;
1262
1263 PROC_LOCK(p);
1264 maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
1265 PROC_UNLOCK(p);
1266
1267 /*
1268 * Search the bitmap for a free descriptor. If none is found, try
1269 * to grow the file table. Keep at it until we either get a file
1270 * descriptor or run into process or system limits; fdgrowtable()

--- 13 unchanged lines hidden (view full) ---

1284 * used and return it to the caller.
1285 */
1286 KASSERT(!fdisused(fdp, fd),
1287 ("fd_first_free() returned non-free descriptor"));
1288 KASSERT(fdp->fd_ofiles[fd] == NULL,
1289 ("free descriptor isn't"));
1290 fdp->fd_ofileflags[fd] = 0; /* XXX needed? */
1291 fdused(fdp, fd);
1260 PROC_LOCK(p);
1261 maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc);
1262 PROC_UNLOCK(p);
1263
1264 /*
1265 * Search the bitmap for a free descriptor. If none is found, try
1266 * to grow the file table. Keep at it until we either get a file
1267 * descriptor or run into process or system limits; fdgrowtable()

--- 13 unchanged lines hidden (view full) ---

1281 * used and return it to the caller.
1282 */
1283 KASSERT(!fdisused(fdp, fd),
1284 ("fd_first_free() returned non-free descriptor"));
1285 KASSERT(fdp->fd_ofiles[fd] == NULL,
1286 ("free descriptor isn't"));
1287 fdp->fd_ofileflags[fd] = 0; /* XXX needed? */
1288 fdused(fdp, fd);
1289 fdp->fd_freefile = fd_first_free(fdp, fd, fdp->fd_nfiles);
1292 *result = fd;
1293 return (0);
1294}
1295
1296/*
1297 * Check to see whether n user file descriptors
1298 * are available to the process p.
1299 */

--- 1389 unchanged lines hidden ---
1290 *result = fd;
1291 return (0);
1292}
1293
1294/*
1295 * Check to see whether n user file descriptors
1296 * are available to the process p.
1297 */

--- 1389 unchanged lines hidden ---