Don't try working on partitions
authorWouter Verhelst <w@uter.be>
Mon, 8 Jun 2009 21:15:46 +0000 (23:15 +0200)
committerWouter Verhelst <w@uter.be>
Mon, 8 Jun 2009 21:15:46 +0000 (23:15 +0200)
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.

nbd-client.c

index 913af90..80dc816 100644 (file)
 
 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) {