From: Wouter Verhelst Date: Mon, 8 Jun 2009 21:15:46 +0000 (+0200) Subject: Don't try working on partitions X-Git-Url: http://git.alex.org.uk Don't try working on partitions When a partition is given to the -d or -c command line options, reduce it to the master device instead. This assumes udev-style naming of device entries, though. --- diff --git a/nbd-client.c b/nbd-client.c index 913af90..80dc816 100644 --- a/nbd-client.c +++ b/nbd-client.c @@ -41,11 +41,16 @@ int check_conn(char* devname, int do_print) { char buf[256]; + char* p; int fd; int len; if(!strncmp(devname, "/dev/", 5)) { devname+=5; } + if((p=strchr(devname, 'p'))) { + /* We can't do checks on partitions. */ + *p='\0'; + } snprintf(buf, 256, "/sys/block/%s/pid", devname); if((fd=open(buf, O_RDONLY))<0) { if(errno==ENOENT) {