public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Theodore Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, Eric Sandeen <sandeen@redhat.com>,
	mbroz@redhat.com, agk@redhat.com
Subject: Re: [PATCH] blkid: optimize dm_device_is_leaf() usage
Date: Wed, 27 Aug 2008 10:32:52 +0200	[thread overview]
Message-ID: <20080827083252.GP6029@nb.net.home> (raw)
In-Reply-To: <20080827044054.GE29936@mit.edu>

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@redhat.com>

  reply	other threads:[~2008-08-27  8:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-25 20:48 [PATCH] blkid: optimize dm_device_is_leaf() usage Karel Zak
2008-08-26 12:24 ` Theodore Tso
2008-08-26 13:51   ` Karel Zak
2008-08-26 14:47     ` Theodore Tso
2008-08-26 18:04       ` Theodore Tso
2008-08-26 19:44       ` Andreas Dilger
2008-08-26 20:00         ` Theodore Tso
2008-08-26 20:47       ` Karel Zak
2008-08-26 23:32         ` Theodore Tso
2008-08-27  0:19           ` Karel Zak
2008-08-27  1:21             ` Theodore Tso
2008-08-27  4:40               ` Theodore Tso
2008-08-27  8:32                 ` Karel Zak [this message]
2008-08-27  7:26             ` Andreas Dilger
2008-08-27  8:10               ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080827083252.GP6029@nb.net.home \
    --to=kzak@redhat.com \
    --cc=agk@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mbroz@redhat.com \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox