Mailinglist Archive: opensuse-factory (396 mails)

< Previous Next >
[opensuse-factory] rdev missing from util-linux in factory / thumbleweed
cc: Adding opensuse-factory

On Fri, Jan 14, 2011 at 10:26 PM, Mark Lord <mlord@xxxxxxxxx> wrote:
On 11-01-12 12:32 PM, Greg Freemyer wrote:

Mark,

I just got a problem report about wiper.sh needing /usr/sbin/rdev.

That seems to have been deprecated for a while.  Googling
"usr/sbin/rdev" I see the same issue raised for several distros.

Are you working on a hdparm update / patch to address that?

Thus far it seems to only be an issue on the Redhat RPM based distros,
eg. Fedora and Suse.  Most others still have rdev.

Ideally, I'd like to remove the dependency, as even when rdev is present
it does not always return useful info (eg. "/dev/root" is NOT useful).

But I have yet to figure out what to replace it with.
Depending upon non-kernel files (eg. /etc/mtab) is not wise here,
because any screw-up means total loss of the user's root partition.

Any idea how to determine the underlying device number (major,minor)
for the root filesystem ?


==> Johannes
You must be getting util-linux from Tumbleweed or factory which is
why your missing rdev.

==> Mark,

rdev was removed from util-linux in May 2010. Apparently it is in
openSUSE 11.3, but not in current openSUSE factory code which will be
released as openSUSE 11.4 in March. I assume you will have repeated
issues with all new distros if you depend on rdev.

see http://www.spinics.net/lists/util-linux-ng/msg03170.html

It should be easy enough for openSUSE to patch rdev back into
util-linux, but it seems like the wrong solution.

The key code is fairly small:
stat("/",&s);
printf("%s /\n", find_dev(s.st_dev));

Where find_dev() is:
===
/* Earlier rdev fails on /dev/ida/c0d0p1 so we allow for
recursion in /dev. -- Paul Clements */
/* In fact devfs needs deep recursion. */

static int
find_dev_recursive(char *dirnamebuf, int number) {
DIR *dp;
struct dirent *dir;
struct stat s;
int dirnamelen = 0;

if ((dp = opendir(dirnamebuf)) == NULL)
die("opendir");
dirnamelen = strlen(dirnamebuf);
while ((dir = readdir(dp)) != NULL) {
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
if (dirnamelen + 1 + strlen(dir->d_name) > PATH_MAX)
continue;
dirnamebuf[dirnamelen] = '/';
strcpy(dirnamebuf+dirnamelen+1, dir->d_name);
if (lstat(dirnamebuf, &s) < 0)
continue;
if ((s.st_mode & S_IFMT) == S_IFBLK && s.st_rdev == number)
return 1;
if ((s.st_mode & S_IFMT) == S_IFDIR &&
find_dev_recursive(dirnamebuf, number))
return 1;
}
dirnamebuf[dirnamelen] = 0;
closedir(dp);
return 0;
}

static char *
find_dev(int number) {
static char name[PATH_MAX+1];

if (!number)
return "Boot device";
strcpy(name, "/dev");
if (find_dev_recursive(name, number))
return name;
sprintf(name, "0x%04x", number);
return name;
}
===
If you need to depend on it, maybe you need to add the above logic to
hdparm (or create a small standalone utility inside your package)?

What is your suggestion for openSUSE. Wait for you to eliminate the
need for rdev from hdparm (wiper.sh), or patch it back into util-linux
for now?

Greg
--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-factory+help@xxxxxxxxxxxx

< Previous Next >
This Thread