On Wed, Aug 27, 2008 at 12:40:54AM -0400, Theodore Tso wrote: > > I think we can ignore this minor problem for now. I'll try to found a > > better solution for dependencies resolution without libdevmapper. My > > wish is to avoid libdevmapper in libfsprobe. > > Here's a patch that I've been working on which gives a priority bonus > to dm leaf devices, without needing libdevmapper. As I've mentioned > before, I'm not 100% convinced this is always the right thing. But > it's probably a not-half-bad hueristic... [...] > > +static int is_dm_leaf(const char *devname) > +{ > + struct dirent *de, *d_de; > + DIR *dir, *d_dir; > + char path[256]; > + int ret = 1; > + > + if ((dir = opendir("/sys/block")) == NULL) > + return 0; > + while ((de = readdir(dir)) != NULL) { > + if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..") || > + !strcmp(de->d_name, devname) || > + strncmp(de->d_name, "dm-", 3) || > + strlen(de->d_name) > sizeof(path)-32) > + continue; > + sprintf(path, "/sys/block/%s/slaves", de->d_name); > + if ((d_dir = opendir(path)) == NULL) > + continue; > + while ((d_de = readdir(d_dir)) != NULL) { > + if (!strcmp(d_de->d_name, devname)) { > + ret = 0; > + break; > + } > + } > + closedir(d_dir); > + if (!ret) > + break; > + } > + closedir(dir); > + return ret; > +} Seems good. This patch and the brute-force for conversion from dm-N to real names is the way how replace the HAVE_DEVMAPPER crap in libblkid. Thanks! Karel -- Karel Zak <kzak@xxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html