Permalink
Browse files

NBD: Implement Network Block Device support.

This is modeled after the Linux API, so that existing NBD clients
do not need to be changed to work on this platform.

no objections
  • Loading branch information...
bluerise committed Apr 23, 2015
1 parent 29ce620 commit 098497f044a2a594586198722b4b049e7e0380fe
@@ -226,6 +226,8 @@ _mkdev(tmpfsrd, tmpfsrd*, {-dodisk2 tmpfsrd $U major_tmpfsrd_b major_tmpfsrd_c $
__devitem(xd, xd*, Xylogic 753/7053 disks)dnl
__devitem(xy, xy*, {- Xylogic 450/451 disks-})dnl
__devitem(wd, {-wd*-}, {-quote(winchester)disk drives (ST506{-,-} IDE{-,-} ESDI{-,-} RLL{-,-} ...)-})dnl
__devitem(nbd, nbd*, quote(network)pseudo-disk devices)dnl
_mkdev(nbd, nbd*, {-dodisk nbd $U major_nbd_b major_nbd_c $U 0{--}ifstep(nbd)-})dnl
__devitem(vnd, vnd*, quote(file)pseudo-disk devices)dnl
_mkdev(vnd, vnd*, {-dodisk vnd $U major_vnd_b major_vnd_c $U 0{--}ifstep(vnd)-})dnl
__devitem(ra, ra*, {-MSCP disks-})dnl
@@ -49,7 +49,7 @@ show_vers()dnl <-- now that all files are included, show versions
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 18 2009 $
.Dd $Mdocdate: May 22 2015 $
.Dt MAKEDEV 8 MACHINE
.Os
.Sh NAME
@@ -33,6 +33,7 @@
# cd* ATAPI and SCSI CD-ROM drives
# sd* SCSI disks, including flopticals
# tmpfsrd* "tmpfsrd" pseudo-disks
# nbd* "network" pseudo-disk devices
# vnd* "file" pseudo-disk devices
# wd* "winchester" disk drives (ST506, IDE, ESDI, RLL, ...)
# Tapes:
@@ -216,7 +217,7 @@ U=`unt $i`
case $i in
ramdisk)
R std bpf0 wd0 sd0 tty00 tty01 tmpfsrd0 bio diskmap
R st0 cd0 ttyC0 wskbd0 wskbd1 wskbd2 random
R st0 cd0 ttyC0 wskbd0 wskbd1 wskbd2 random nbd0
;;
std)
@@ -491,6 +492,10 @@ vnd*)
dodisk vnd $U 14 41 $U 0
;;
nbd*)
dodisk nbd $U 20 43 $U 0
;;
tmpfsrd*)
dodisk2 tmpfsrd $U 19 48 $U 0
;;
@@ -505,15 +510,15 @@ local)
all)
R drm0 drm1 drm2 drm3 nvram gpio0 gpio1 gpio2 bktr0 vnd0 vnd1
R vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 cd0 cd1
R tmpfsrd0 tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4 bpf5
R bpf6 bpf7 bpf8 bpf9 bio pty0 diskmap vscsi0 ch0 audio0
R audio1 audio2 fuse pppx hotplug ptm gpr0 local wscons pci0
R pci1 pci2 pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4
R rmidi5 rmidi6 rmidi7 tuner0 radio0 speaker video0 video1 uk0
R random lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 tty00 tty01 tty02 tty03
R tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b apm pf pctr
R systrace wd0 wd1 wd2 wd3 std st0 st1 fd
R vnd2 vnd3 nbd0 nbd1 nbd2 nbd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6
R sd7 sd8 sd9 cd0 cd1 tmpfsrd0 tun0 tun1 tun2 tun3 bpf0 bpf1
R bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 bio pty0 diskmap
R vscsi0 ch0 audio0 audio1 audio2 fuse pppx hotplug ptm gpr0
R local wscons pci0 pci1 pci2 pci3 uall rmidi0 rmidi1 rmidi2
R rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0 radio0 speaker
R video0 video1 uk0 random lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 tty00
R tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a
R tty0b apm pf pctr systrace wd0 wd1 wd2 wd3 std st0 st1 fd
;;
wd*|sd*)
@@ -30,6 +30,7 @@ _TITLE(dis)
_DEV(cd, 15, 6)
_DEV(sd, 13, 4)
_DEV(tmpfsrd, 48, 19)
_DEV(nbd, 43, 20)
_DEV(vnd, 41, 14)
_DEV(wd, 3, 0)
_TITLE(tap)
@@ -92,7 +93,7 @@ divert(__mddivert)dnl
dnl
ramdisk)
_recurse std bpf0 wd0 sd0 tty00 tty01 tmpfsrd0 bio diskmap
_recurse st0 cd0 ttyC0 wskbd0 wskbd1 wskbd2 random
_recurse st0 cd0 ttyC0 wskbd0 wskbd1 wskbd2 random nbd0
;;
_std(1, 2, 50, 7)
@@ -113,6 +114,7 @@ target(all, xy, 0, 1, 2, 3)dnl
target(all, tmpfsrd, 0)dnl
target(all, cd, 0, 1)dnl
target(all, sd, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)dnl
target(all, nbd, 0, 1, 2, 3)dnl
target(all, vnd, 0, 1, 2, 3)dnl
target(all, bktr, 0)dnl
target(all, gpio, 0, 1, 2)dnl
@@ -34,6 +34,7 @@
# ch* SCSI media changers
# sd* SCSI disks, including flopticals
# tmpfsrd* "tmpfsrd" pseudo-disks
# nbd* "network" pseudo-disk devices
# vnd* "file" pseudo-disk devices
# wd* "winchester" disk drives (ST506, IDE, ESDI, RLL, ...)
# Tapes:
@@ -207,7 +208,7 @@ U=`unt $i`
case $i in
ramdisk)
R std bpf0 wd0 wd1 sd0 tty00 tmpfsrd0 wsmouse
R st0 ttyC0 wskbd0 apm bio diskmap random
R st0 ttyC0 wskbd0 apm bio diskmap random nbd0
;;
std)
@@ -449,6 +450,10 @@ vnd*)
dodisk vnd $U 19 19 $U 0
;;
nbd*)
dodisk nbd $U 21 21 $U 0
;;
tmpfsrd*)
dodisk2 tmpfsrd $U 20 20 $U 0
;;
@@ -467,14 +472,14 @@ local)
all)
R gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7 gpio8 vnd0
R vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 cd0
R cd1 tmpfsrd0 tun0 tun1 tun2 tun3 bio bpf0 bpf1 bpf2 bpf3
R bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 pty0 diskmap vscsi0 ch0 fuse
R pppx hotplug ptm local wscons pci0 pci1 pci2 pci3 uall
R rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7
R tuner0 radio0 video0 video1 uk0 random tty00 tty01 tty02
R tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b apm
R pf systrace wd0 wd1 wd2 wd3 std st0 st1 fd
R vnd1 vnd2 vnd3 nbd0 nbd1 nbd2 nbd3 sd0 sd1 sd2 sd3 sd4 sd5
R sd6 sd7 sd8 sd9 cd0 cd1 tmpfsrd0 tun0 tun1 tun2 tun3 bio
R bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 pty0
R diskmap vscsi0 ch0 fuse pppx hotplug ptm local wscons pci0
R pci1 pci2 pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4
R rmidi5 rmidi6 rmidi7 tuner0 radio0 video0 video1 uk0 random
R tty00 tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09
R tty0a tty0b apm pf systrace wd0 wd1 wd2 wd3 std st0 st1 fd
;;
wd*|sd*)
@@ -37,6 +37,7 @@ _DEV(cd, 26, 26)
_DEV(ch, 27)
_DEV(sd, 24, 24)
_DEV(tmpfsrd, 20, 20)
_DEV(nbd, 21, 21)
_DEV(vnd, 19, 19)
_DEV(wd, 16, 16)
_TITLE(tap)
@@ -90,7 +91,7 @@ divert(__mddivert)dnl
dnl
ramdisk)
_recurse std bpf0 wd0 wd1 sd0 tty00 tmpfsrd0 wsmouse
_recurse st0 ttyC0 wskbd0 apm bio diskmap random
_recurse st0 ttyC0 wskbd0 apm bio diskmap random nbd0
;;
_std(1, 2, 8, 6)
@@ -109,5 +110,6 @@ target(all, xy, 0, 1, 2, 3)dnl
target(all, tmpfsrd, 0)dnl
target(all, cd, 0, 1)dnl
target(all, sd, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)dnl
target(all, nbd, 0, 1, 2, 3)dnl
target(all, vnd, 0, 1, 2, 3)dnl
target(all, gpio, 0, 1, 2, 3, 4, 5, 6, 7, 8)dnl
@@ -23,7 +23,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 18 2009 $
.Dd $Mdocdate: May 22 2015 $
.Dt MAKEDEV 8 amd64
.Os
.Sh NAME
@@ -84,6 +84,10 @@ SCSI disks, including flopticals, see
.Dq tmpfsrd
pseudo-disks, see
.Xr tmpfsrd 4 .
.It Ar nbd*
.Dq network
pseudo-disk devices, see
.Xr nbd 4 .
.It Ar vnd*
.Dq file
pseudo-disk devices, see
@@ -23,7 +23,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: December 11 2014 $
.Dd $Mdocdate: May 22 2015 $
.Dt MAKEDEV 8 armv7
.Os
.Sh NAME
@@ -87,6 +87,10 @@ SCSI disks, including flopticals, see
.Dq tmpfsrd
pseudo-disks, see
.Xr tmpfsrd 4 .
.It Ar nbd*
.Dq network
pseudo-disk devices, see
.Xr nbd 4 .
.It Ar vnd*
.Dq file
pseudo-disk devices, see
@@ -233,5 +233,6 @@ struct nam2blk nam2blk[] = {
{ "cd", 6 },
{ "vnd", 14 },
{ "tmpfsrd", 19 },
{ "nbd", 20 },
{ NULL, -1 }
};
@@ -47,6 +47,7 @@ bdev_decl(wd);
#include "cd.h"
#include "uk.h"
#include "vnd.h"
#include "nbd.h"
#include "tmpfsrd.h"
struct bdevsw bdevsw[] =
@@ -71,6 +72,7 @@ struct bdevsw bdevsw[] =
bdev_notdef(), /* 17: was: rd(4) ramdisk driver */
bdev_notdef(), /* 18 */
bdev_disk_init(NTMPFSRD,tmpfsrd), /* 19: tmpfs RAM disk driver */
bdev_disk_init(NNBD,nbd), /* 20: network block device */
};
int nblkdev = nitems(bdevsw);
@@ -215,7 +217,7 @@ struct cdevsw cdevsw[] =
cdev_tun_init(NTUN,tun), /* 40: network tunnel */
cdev_disk_init(NVND,vnd), /* 41: vnode disk driver */
cdev_audio_init(NAUDIO,audio), /* 42: generic audio I/O */
cdev_notdef(), /* 43 */
cdev_disk_init(NNBD,nbd), /* 43: network block device*/
cdev_video_init(NVIDEO,video), /* 44: generic video I/O */
cdev_random_init(1,random), /* 45: random data source */
cdev_ocis_init(NPCTR,pctr), /* 46: performance counters */
@@ -357,7 +359,7 @@ int chrtoblktbl[] = {
/* 40 */ NODEV,
/* 41 */ 14, /* vnd */
/* 42 */ NODEV,
/* 43 */ NODEV,
/* 43 */ 20, /* nbd */
/* 44 */ NODEV,
/* 45 */ NODEV,
/* 46 */ NODEV,
@@ -244,6 +244,7 @@ attach vmt at mainbus
# device major numbers
#
major {nbd = 20}
major {vnd = 14}
major {sd = 4}
major {st = 5}
@@ -78,6 +78,7 @@
*/
#include "vnd.h" /* vnode disk driver */
#include "tmpfsrd.h"
#include "nbd.h"
/*
* WD/ATA devices
@@ -160,7 +161,7 @@ struct bdevsw bdevsw[] = {
bdev_notdef(), /* 18: was: rd(4) ramdisk driver */
bdev_disk_init(NVND,vnd), /* 19: vnode disk driver */
bdev_disk_init(NTMPFSRD,tmpfsrd), /* 20: tmpfs RAM disk driver */
bdev_notdef(), /* 21: was: concatenated disk driver */
bdev_disk_init(NNBD,nbd), /* 21: network block device */
bdev_notdef(), /* 22: */
bdev_notdef(), /* 23: */
bdev_disk_init(NSD,sd), /* 24: SCSI disk */
@@ -285,7 +286,7 @@ struct cdevsw cdevsw[] = {
cdev_notdef(), /* 18: */
cdev_disk_init(NVND,vnd), /* 19: vnode disk driver */
cdev_disk_init(NTMPFSRD,tmpfsrd), /* 20: tmpfs RAM disk driver */
cdev_notdef(), /* 21: was: concatenated disk driver */
cdev_disk_init(NNBD,nbd), /* 21: network block deivce */
cdev_bpf_init(NBPFILTER,bpf), /* 22: Berkeley packet filter */
cdev_notdef(), /* 23: */
cdev_disk_init(NSD,sd), /* 24: SCSI disk */
@@ -432,7 +433,7 @@ int chrtoblktbl[] = {
/* 18 */ NODEV,
/* 19 */ 19, /* vnd */
/* 20 */ 20, /* tmpfsrd */
/* 21 */ NODEV,
/* 21 */ 21, /* nbd */
/* 22 */ NODEV,
/* 23 */ NODEV,
/* 24 */ 24, /* sd */
@@ -139,6 +139,7 @@ struct nam2blk nam2blk[] = {
{ "wd", 16 },
{ "sd", 24 },
{ "cd", 26 },
{ "nbd", 21 },
{ "tmpfsrd", 20 },
{ NULL, -1 }
};
@@ -7,6 +7,7 @@ major {wd = 16}
major {sd = 24}
major {cd = 26}
major {tmpfsrd = 20}
major {nbd = 21}
file arch/arm/arm/conf.c
@@ -85,6 +85,7 @@ pseudo-device nmea 1 # NMEA 0183 line discipline
pseudo-device msts 1 # MSTS line discipline
pseudo-device endrun 1 # EndRun line discipline
pseudo-device vnd 4 # vnode disk devices
pseudo-device nbd 4 # network block device support
pseudo-device ksyms 1 # kernel symbols device
pseudo-device systrace 1 # system call tracing device
@@ -513,6 +513,7 @@ device spdmem
file dev/spdmem.c spdmem
# legitimate pseudo-devices
pseudo-device nbd: disk
pseudo-device vnd: disk
pseudo-device tmpfsrd: disk
file dev/tmpfsrd.c tmpfsrd needs-flag
@@ -619,6 +620,7 @@ file dev/ic/tc921x.c tc921x
file dev/ic/pt2254a.c pt2254a
file dev/midi.c midi | midibus needs-flag
file dev/mulaw.c mulaw
file dev/nbd.c nbd needs-flag
file dev/systrace.c systrace needs-flag
file dev/vnd.c vnd needs-flag
file dev/rnd.c
Oops, something went wrong.

0 comments on commit 098497f

Please sign in to comment.