kern_descrip.c (249240) | kern_descrip.c (249480) |
---|---|
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 249240 2013-04-07 17:44:30Z trociny $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_descrip.c 249480 2013-04-14 17:08:34Z mjg $"); |
39 40#include "opt_capsicum.h" 41#include "opt_compat.h" 42#include "opt_ddb.h" 43#include "opt_ktrace.h" 44#include "opt_procdesc.h" 45 46#include <sys/param.h> --- 1530 unchanged lines hidden (view full) --- 1577 ("file descriptor isn't free")); 1578 KASSERT(fdp->fd_ofiles[fd].fde_flags == 0, ("file flags are set")); 1579 fdused(fdp, fd); 1580 *result = fd; 1581 return (0); 1582} 1583 1584/* | 39 40#include "opt_capsicum.h" 41#include "opt_compat.h" 42#include "opt_ddb.h" 43#include "opt_ktrace.h" 44#include "opt_procdesc.h" 45 46#include <sys/param.h> --- 1530 unchanged lines hidden (view full) --- 1577 ("file descriptor isn't free")); 1578 KASSERT(fdp->fd_ofiles[fd].fde_flags == 0, ("file flags are set")); 1579 fdused(fdp, fd); 1580 *result = fd; 1581 return (0); 1582} 1583 1584/* |
1585 * Allocate n file descriptors for the process. 1586 */ 1587int 1588fdallocn(struct thread *td, int minfd, int *fds, int n) 1589{ 1590 struct proc *p = td->td_proc; 1591 struct filedesc *fdp = p->p_fd; 1592 int i; 1593 1594 FILEDESC_XLOCK_ASSERT(fdp); 1595 1596 if (!fdavail(td, n)) 1597 return (EMFILE); 1598 1599 for (i = 0; i < n; i++) 1600 if (fdalloc(td, 0, &fds[i]) != 0) 1601 break; 1602 1603 if (i < n) { 1604 for (i--; i >= 0; i--) 1605 fdunused(fdp, fds[i]); 1606 return (EMFILE); 1607 } 1608 1609 return (0); 1610} 1611 1612/* |
|
1585 * Check to see whether n user file descriptors are available to the process 1586 * p. 1587 */ 1588int 1589fdavail(struct thread *td, int n) 1590{ 1591 struct proc *p = td->td_proc; 1592 struct filedesc *fdp = td->td_proc->p_fd; --- 2282 unchanged lines hidden --- | 1613 * Check to see whether n user file descriptors are available to the process 1614 * p. 1615 */ 1616int 1617fdavail(struct thread *td, int n) 1618{ 1619 struct proc *p = td->td_proc; 1620 struct filedesc *fdp = td->td_proc->p_fd; --- 2282 unchanged lines hidden --- |