/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* SUCH DAMAGE.
*
* @(#)kern_descrip.c 8.8 (Berkeley) 2/14/95
- *
- * History:
- * CHW 8/5/98 Added F_SETSIZE command to truncate without
- * zero filling space
- * CHW 7/6/98 Updated Preallocate command to take a structure
- * and return output.
- * CHW 6/25/98 Fixed a bug in the lock call in fcntl
- * Preallocate command
*/
#include <sys/param.h>
void *uap;
register_t *retval;
{
-
*retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles);
return (0);
}
void *uap;
register_t *retval;
{
-
*retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, NOFILE);
return (0);
}
_fdrelse(fdp, i);
goto closeit;
}
- }
- else {
+ } else {
struct file **fpp;
char flags;
closeit:
if (*(fpp = &fdp->fd_ofiles[new])) {
struct file *fp = *fpp;
- *fpp = NULL; (void) closef(fp, p);
+ *fpp = NULL;
+ (void) closef(fp, p);
}
}
return (finishdup(fdp, old, new, retval));
fp->f_cred = NOCRED;
crfree(cred);
}
-#if 1 || DIAGNOSTIC
+
fp->f_count = 0;
-#endif
+
nfiles--;
FREE_ZONE(fp, sizeof *fp, M_FILE);
}
*fpp = NULL;
*flags = 0;
}
- }
- else
+ } else
(void) memset(newfdp->fd_ofiles, 0, i * OFILESIZE);
return (newfdp);
fdfree(p)
struct proc *p;
{
- register struct filedesc *fdp;
- register struct file **fpp;
- register int i;
+ struct filedesc *fdp;
+ struct file **fpp;
+ int i;
+ struct vnode *tvp;
if ((fdp = p->p_fd) == NULL)
return;
FREE_ZONE(fdp->fd_ofiles,
fdp->fd_nfiles * OFILESIZE, M_OFILETABL);
}
- vrele(fdp->fd_cdir);
- if (fdp->fd_rdir)
- vrele(fdp->fd_rdir);
+ tvp = fdp->fd_cdir;
+ fdp->fd_cdir = NULL;
+ vrele(tvp);
+ if (fdp->fd_rdir) {
+ tvp = fdp->fd_rdir;
+ fdp->fd_rdir = NULL;
+ vrele(tvp);
+ }
FREE_ZONE(fdp, sizeof *fdp, M_FILEDESC);
}