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.8 by root, Tue May 30 01:07:29 2017 UTC vs.
Revision 1.9 by root, Tue May 30 03:58:30 2017 UTC

87{ 87{
88 struct rstate *s; 88 struct rstate *s;
89 u64 from; 89 u64 from;
90 u32 len; 90 u32 len;
91 char *method; 91 char *method;
92 int cmd;
92 MAGIC *mg = mg_find (SvRV (obj), PERL_MAGIC_ext); 93 MAGIC *mg = mg_find (SvRV (obj), PERL_MAGIC_ext);
93 94
94 if (!mg) 95 if (!mg)
95 { 96 {
96 mg = sv_magicext (SvRV (obj), 0, PERL_MAGIC_ext, 0, 0, 0); 97 mg = sv_magicext (SvRV (obj), 0, PERL_MAGIC_ext, 0, 0, 0);
123 if (s->req.magic != htonl (NBD_REQUEST_MAGIC)) 124 if (s->req.magic != htonl (NBD_REQUEST_MAGIC))
124 croak ("Linux::NBD::Server received illegal request magic %08lx - protocol error.\n", ntohl (s->req.magic)); 125 croak ("Linux::NBD::Server received illegal request magic %08lx - protocol error.\n", ntohl (s->req.magic));
125 126
126 from = ntohll (s->req.from); 127 from = ntohll (s->req.from);
127 len = ntohl (s->req.len); 128 len = ntohl (s->req.len);
129 cmd = ntohl (s->req.type) & NBD_CMD_MASK_COMMAND;
128 130
129 switch (ntohl (s->req.type)) 131 switch (cmd)
130 { 132 {
131 case NBD_CMD_WRITE: 133 case NBD_CMD_WRITE:
132 if (!mg->mg_obj) 134 if (!mg->mg_obj)
133 { 135 {
134 mg->mg_flags |= MGf_REFCOUNTED; 136 mg->mg_flags |= MGf_REFCOUNTED;
174 method = "req_write"; 176 method = "req_write";
175 } 177 }
176 else 178 else
177 { 179 {
178 PUSHs (sv_2mortal (newSVuv (len))); 180 PUSHs (sv_2mortal (newSVuv (len)));
179 method = s->req.type == NBD_CMD_READ ? "req_read" 181 method = cmd == NBD_CMD_READ ? "req_read"
180 : s->req.type == NBD_CMD_FLUSH ? "req_flush" 182 : cmd == NBD_CMD_FLUSH ? "req_flush"
181 : s->req.type == NBD_CMD_TRIM ? "req_trim" 183 : cmd == NBD_CMD_TRIM ? "req_trim"
182 : s->req.type == NBD_CMD_WRITE_ZEROES ? "req_write_zeroes" 184 : cmd == NBD_CMD_WRITE_ZEROES ? "req_write_zeroes"
183 : (abort (), ""); 185 : (abort (), "");
184 } 186 }
185 187
186 break; 188 break;
187 189

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines