if (read(sock, &magic, sizeof(magic)) < 0)
err("Failed/2: %m");
magic = ntohll(magic);
- if (magic != cliserv_magic)
- err("Not enough cliserv_magic");
- printf(".");
if(name) {
uint32_t opt;
uint64_t namesize;
uint64_t reserved = 0;
+ if (magic != opts_magic)
+ err("Not enough opts_magic");
+ printf(".");
if(read(sock, &tmp, sizeof(uint16_t)) < 0) {
err("Failed reading flags: %m");
}
namesize = ntohll(namesize);
write(sock, &namesize, sizeof(namesize));
write(sock, name, strlen(name));
+ } else {
+ if (magic != cliserv_magic)
+ err("Not enough cliserv_magic");
+ printf(".");
}
if (read(sock, &size64, sizeof(size64)) < 0)
} else {
fprintf(stderr, "nbd-client version %s\n", PACKAGE_VERSION);
}
- fprintf(stderr, "Usage: nbd-client host port nbd_device [-block-size|-b block size] [-timeout|-t timeout] [-swap|-s] [-sdp|-S] [-persist|-p] [-nofork|-n]\n");
+ fprintf(stderr, "Usage: nbd-client host port nbd_device [-block-size|-b block size] [-timeout|-t timeout] [-swap|-s] [-sdp|-S] [-persist|-p] [-nofork|-n] [-name|-N name]\n");
fprintf(stderr, "Or : nbd-client -d nbd_device\n");
fprintf(stderr, "Or : nbd-client -c nbd_device\n");
fprintf(stderr, "Or : nbd-client -h|--help\n");
uint64_t size_host;
uint32_t flags = NBD_FLAG_HAS_FLAGS;
uint16_t smallflags = 0;
+ uint64_t magic;
memset(zeros, '\0', sizeof(zeros));
if(!client || !client->modern) {
if(client)
exit(EXIT_FAILURE);
}
- cliserv_magic = htonll(cliserv_magic);
- if (write(net, &cliserv_magic, sizeof(cliserv_magic)) < 0) {
+ magic = htonll(opts_magic);
+ if (write(net, &magic, sizeof(magic)) < 0) {
err_nonfatal("Negotiation failed: %m");
if(client)
exit(EXIT_FAILURE);
}
if(!client) {
uint64_t reserved;
- uint64_t magic;
uint32_t opt;
uint64_t namelen;
char* name;