From 965c7ff9a9d64bb53dd7a808f3193b36ab7b014d Mon Sep 17 00:00:00 2001 From: sr Date: Sat, 25 Aug 2012 16:14:20 +0200 Subject: [*] Fix bug in serializer_get_* [CLIENT/KERNEL] Change ioctl to handle volume names instead if vids [*] Make protocol endian safe [CLIENT] Display ioctl errorcode on failure --- src/client/client.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/client') diff --git a/src/client/client.c b/src/client/client.c index a48cab9..86b7cb9 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) break; case 'h': dnbd3_get_ip(optarg, msg.addr, &msg.addrtype); - printf("Host set to %s (type %d)\n", optarg, (int)msg.addrtype); + printf("Host set to %s (type %d)\n", inet_ntoa(*(struct in_addr*)msg.addr), (int)msg.addrtype); break; case 'i': msg.imgname = strdup(optarg); @@ -166,9 +166,10 @@ int main(int argc, char *argv[]) fd = open(dev, O_WRONLY); printf("INFO: Closing device %s\n", dev); - if (ioctl(fd, IOCTL_CLOSE, &msg) < 0) + const int ret = ioctl(fd, IOCTL_OPEN, &msg); + if (ret < 0) { - printf("ERROR: ioctl not successful (close)\n"); + printf("ERROR: ioctl not successful (close, errcode: %d)\n", ret); exit(EXIT_FAILURE); } @@ -199,9 +200,10 @@ int main(int argc, char *argv[]) fd = open(dev, O_WRONLY); printf("INFO: Connecting %s to %s (%s rid:%i)\n", dev, "", msg.imgname, msg.rid); - if (ioctl(fd, IOCTL_OPEN, &msg) < 0) + const int ret = ioctl(fd, IOCTL_OPEN, &msg); + if (ret < 0) { - printf("ERROR: ioctl not successful (connect)\n"); + printf("ERROR: ioctl not successful (connect, errcode: %d)\n", ret); exit(EXIT_FAILURE); } @@ -235,9 +237,10 @@ int main(int argc, char *argv[]) fd = open(dev, O_WRONLY); printf("INFO: Connecting %s to %s (%s rid:%i)\n", dev, "", msg.imgname, msg.rid); - if (ioctl(fd, IOCTL_OPEN, &msg) < 0) + const int ret = ioctl(fd, IOCTL_OPEN, &msg); + if (ret < 0) { - printf("ERROR: ioctl not successful (connect)\n"); + printf("ERROR: ioctl not successful (config file, errcode: %d)\n", ret); exit(EXIT_FAILURE); } -- cgit v1.2.3-55-g7522