kern_descrip.c (219968) | kern_descrip.c (219999) |
---|---|
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 219968 2011-03-24 18:40:11Z jhb $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_descrip.c 219999 2011-03-25 14:00:36Z kib $"); |
39 40#include "opt_compat.h" 41#include "opt_ddb.h" 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46 --- 1464 unchanged lines hidden (view full) --- 1511/* 1512 * Create a new open file structure and allocate a file decriptor for the 1513 * process that refers to it. We add one reference to the file for the 1514 * descriptor table and one reference for resultfp. This is to prevent us 1515 * being preempted and the entry in the descriptor table closed after we 1516 * release the FILEDESC lock. 1517 */ 1518int | 39 40#include "opt_compat.h" 41#include "opt_ddb.h" 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46 --- 1464 unchanged lines hidden (view full) --- 1511/* 1512 * Create a new open file structure and allocate a file decriptor for the 1513 * process that refers to it. We add one reference to the file for the 1514 * descriptor table and one reference for resultfp. This is to prevent us 1515 * being preempted and the entry in the descriptor table closed after we 1516 * release the FILEDESC lock. 1517 */ 1518int |
1519falloc(struct thread *td, struct file **resultfp, int *resultfd) | 1519fallocf(struct thread *td, struct file **resultfp, int *resultfd, int flags) |
1520{ 1521 struct proc *p = td->td_proc; 1522 struct file *fp; 1523 int error, i; 1524 int maxuserfiles = maxfiles - (maxfiles / 20); 1525 static struct timeval lastfail; 1526 static int curfail; 1527 --- 26 unchanged lines hidden (view full) --- 1554 if ((error = fdalloc(td, 0, &i))) { 1555 FILEDESC_XUNLOCK(p->p_fd); 1556 fdrop(fp, td); 1557 if (resultfp) 1558 fdrop(fp, td); 1559 return (error); 1560 } 1561 p->p_fd->fd_ofiles[i] = fp; | 1520{ 1521 struct proc *p = td->td_proc; 1522 struct file *fp; 1523 int error, i; 1524 int maxuserfiles = maxfiles - (maxfiles / 20); 1525 static struct timeval lastfail; 1526 static int curfail; 1527 --- 26 unchanged lines hidden (view full) --- 1554 if ((error = fdalloc(td, 0, &i))) { 1555 FILEDESC_XUNLOCK(p->p_fd); 1556 fdrop(fp, td); 1557 if (resultfp) 1558 fdrop(fp, td); 1559 return (error); 1560 } 1561 p->p_fd->fd_ofiles[i] = fp; |
1562 if ((flags & O_CLOEXEC) != 0) 1563 p->p_fd->fd_ofileflags[i] |= UF_EXCLOSE; |
|
1562 FILEDESC_XUNLOCK(p->p_fd); 1563 if (resultfp) 1564 *resultfp = fp; 1565 if (resultfd) 1566 *resultfd = i; 1567 return (0); 1568} 1569 | 1564 FILEDESC_XUNLOCK(p->p_fd); 1565 if (resultfp) 1566 *resultfp = fp; 1567 if (resultfd) 1568 *resultfd = i; 1569 return (0); 1570} 1571 |
1572int 1573falloc(struct thread *td, struct file **resultfp, int *resultfd) 1574{ 1575 1576 return (fallocf(td, resultfp, resultfd, 0)); 1577} 1578 |
|
1570/* 1571 * Build a new filedesc structure from another. 1572 * Copy the current, root, and jail root vnode references. 1573 */ 1574struct filedesc * 1575fdinit(struct filedesc *fdp) 1576{ 1577 struct filedesc0 *newfdp; --- 1873 unchanged lines hidden --- | 1579/* 1580 * Build a new filedesc structure from another. 1581 * Copy the current, root, and jail root vnode references. 1582 */ 1583struct filedesc * 1584fdinit(struct filedesc *fdp) 1585{ 1586 struct filedesc0 *newfdp; --- 1873 unchanged lines hidden --- |