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.7 by root, Tue Sep 21 11:51:55 2010 UTC vs.
Revision 1.8 by root, Tue May 30 01:07:29 2017 UTC

10#include <netinet/in.h> 10#include <netinet/in.h>
11#include <byteswap.h> 11#include <byteswap.h>
12 12
13typedef uint32_t u32; 13typedef uint32_t u32;
14typedef uint64_t u64; 14typedef uint64_t u64;
15#include <linux/nbd.h> 15#include "nbd.h"
16 16
17#if __BYTE_ORDER == __BIG_ENDIAN 17#if __BYTE_ORDER == __BIG_ENDIAN
18#define ntohll(netlong) (netlong) 18#define ntohll(netlong) (netlong)
19#elif __BYTE_ORDER == __LITTLE_ENDIAN 19#elif __BYTE_ORDER == __LITTLE_ENDIAN
20#define ntohll(netlong) __bswap_64(netlong) 20#define ntohll(netlong) __bswap_64(netlong)
55 CODE: 55 CODE:
56 ioctl (dev, NBD_DISCONNECT); 56 ioctl (dev, NBD_DISCONNECT);
57 57
58void 58void
59_clear_sock (int dev) 59_clear_sock (int dev)
60 ALIAS:
61 _clear_sock = NBD_CLEAR_SOCK
62 _clear_que = NBD_CLEAR_QUE
60 CODE: 63 CODE:
61 ioctl (dev, NBD_CLEAR_SOCK); 64 ioctl (dev, ix);
62 65
63void 66void
64_clear_que (int dev)
65 CODE:
66 ioctl (dev, NBD_CLEAR_QUE);
67
68void
69_set_blksize (int dev, unsigned long blocksize)
70 CODE:
71 ioctl (dev, NBD_SET_BLKSIZE, blocksize);
72
73void
74_set_size (int dev, unsigned long size) 67_set_blksize (int dev, unsigned long arg)
68 ALIAS:
69 _set_blksize = NBD_SET_BLKSIZE
70 _set_size = NBD_SET_SIZE
71 _set_size_blocks = NBD_SET_SIZE_BLOCKS
72 _set_timeout = NBD_SET_TIMEOUT
73 _set_flags = NBD_SET_FLAGS
75 CODE: 74 CODE:
76 ioctl (dev, NBD_SET_SIZE, size); 75 ioctl (dev, ix, arg);
77
78void
79_set_size_blocks (int dev, unsigned long nblocks)
80 CODE:
81 ioctl (dev, NBD_SET_SIZE_BLOCKS, nblocks);
82
83void
84_set_timeout (int dev, unsigned long timeout)
85 CODE:
86 ioctl (dev, NBD_SET_TIMEOUT, timeout);
87 76
88void 77void
89_print_debug (int dev) 78_print_debug (int dev)
90 CODE: 79 CODE:
91 ioctl (dev, NBD_PRINT_DEBUG, 0); 80 ioctl (dev, NBD_PRINT_DEBUG, 0);
163 XSRETURN_NO; 152 XSRETURN_NO;
164 } 153 }
165 154
166 /* fallthrough */ 155 /* fallthrough */
167 case NBD_CMD_READ: 156 case NBD_CMD_READ:
157 case NBD_CMD_FLUSH:
158 case NBD_CMD_TRIM:
159 case NBD_CMD_WRITE_ZEROES:
168 s->req_read = 0; 160 s->req_read = 0;
169 161
170 PUSHMARK (SP); 162 PUSHMARK (SP);
171 EXTEND (SP, 4); 163 EXTEND (SP, 4);
172 PUSHs (obj); 164 PUSHs (obj);
182 method = "req_write"; 174 method = "req_write";
183 } 175 }
184 else 176 else
185 { 177 {
186 PUSHs (sv_2mortal (newSVuv (len))); 178 PUSHs (sv_2mortal (newSVuv (len)));
187 method = "req_read"; 179 method = s->req.type == NBD_CMD_READ ? "req_read"
180 : s->req.type == NBD_CMD_FLUSH ? "req_flush"
181 : s->req.type == NBD_CMD_TRIM ? "req_trim"
182 : s->req.type == NBD_CMD_WRITE_ZEROES ? "req_write_zeroes"
183 : (abort (), "");
188 } 184 }
189 185
190 break; 186 break;
191 187
192 case NBD_CMD_DISC: 188 case NBD_CMD_DISC:
227 223
228 RETVAL = newSVpvn ((char *)&rep, sizeof (rep)); 224 RETVAL = newSVpvn ((char *)&rep, sizeof (rep));
229 225
230 if (data && !error) 226 if (data && !error)
231 sv_catsv (RETVAL, data); 227 sv_catsv (RETVAL, data);
232} 228}
233 OUTPUT: 229 OUTPUT:
234 RETVAL 230 RETVAL
235 231

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines