View | Details | Raw Unified | Return to bug 194985
Collapse All | Expand All

(-)b/sys/kern/kern_descrip.c (+29 lines)
Lines 255-260 fdused_init(struct filedesc *fdp, int fd) Link Here
255
	KASSERT(!fdisused(fdp, fd), ("fd=%d is already used", fd));
255
	KASSERT(!fdisused(fdp, fd), ("fd=%d is already used", fd));
256
256
257
	fdp->fd_map[NDSLOT(fd)] |= NDBIT(fd);
257
	fdp->fd_map[NDSLOT(fd)] |= NDBIT(fd);
258
	fdp->fd_openfd++;
258
}
259
}
259
260
260
static void
261
static void
Lines 288-293 fdunused(struct filedesc *fdp, int fd) Link Here
288
		fdp->fd_freefile = fd;
289
		fdp->fd_freefile = fd;
289
	if (fd == fdp->fd_lastfile)
290
	if (fd == fdp->fd_lastfile)
290
		fdp->fd_lastfile = fd_last_used(fdp, fd);
291
		fdp->fd_lastfile = fd_last_used(fdp, fd);
292
	fdp->fd_openfd--;
291
}
293
}
292
294
293
/*
295
/*
Lines 1262-1267 sys_closefrom(struct thread *td, struct closefrom_args *uap) Link Here
1262
	return (0);
1264
	return (0);
1263
}
1265
}
1264
1266
1267
/*
1268
 * Number of file descriptors per process
1269
 */ 
1270
#ifndef _SYS_SYSPROTO_H_
1271
struct getdtablecount_args {
1272
	int	dummy;
1273
};
1274
#endif
1275
/* ARGSUSED */
1276
1277
int
1278
sys_getdtablecount(struct thread *td, struct getdtablecount_args *uap)
1279
{
1280
	struct proc *p;
1281
	struct filedesc *fdp;
1282
1283
	p = td->td_proc;
1284
	PROC_LOCK(p);
1285
	fdp = p->p_fd;
1286
	FILEDESC_SLOCK(fdp);
1287
	td->td_retval[0] = fdp->fd_openfd;
1288
	FILEDESC_SUNLOCK(fdp);
1289
	PROC_UNLOCK(p);
1290
	
1291
	return (0);
1292
}
1293
1265
#if defined(COMPAT_43)
1294
#if defined(COMPAT_43)
1266
/*
1295
/*
1267
 * Return status information about a file descriptor.
1296
 * Return status information about a file descriptor.

Return to bug 194985