From: Christophe Varoqui Date: Sun, 18 Nov 2007 18:01:15 +0000 (+0100) Subject: [libmultipath] fix "show devices" CLI command X-Git-Tag: 0.4.9~251 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=896c99b30ff4e0c7386f615a3e1dba99c31e6d8b;p=platform%2Fupstream%2Fmultipath-tools.git [libmultipath] fix "show devices" CLI command Whatever this command was intented to do, it did not. I still don't see the usefulness, but now it displays : ... sdf devnode whitelisted, monitored sdb devnode whitelisted, unmonitored sda devnode whitelisted, unmonitored ram15 devnode blacklisted, unmonitored ... --- diff --git a/libmultipath/print.c b/libmultipath/print.c index 01a157a..9ac5cc0 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -1118,15 +1118,16 @@ snprint_devices (char * buff, int len, struct vectors *vecs) return len; fwd += snprintf(buff + fwd, len - fwd, "available block devices:\n"); - strcpy(devpath,"/sys/block"); - devptr = devpath + 10; + strcpy(devpath,"/sys/block/"); while ((blkdev = readdir(blkdir)) != NULL) { if ((strcmp(blkdev->d_name,".") == 0) || (strcmp(blkdev->d_name,"..") == 0)) continue; - strcat(devptr,blkdev->d_name); - if (stat(devptr, &statbuf) < 0) + devptr = devpath + 11; + *devptr = '\0'; + strncat(devptr, blkdev->d_name, PATH_MAX-12); + if (stat(devpath, &statbuf) < 0) continue; if (S_ISDIR(statbuf.st_mode) == 0) @@ -1135,18 +1136,20 @@ snprint_devices (char * buff, int len, struct vectors *vecs) if ((len - fwd - threshold) <= 0) return len; - fwd += snprintf(buff + fwd, len - fwd, " %s", devpath); - pp = find_path_by_dev(vecs->pathvec, devpath); + fwd += snprintf(buff + fwd, len - fwd, " %s", devptr); + pp = find_path_by_dev(vecs->pathvec, devptr); if (!pp) { r = filter_devnode(conf->blist_devnode, - conf->elist_devnode, devpath); + conf->elist_devnode, devptr); if (r > 0) fwd += snprintf(buff + fwd, len - fwd, - " (blacklisted)"); + " devnode blacklisted, unmonitored"); else if (r < 0) fwd += snprintf(buff + fwd, len - fwd, - " (whitelisted)"); - } + " devnode whitelisted, unmonitored"); + } else + fwd += snprintf(buff + fwd, len - fwd, + " devnode whitelisted, monitored"); fwd += snprintf(buff + fwd, len - fwd, "\n"); } closedir(blkdir);