fd: move fd table sizing out of fdinit
now it is placed with the rest of actual initialisation
This commit is contained in:
parent
4103c3cd5b
commit
893d20c95a
@ -568,7 +568,7 @@ proc0_init(void *dummy __unused)
|
||||
|
||||
/* Create the file descriptor table. */
|
||||
p->p_pd = pdinit(NULL, false);
|
||||
p->p_fd = fdinit(NULL, false, NULL);
|
||||
p->p_fd = fdinit();
|
||||
p->p_fdtol = NULL;
|
||||
|
||||
/* Create the limits structures. */
|
||||
|
@ -2150,16 +2150,11 @@ finstall(struct thread *td, struct file *fp, int *fd, int flags,
|
||||
* If fdp is not NULL, return with it shared locked.
|
||||
*/
|
||||
struct filedesc *
|
||||
fdinit(struct filedesc *fdp, bool prepfiles, int *lastfile)
|
||||
fdinit(void)
|
||||
{
|
||||
struct filedesc0 *newfdp0;
|
||||
struct filedesc *newfdp;
|
||||
|
||||
if (prepfiles)
|
||||
MPASS(lastfile != NULL);
|
||||
else
|
||||
MPASS(lastfile == NULL);
|
||||
|
||||
newfdp0 = uma_zalloc(filedesc0_zone, M_WAITOK | M_ZERO);
|
||||
newfdp = &newfdp0->fd_fd;
|
||||
|
||||
@ -2171,24 +2166,6 @@ fdinit(struct filedesc *fdp, bool prepfiles, int *lastfile)
|
||||
newfdp->fd_files = (struct fdescenttbl *)&newfdp0->fd_dfiles;
|
||||
newfdp->fd_files->fdt_nfiles = NDFILE;
|
||||
|
||||
if (fdp == NULL)
|
||||
return (newfdp);
|
||||
|
||||
FILEDESC_SLOCK(fdp);
|
||||
if (!prepfiles) {
|
||||
FILEDESC_SUNLOCK(fdp);
|
||||
return (newfdp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
*lastfile = fdlastfile(fdp);
|
||||
if (*lastfile < newfdp->fd_nfiles)
|
||||
break;
|
||||
FILEDESC_SUNLOCK(fdp);
|
||||
fdgrowtable(newfdp, *lastfile + 1);
|
||||
FILEDESC_SLOCK(fdp);
|
||||
}
|
||||
|
||||
return (newfdp);
|
||||
}
|
||||
|
||||
@ -2368,7 +2345,16 @@ fdcopy(struct filedesc *fdp)
|
||||
|
||||
MPASS(fdp != NULL);
|
||||
|
||||
newfdp = fdinit(fdp, true, &lastfile);
|
||||
newfdp = fdinit();
|
||||
FILEDESC_SLOCK(fdp);
|
||||
for (;;) {
|
||||
lastfile = fdlastfile(fdp);
|
||||
if (lastfile < newfdp->fd_nfiles)
|
||||
break;
|
||||
FILEDESC_SUNLOCK(fdp);
|
||||
fdgrowtable(newfdp, lastfile + 1);
|
||||
FILEDESC_SLOCK(fdp);
|
||||
}
|
||||
/* copy all passable descriptors (i.e. not kqueue) */
|
||||
newfdp->fd_freefile = -1;
|
||||
for (i = 0; i <= lastfile; ++i) {
|
||||
|
@ -340,7 +340,7 @@ fork_norfproc(struct thread *td, int flags)
|
||||
struct filedesc *fdtmp;
|
||||
struct pwddesc *pdtmp;
|
||||
pdtmp = pdinit(td->td_proc->p_pd, false);
|
||||
fdtmp = fdinit(td->td_proc->p_fd, false, NULL);
|
||||
fdtmp = fdinit();
|
||||
pdescfree(td);
|
||||
fdescfree(td);
|
||||
p1->p_fd = fdtmp;
|
||||
@ -418,7 +418,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread *
|
||||
*/
|
||||
if (fr->fr_flags & RFCFDG) {
|
||||
pd = pdinit(p1->p_pd, false);
|
||||
fd = fdinit(p1->p_fd, false, NULL);
|
||||
fd = fdinit();
|
||||
fdtol = NULL;
|
||||
} else if (fr->fr_flags & RFFDG) {
|
||||
if (fr->fr_flags2 & FR2_SHARE_PATHS)
|
||||
|
@ -254,7 +254,7 @@ void fdunshare(struct thread *td);
|
||||
void fdescfree(struct thread *td);
|
||||
int fdlastfile(struct filedesc *fdp);
|
||||
int fdlastfile_single(struct filedesc *fdp);
|
||||
struct filedesc *fdinit(struct filedesc *fdp, bool prepfiles, int *lastfile);
|
||||
struct filedesc *fdinit(void);
|
||||
struct filedesc *fdshare(struct filedesc *fdp);
|
||||
struct filedesc_to_leader *
|
||||
filedesc_to_leader_alloc(struct filedesc_to_leader *old,
|
||||
|
Loading…
Reference in New Issue
Block a user