Switch from a rake-based build to a make-based build.
This commit beefs up the Makefile to do the build, instead of the Rakefile. It also removes from the Rakefile the dependency on rake_utils, which should mean it's ok to build in a schroot. The files are reorganised to make the Makefile rules more tractable, although the reorganisation reveals a problem with our current code organisation. The problem is that the proxy-specific code transitively depends on the server code via flexnbd.h, which has a circular dependency on the server and client structs. This should be broken in a future commit by separating the flexnbd struct into a shared config struct and server-specific parts, so that the server code can be moved into src/server to more accurately show the functional dependencies.
This commit is contained in:
58
src/common/nbdtypes.c
Normal file
58
src/common/nbdtypes.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "nbdtypes.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
|
||||
|
||||
/**
|
||||
* We intentionally ignore the reserved 128 bytes at the end of the
|
||||
* request, since there's nothing we can do with them.
|
||||
*/
|
||||
void nbd_r2h_init( struct nbd_init_raw * from, struct nbd_init * to )
|
||||
{
|
||||
memcpy( to->passwd, from->passwd, 8 );
|
||||
to->magic = be64toh( from->magic );
|
||||
to->size = be64toh( from->size );
|
||||
}
|
||||
|
||||
void nbd_h2r_init( struct nbd_init * from, struct nbd_init_raw * to)
|
||||
{
|
||||
memcpy( to->passwd, from->passwd, 8 );
|
||||
to->magic = htobe64( from->magic );
|
||||
to->size = htobe64( from->size );
|
||||
}
|
||||
|
||||
|
||||
void nbd_r2h_request( struct nbd_request_raw *from, struct nbd_request * to )
|
||||
{
|
||||
to->magic = htobe32( from->magic );
|
||||
to->type = htobe32( from->type );
|
||||
memcpy( to->handle, from->handle, 8 );
|
||||
to->from = htobe64( from->from );
|
||||
to->len = htobe32( from->len );
|
||||
}
|
||||
|
||||
void nbd_h2r_request( struct nbd_request * from, struct nbd_request_raw * to )
|
||||
{
|
||||
to->magic = be32toh( from->magic );
|
||||
to->type = be32toh( from->type );
|
||||
memcpy( to->handle, from->handle, 8 );
|
||||
to->from = be64toh( from->from );
|
||||
to->len = be32toh( from->len );
|
||||
}
|
||||
|
||||
|
||||
void nbd_r2h_reply( struct nbd_reply_raw * from, struct nbd_reply * to )
|
||||
{
|
||||
to->magic = htobe32( from->magic );
|
||||
to->error = htobe32( from->error );
|
||||
memcpy( to->handle, from->handle, 8 );
|
||||
}
|
||||
|
||||
void nbd_h2r_reply( struct nbd_reply * from, struct nbd_reply_raw * to )
|
||||
{
|
||||
to->magic = be32toh( from->magic );
|
||||
to->error = be32toh( from->error );
|
||||
memcpy( to->handle, from->handle, 8 );
|
||||
}
|
||||
|
Reference in New Issue
Block a user