Deleted Added
full compact
kern_descrip.c (65122) kern_descrip.c (65374)
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.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
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.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
39 * $FreeBSD: head/sys/kern/kern_descrip.c 65122 2000-08-26 23:49:44Z alfred $
39 * $FreeBSD: head/sys/kern/kern_descrip.c 65374 2000-09-02 19:17:34Z phk $
40 */
41
42#include "opt_compat.h"
40 */
41
42#include "opt_compat.h"
43#include "opt_devfs.h"
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>
47#include <sys/conf.h>
48#include <sys/filedesc.h>
49#include <sys/kernel.h>
50#include <sys/sysctl.h>
51#include <sys/vnode.h>

--- 5 unchanged lines hidden (view full) ---

57#include <sys/malloc.h>
58#include <sys/unistd.h>
59#include <sys/resourcevar.h>
60#include <sys/event.h>
61
62#include <vm/vm.h>
63#include <vm/vm_extern.h>
64
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/sysproto.h>
46#include <sys/conf.h>
47#include <sys/filedesc.h>
48#include <sys/kernel.h>
49#include <sys/sysctl.h>
50#include <sys/vnode.h>

--- 5 unchanged lines hidden (view full) ---

56#include <sys/malloc.h>
57#include <sys/unistd.h>
58#include <sys/resourcevar.h>
59#include <sys/event.h>
60
61#include <vm/vm.h>
62#include <vm/vm_extern.h>
63
65#ifdef DEVFS
66#include <sys/ctype.h>
67#include <sys/eventhandler.h>
68#include <fs/devfs/devfs.h>
69#endif
70
71static MALLOC_DEFINE(M_FILEDESC, "file desc", "Open file descriptor table");
72MALLOC_DEFINE(M_FILE, "file", "Open file structure");
73static MALLOC_DEFINE(M_SIGIO, "sigio", "sigio structures");
74
75static d_open_t fdopen;
76#define NUMFDESC 64
77
78#define CDEV_MAJOR 22

--- 1238 unchanged lines hidden (view full) ---

1317 &maxfilesperproc, 0, "Maximum files allowed open per process");
1318
1319SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW,
1320 &maxfiles, 0, "Maximum number of files");
1321
1322SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD,
1323 &nfiles, 0, "System-wide number of open files");
1324
64static MALLOC_DEFINE(M_FILEDESC, "file desc", "Open file descriptor table");
65MALLOC_DEFINE(M_FILE, "file", "Open file structure");
66static MALLOC_DEFINE(M_SIGIO, "sigio", "sigio structures");
67
68static d_open_t fdopen;
69#define NUMFDESC 64
70
71#define CDEV_MAJOR 22

--- 1238 unchanged lines hidden (view full) ---

1310 &maxfilesperproc, 0, "Maximum files allowed open per process");
1311
1312SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW,
1313 &maxfiles, 0, "Maximum number of files");
1314
1315SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD,
1316 &nfiles, 0, "System-wide number of open files");
1317
1325#ifdef DEVFS
1326static void
1327fildesc_clone(void *arg, char *name, int namelen, dev_t *dev)
1328{
1329 int u;
1330
1331 if (*dev != NODEV)
1332 return;
1318static void
1319fildesc_clone(void *arg, char *name, int namelen, dev_t *dev)
1320{
1321 int u;
1322
1323 if (*dev != NODEV)
1324 return;
1333 if (devfs_stdclone(name, NULL, "fd/", &u) != 1)
1325 if (dev_stdclone(name, NULL, "fd/", &u) != 1)
1334 return;
1335 if (u <= 2)
1336 return;
1337 *dev = make_dev(&fildesc_cdevsw, u, UID_BIN, GID_BIN, 0666, name);
1338 return;
1339}
1326 return;
1327 if (u <= 2)
1328 return;
1329 *dev = make_dev(&fildesc_cdevsw, u, UID_BIN, GID_BIN, 0666, name);
1330 return;
1331}
1340#endif
1341
1342static void
1343fildesc_drvinit(void *unused)
1344{
1345 dev_t dev;
1346
1347 dev = make_dev(&fildesc_cdevsw, 0, UID_BIN, GID_BIN, 0666, "fd/0");
1348 make_dev_alias(dev, "stdin");
1349 dev = make_dev(&fildesc_cdevsw, 1, UID_BIN, GID_BIN, 0666, "fd/1");
1350 make_dev_alias(dev, "stdout");
1351 dev = make_dev(&fildesc_cdevsw, 2, UID_BIN, GID_BIN, 0666, "fd/2");
1352 make_dev_alias(dev, "stderr");
1332
1333static void
1334fildesc_drvinit(void *unused)
1335{
1336 dev_t dev;
1337
1338 dev = make_dev(&fildesc_cdevsw, 0, UID_BIN, GID_BIN, 0666, "fd/0");
1339 make_dev_alias(dev, "stdin");
1340 dev = make_dev(&fildesc_cdevsw, 1, UID_BIN, GID_BIN, 0666, "fd/1");
1341 make_dev_alias(dev, "stdout");
1342 dev = make_dev(&fildesc_cdevsw, 2, UID_BIN, GID_BIN, 0666, "fd/2");
1343 make_dev_alias(dev, "stderr");
1353#ifdef DEVFS
1354 EVENTHANDLER_REGISTER(devfs_clone, fildesc_clone, 0, 1000);
1355#else
1356 {
1357 int fd;
1344 EVENTHANDLER_REGISTER(dev_clone, fildesc_clone, 0, 1000);
1345 if (!devfs_present) {
1346 int fd;
1358
1347
1359 for (fd = 3; fd < NUMFDESC; fd++)
1360 make_dev(&fildesc_cdevsw, fd, UID_BIN, GID_BIN, 0666, "fd/%d", fd);
1348 for (fd = 3; fd < NUMFDESC; fd++)
1349 make_dev(&fildesc_cdevsw, fd, UID_BIN, GID_BIN, 0666,
1350 "fd/%d", fd);
1361 }
1351 }
1362#endif
1363}
1364
1365struct fileops badfileops = {
1366 badfo_readwrite,
1367 badfo_readwrite,
1368 badfo_ioctl,
1369 badfo_poll,
1370 badfo_stat,

--- 58 unchanged lines hidden ---
1352}
1353
1354struct fileops badfileops = {
1355 badfo_readwrite,
1356 badfo_readwrite,
1357 badfo_ioctl,
1358 badfo_poll,
1359 badfo_stat,

--- 58 unchanged lines hidden ---