version 1.143, 2006/05/14 21:15:11 |
version 1.144, 2006/07/23 22:06:11 |
|
|
* a file descriptor for the process that refers to it. |
* a file descriptor for the process that refers to it. |
*/ |
*/ |
int |
int |
falloc(struct proc *p, struct file **resultfp, int *resultfd) |
falloc(struct lwp *l, struct file **resultfp, int *resultfd) |
{ |
{ |
struct file *fp, *fq; |
struct file *fp, *fq; |
|
struct proc *p; |
int error, i; |
int error, i; |
|
|
|
p = l->l_proc; |
|
|
restart: |
restart: |
if ((error = fdalloc(p, 0, &i)) != 0) { |
if ((error = fdalloc(p, 0, &i)) != 0) { |
if (error == ENOSPC) { |
if (error == ENOSPC) { |
Line 995 falloc(struct proc *p, struct file **res |
|
Line 998 falloc(struct proc *p, struct file **res |
|
p->p_fd->fd_ofiles[i] = fp; |
p->p_fd->fd_ofiles[i] = fp; |
simple_lock_init(&fp->f_slock); |
simple_lock_init(&fp->f_slock); |
fp->f_count = 1; |
fp->f_count = 1; |
fp->f_cred = p->p_cred; |
fp->f_cred = l->l_cred; |
kauth_cred_hold(fp->f_cred); |
kauth_cred_hold(fp->f_cred); |
if (resultfp) { |
if (resultfp) { |
fp->f_usecount = 1; |
fp->f_usecount = 1; |
|
|
snprintf(which, sizeof(which), ",%d", i); |
snprintf(which, sizeof(which), ",%d", i); |
strlcat(closed, which, sizeof(closed)); |
strlcat(closed, which, sizeof(closed)); |
if (devnullfp == NULL) { |
if (devnullfp == NULL) { |
if ((error = falloc(p, &fp, &fd)) != 0) |
if ((error = falloc(l, &fp, &fd)) != 0) |
return (error); |
return (error); |
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/null", |
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/null", |
l); |
l); |