Hopefully resolved the byte order issues.
This commit is contained in:
parent
595c02ce48
commit
552256907e
30
abuse.c
30
abuse.c
|
@ -13,6 +13,24 @@
|
||||||
|
|
||||||
#include "abuse.h"
|
#include "abuse.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These helper functions were taken from cliserv.h in the nbd distribution.
|
||||||
|
*/
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
u_int64_t ntohll(u_int64_t a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
u_int64_t ntohll(u_int64_t a) {
|
||||||
|
u_int32_t lo = a & 0xffffffff;
|
||||||
|
u_int32_t hi = a >> 32U;
|
||||||
|
lo = ntohl(lo);
|
||||||
|
hi = ntohl(hi);
|
||||||
|
return ((u_int64_t) lo) << 32U | hi;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#define htonll ntohll
|
||||||
|
|
||||||
int abuse_main(int argc, char *argv[], const struct abuse_operations *aop, void *userdata)
|
int abuse_main(int argc, char *argv[], const struct abuse_operations *aop, void *userdata)
|
||||||
{
|
{
|
||||||
int sp[2];
|
int sp[2];
|
||||||
|
@ -72,9 +90,8 @@ int abuse_main(int argc, char *argv[], const struct abuse_operations *aop, void
|
||||||
assert(bytes_read == sizeof(request));
|
assert(bytes_read == sizeof(request));
|
||||||
memcpy(reply.handle, request.handle, sizeof(reply.handle));
|
memcpy(reply.handle, request.handle, sizeof(reply.handle));
|
||||||
|
|
||||||
/* FIXME: these might need conversion from the network byte order. */
|
|
||||||
len = ntohl(request.len);
|
len = ntohl(request.len);
|
||||||
from = request.from;
|
from = ntohll(request.from);
|
||||||
(void) from;
|
(void) from;
|
||||||
assert(request.magic == htonl(NBD_REQUEST_MAGIC));
|
assert(request.magic == htonl(NBD_REQUEST_MAGIC));
|
||||||
|
|
||||||
|
@ -88,8 +105,13 @@ int abuse_main(int argc, char *argv[], const struct abuse_operations *aop, void
|
||||||
/* assert(bytes_written == len + sizeof(struct nbd_reply)); */
|
/* assert(bytes_written == len + sizeof(struct nbd_reply)); */
|
||||||
free(chunk);
|
free(chunk);
|
||||||
break;
|
break;
|
||||||
default:
|
case NBD_CMD_WRITE:
|
||||||
/* We'll not worry about the other cases for now. */
|
break;
|
||||||
|
case NBD_CMD_DISC:
|
||||||
|
break;
|
||||||
|
case NBD_CMD_FLUSH:
|
||||||
|
break;
|
||||||
|
case NBD_CMD_TRIM:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
abuse.h
3
abuse.h
|
@ -13,6 +13,7 @@ struct abuse_operations {
|
||||||
u_int64_t size;
|
u_int64_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
int abuse_main(int argc, char *argv[], const struct abuse_operations *aop, void *userdata);
|
int abuse_main(int argc, char *argv[], const struct abuse_operations *aop,
|
||||||
|
void *userdata);
|
||||||
|
|
||||||
#endif /* ABUSE_H_INCLUDED */
|
#endif /* ABUSE_H_INCLUDED */
|
||||||
|
|
Loading…
Reference in New Issue