pre-2.3.4..
[davej-history.git] / include / linux / nbd.h
blobc2c0431f42dab574bf0cbd17b16fb1e0ae9d3f4c
1 #ifndef LINUX_NBD_H
2 #define LINUX_NBD_H
4 #define NBD_SET_SOCK _IO( 0xab, 0 )
5 #define NBD_SET_BLKSIZE _IO( 0xab, 1 )
6 #define NBD_SET_SIZE _IO( 0xab, 2 )
7 #define NBD_DO_IT _IO( 0xab, 3 )
8 #define NBD_CLEAR_SOCK _IO( 0xab, 4 )
9 #define NBD_CLEAR_QUE _IO( 0xab, 5 )
10 #define NBD_PRINT_DEBUG _IO( 0xab, 6 )
11 #define NBD_SET_SIZE_BLOCKS _IO( 0xab, 7 )
13 #ifdef MAJOR_NR
15 #include <linux/locks.h>
16 #include <asm/semaphore.h>
18 #define LOCAL_END_REQUEST
20 #include <linux/blk.h>
22 #ifdef PARANOIA
23 extern int requests_in;
24 extern int requests_out;
25 #endif
27 static void
28 nbd_end_request(struct request *req)
30 #ifdef PARANOIA
31 requests_out++;
32 #endif
33 if (end_that_request_first( req, !req->errors, "nbd" ))
34 return;
35 end_that_request_last( req );
38 #define MAX_NBD 128
40 struct nbd_device {
41 int refcnt;
42 int flags;
43 int harderror; /* Code of hard error */
44 #define NBD_READ_ONLY 0x0001
45 #define NBD_WRITE_NOCHK 0x0002
46 #define NBD_INITIALISED 0x0004
47 struct socket * sock;
48 struct file * file; /* If == NULL, device is not ready, yet */
49 int magic; /* FIXME: not if debugging is off */
50 struct request *head; /* Requests are added here... */
51 struct request *tail;
52 struct semaphore queue_lock;
54 #endif
56 /* This now IS in some kind of include file... */
58 /* These are send over network in request/reply magic field */
60 #define NBD_REQUEST_MAGIC 0x25609513
61 #define NBD_REPLY_MAGIC 0x67446698
62 /* Do *not* use magics: 0x12560953 0x96744668. */
65 * This is packet used for communication between client and
66 * server. All data are in network byte order.
68 struct nbd_request {
69 u32 magic;
70 u32 type; /* == READ || == WRITE */
71 char handle[8];
72 u64 from;
73 u32 len;
75 #ifdef __GNUC__
76 __attribute__ ((packed))
77 #endif
80 struct nbd_reply {
81 u32 magic;
82 u32 error; /* 0 = ok, else error */
83 char handle[8]; /* handle you got from request */
85 #endif