vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / drivers / disk / virtual / nbd / nbd.h
blob9494cdd7883a6c9e28f76de370e0b1880a8d546c
1 /*
2 * Network Block Device protocol
3 * Copyright 2006-2007, François Revol. All rights reserved.
4 * Distributed under the terms of the MIT License.
5 *
6 * references:
7 * include/linux/nbd.h
8 */
10 enum {
11 NBD_CMD_READ = 0,
12 NBD_CMD_WRITE,
13 NBD_CMD_DISC
16 #define NBD_REQUEST_MAGIC 0x25609513
17 #define NBD_REPLY_MAGIC 0x67446698
19 /* in network byte order */
20 struct nbd_request {
21 uint32 magic; /* REQUEST_MAGIC */
22 uint32 type;
23 uint64 handle; //char handle[8];
24 uint64 from;
25 uint32 len;
26 } _PACKED;
28 /* in network byte order */
29 struct nbd_reply {
30 uint32 magic; /* REPLY_MAGIC */
31 uint32 error;
32 uint64 handle; //char handle[8];
33 } _PACKED;
35 /* initialization protocol (ENBD ? or at least Linux specific ?) */
37 #define NBD_INIT_PASSWD "NBDMAGIC"
38 #define NBD_INIT_MAGIC 0x0000420281861253LL
40 /* in network byte order */
41 struct nbd_init_packet {
42 uint8 passwd[8]; /* "NBDMAGIC" */
43 uint64 magic; /* INIT_MAGIC */
44 uint64 device_size; /* size in bytes */
45 uint8 dummy[128]; /* reserved for future use */
46 } _PACKED;