diff options
Diffstat (limited to 'sys/dev/null/null.c')
-rw-r--r-- | sys/dev/null/null.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c index c1208c11..f836147 100644 --- a/sys/dev/null/null.c +++ b/sys/dev/null/null.c @@ -1,6 +1,7 @@ /*- * Copyright (c) 2000 Mark R. V. Murray & Jeroen C. van Gelderen * Copyright (c) 2001-2004 Mark R. V. Murray + * Copyright (c) 2014 Eitan Adler * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,14 +46,24 @@ __FBSDID("$FreeBSD$"); #include <machine/vmparam.h> /* For use with destroy_dev(9). */ +static struct cdev *full_dev; static struct cdev *null_dev; static struct cdev *zero_dev; +static d_write_t full_write; static d_write_t null_write; static d_ioctl_t null_ioctl; static d_ioctl_t zero_ioctl; static d_read_t zero_read; +static struct cdevsw full_cdevsw = { + .d_version = D_VERSION, + .d_read = zero_read, + .d_write = full_write, + .d_ioctl = zero_ioctl, + .d_name = "full", +}; + static struct cdevsw null_cdevsw = { .d_version = D_VERSION, .d_read = (d_read_t *)nullop, @@ -70,6 +81,16 @@ static struct cdevsw zero_cdevsw = { .d_flags = D_MMAP_ANON, }; + + +/* ARGSUSED */ +static int +full_write(struct cdev *dev __unused, struct uio *uio __unused, int flags __unused) +{ + + return (ENOSPC); +} + /* ARGSUSED */ static int null_write(struct cdev *dev __unused, struct uio *uio, int flags __unused) @@ -155,7 +176,9 @@ null_modevent(module_t mod __unused, int type, void *data __unused) switch(type) { case MOD_LOAD: if (bootverbose) - printf("null: <null device, zero device>\n"); + printf("null: <full device, null device, zero device>\n"); + full_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &full_cdevsw, 0, + NULL, UID_ROOT, GID_WHEEL, 0666, "full"); null_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &null_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0666, "null"); zero_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &zero_cdevsw, 0, @@ -163,6 +186,7 @@ null_modevent(module_t mod __unused, int type, void *data __unused) break; case MOD_UNLOAD: + destroy_dev(full_dev); destroy_dev(null_dev); destroy_dev(zero_dev); break; |