Added .INCOMPLETE hack to aid with marking finished transfers.
This commit is contained in:
@@ -92,6 +92,9 @@ void params_serve(
|
|||||||
out->bind_to.v4.sin_port = htobe16(out->bind_to.v4.sin_port);
|
out->bind_to.v4.sin_port = htobe16(out->bind_to.v4.sin_port);
|
||||||
|
|
||||||
out->filename = s_file;
|
out->filename = s_file;
|
||||||
|
out->filename_incomplete = xmalloc(strlen(s_file)+11);
|
||||||
|
strcpy(out->filename_incomplete, s_file);
|
||||||
|
strcpy(out->filename_incomplete + strlen(s_file), ".INCOMPLETE");
|
||||||
}
|
}
|
||||||
|
|
||||||
void params_readwrite(
|
void params_readwrite(
|
||||||
|
6
params.h
6
params.h
@@ -38,11 +38,13 @@ struct mode_serve_params {
|
|||||||
int acl_entries;
|
int acl_entries;
|
||||||
/** pointer to access control list entries*/
|
/** pointer to access control list entries*/
|
||||||
struct ip_and_mask (*acl)[0];
|
struct ip_and_mask (*acl)[0];
|
||||||
/** file name to serve */
|
/** (static) file name to serve */
|
||||||
char* filename;
|
char* filename;
|
||||||
|
/** file name of INCOMPLETE flag */
|
||||||
|
char* filename_incomplete;
|
||||||
/** TCP backlog for listen() */
|
/** TCP backlog for listen() */
|
||||||
int tcp_backlog;
|
int tcp_backlog;
|
||||||
/** file name of UNIX control socket (or NULL if none) */
|
/** (static) file name of UNIX control socket (or NULL if none) */
|
||||||
char* control_socket_name;
|
char* control_socket_name;
|
||||||
/** size of file */
|
/** size of file */
|
||||||
off64_t size;
|
off64_t size;
|
||||||
|
@@ -43,9 +43,9 @@ void read_reply(int fd, struct nbd_request *request, struct nbd_reply *reply)
|
|||||||
SERVER_ERROR_ON_FAILURE(readloop(fd, reply, sizeof(*reply)),
|
SERVER_ERROR_ON_FAILURE(readloop(fd, reply, sizeof(*reply)),
|
||||||
"Couldn't read reply");
|
"Couldn't read reply");
|
||||||
if (be32toh(reply->magic) != REPLY_MAGIC)
|
if (be32toh(reply->magic) != REPLY_MAGIC)
|
||||||
SERVER_ERROR("Reply magic incorrect (%p)", reply->magic);
|
SERVER_ERROR("Reply magic incorrect (%p)", be32toh(reply->magic));
|
||||||
if (be32toh(reply->error) != 0)
|
if (be32toh(reply->error) != 0)
|
||||||
SERVER_ERROR("Server replied with error %d", reply->error);
|
SERVER_ERROR("Server replied with error %d", be32toh(reply->error));
|
||||||
if (strncmp(request->handle, reply->handle, 8) != 0)
|
if (strncmp(request->handle, reply->handle, 8) != 0)
|
||||||
SERVER_ERROR("Did not reply with correct handle");
|
SERVER_ERROR("Did not reply with correct handle");
|
||||||
}
|
}
|
||||||
|
6
serve.c
6
serve.c
@@ -167,6 +167,12 @@ int client_serve_request(struct client_params* client)
|
|||||||
switch (be32toh(request.type))
|
switch (be32toh(request.type))
|
||||||
{
|
{
|
||||||
case REQUEST_READ:
|
case REQUEST_READ:
|
||||||
|
if (access(client->serve->filename_incomplete, F_OK) == 0 ) {
|
||||||
|
debug("read request while data incomplete");
|
||||||
|
reply.error = htobe32(10);
|
||||||
|
write(client->socket, &reply, sizeof(reply));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case REQUEST_WRITE:
|
case REQUEST_WRITE:
|
||||||
/* check it's not out of range */
|
/* check it's not out of range */
|
||||||
if (be64toh(request.from) < 0 ||
|
if (be64toh(request.from) < 0 ||
|
||||||
|
Reference in New Issue
Block a user