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.1 by root, Thu May 8 23:43:41 2003 UTC vs.
Revision 1.4 by root, Thu Aug 24 12:13:40 2006 UTC

28_set_sock (int dev, int fd) 28_set_sock (int dev, int fd)
29 CODE: 29 CODE:
30 ioctl (dev, NBD_SET_SOCK, (unsigned long)fd); 30 ioctl (dev, NBD_SET_SOCK, (unsigned long)fd);
31 31
32void 32void
33_doit (int dev, int doexit = 0) 33_doit (int dev, int server = 0)
34 CODE: 34 CODE:
35 if (server)
36 for (server = 0; server < 4095; server++)
37 if (server != dev)
38 close (server);
39
35 ioctl (dev, NBD_DO_IT); 40 ioctl (dev, NBD_DO_IT);
36 if (doexit) 41
42 if (server)
37 _exit (0); 43 _exit (0);
38 44
39void 45void
40_disconnect (int dev) 46_disconnect (int dev)
41 CODE: 47 CODE:
69MODULE = Linux::NBD PACKAGE = Linux::NBD::Server 75MODULE = Linux::NBD PACKAGE = Linux::NBD::Server
70 76
71void 77void
72_one_request (SV *obj, int fd) 78_one_request (SV *obj, int fd)
73 CODE: 79 CODE:
80{
74 struct nbd_request req; 81 struct nbd_request req;
75 82
76 if (read (fd, &req, sizeof (req)) == sizeof (req)) 83 if (read (fd, &req, sizeof (req)) == sizeof (req))
77 { 84 {
78 if (req.magic == htonl (NBD_REQUEST_MAGIC)) 85 if (req.magic == htonl (NBD_REQUEST_MAGIC))
79 { 86 {
87 req.type = htonl (req.type);
88
80 if (req.type < 2) 89 if (req.type < 2)
81 { 90 {
82 u64 from = ntohll (req.from); 91 u64 from = ntohll (req.from);
83 92
84 PUSHMARK (SP); 93 PUSHMARK (SP);
97 } 106 }
98 } 107 }
99 } 108 }
100 109
101 XSRETURN_YES; 110 XSRETURN_YES;
111}
102 112
103SV * 113SV *
104_format_reply (SV *handle, unsigned int error = 0, SV *data = 0) 114_format_reply (SV *handle, unsigned int error = 0, SV *data = 0)
105 CODE: 115 CODE:
116{
106 struct nbd_reply rep; 117 struct nbd_reply rep;
107 STRLEN len; 118 STRLEN len;
108 char *h = SvPV (handle, len); 119 char *h = SvPV (handle, len);
109 120
110 if (len != sizeof (rep.handle)) 121 if (len != sizeof (rep.handle))
116 127
117 RETVAL = newSVpvn ((char *)&rep, sizeof (rep)); 128 RETVAL = newSVpvn ((char *)&rep, sizeof (rep));
118 129
119 if (data && !error) 130 if (data && !error)
120 sv_catsv (RETVAL, data); 131 sv_catsv (RETVAL, data);
121 132}
122 OUTPUT: 133 OUTPUT:
123 RETVAL 134 RETVAL
124 135

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines