ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-NBD/NBD.xs
(Generate patch)

Comparing Linux-NBD/NBD.xs (file contents):
Revision 1.2 by root, Fri May 9 00:15:14 2003 UTC vs.
Revision 1.5 by root, Mon Sep 20 11:14:25 2010 UTC

63 ioctl (dev, NBD_SET_BLKSIZE, blocksize); 63 ioctl (dev, NBD_SET_BLKSIZE, blocksize);
64 64
65void 65void
66_set_size (int dev, unsigned long size) 66_set_size (int dev, unsigned long size)
67 CODE: 67 CODE:
68 ioctl (dev, NBD_SET_BLKSIZE, size); 68 ioctl (dev, NBD_SET_SIZE, size);
69 69
70void 70void
71_set_size_blocks (int dev, unsigned long nblocks) 71_set_size_blocks (int dev, unsigned long nblocks)
72 CODE: 72 CODE:
73 ioctl (dev, NBD_SET_SIZE_BLOCKS, nblocks); 73 ioctl (dev, NBD_SET_SIZE_BLOCKS, nblocks);
74 74
75void
76_set_timeout (int dev, unsigned long timeout)
77 CODE:
78 ioctl (dev, NBD_SET_TIMEOUT, timeout);
79
80void
81_print_debug (int dev)
82 CODE:
83 ioctl (dev, NBD_PRINT_DEBUG, 0);
84
75MODULE = Linux::NBD PACKAGE = Linux::NBD::Server 85MODULE = Linux::NBD PACKAGE = Linux::NBD::Server
76 86
77void 87void
78_one_request (SV *obj, int fd) 88_one_request (SV *obj, int fd)
79 CODE: 89 CODE:
90{
80 struct nbd_request req; 91 struct nbd_request req;
81 92
82 if (read (fd, &req, sizeof (req)) == sizeof (req)) 93 if (read (fd, &req, sizeof (req)) == sizeof (req))
83 { 94 {
84 if (req.magic == htonl (NBD_REQUEST_MAGIC)) 95 if (req.magic == htonl (NBD_REQUEST_MAGIC))
85 { 96 {
97 req.type = htonl (req.type);
98
86 if (req.type < 2) 99 if (req.type < 2)
87 { 100 {
88 u64 from = ntohll (req.from); 101 u64 from = ntohll (req.from);
89 102
90 PUSHMARK (SP); 103 PUSHMARK (SP);
103 } 116 }
104 } 117 }
105 } 118 }
106 119
107 XSRETURN_YES; 120 XSRETURN_YES;
121}
108 122
109SV * 123SV *
110_format_reply (SV *handle, unsigned int error = 0, SV *data = 0) 124_format_reply (SV *handle, unsigned int error = 0, SV *data = 0)
111 CODE: 125 CODE:
126{
112 struct nbd_reply rep; 127 struct nbd_reply rep;
113 STRLEN len; 128 STRLEN len;
114 char *h = SvPV (handle, len); 129 char *h = SvPV (handle, len);
115 130
116 if (len != sizeof (rep.handle)) 131 if (len != sizeof (rep.handle))
122 137
123 RETVAL = newSVpvn ((char *)&rep, sizeof (rep)); 138 RETVAL = newSVpvn ((char *)&rep, sizeof (rep));
124 139
125 if (data && !error) 140 if (data && !error)
126 sv_catsv (RETVAL, data); 141 sv_catsv (RETVAL, data);
127 142}
128 OUTPUT: 143 OUTPUT:
129 RETVAL 144 RETVAL
130 145

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines