lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 27 Aug 2008 10:32:52 +0200
From:	Karel Zak <kzak@...hat.com>
To:	Theodore Tso <tytso@....edu>
Cc:	linux-ext4@...r.kernel.org, Eric Sandeen <sandeen@...hat.com>,
	mbroz@...hat.com, agk@...hat.com
Subject: Re: [PATCH] blkid: optimize dm_device_is_leaf() usage

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@...hat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists