getting /dev/<DEVICE> from (MAJOR, minor)

From: Benoît Dejean
Date: Mon Jul 05 2004 - 13:08:14 EST


(sorry for my english)
(sorry if this is not the good place to ask, but i didn't get any anwser
on comp.os.linux.development.system)

Hi, i'd like to retrieve iostats from /sys in a userspace program. My
library has a function fsusage(mount_point) which is implemented using
statvfs(), etc. I'd like to extend it to provide information described
in linux/documentation/iostats.txt : read/write sectors (? the
documentation doesn't say what is a sector, am i wrong if i assume it's
512B on every arch and filesystem ?).

So i need to know the device name to browse /sys/block to the 'stat'
file. I would like to avoid getmntent() (retrieving the device name from
the mount table). I was thinking about retrieving the (major, minor)
with stat() in order to get the devname. But i didn't find any quick way
to get it (readdir()-ing /dev is stupid, i'd better use getmntent()).

How can i retrieve the devname with its (M, m) ?

I want to avoid getmntent, not for performance issue (should not be
critical) but for internal reasons. Btw, even if i finally read the
mnttab, i'm interested in the answer.

thank you.

--
BenoÃt Dejean
JID: TazForEver@xxxxxxxxxx
http://gdesklets.gnomedesktop.org
http://www.paulla.asso.fr

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/