[PATCH] read drive serial number

Kay Sievers kay.sievers at vrfy.org
Mon Aug 2 05:11:49 PDT 2004


On Mon, 2004-08-02 at 02:55 +0200, David Zeuthen wrote:
> On Mon, 2004-08-02 at 01:44 +0200, David Zeuthen wrote:
> > In other words, is it feasible to format, say, a USB thumbdrive with a
> > FAT filesystem on the main block device, e.g. /dev/sda? Or is it after
> > all, a (constant) property of the drive? I think it is not.
> 
> I just tried this, I can indeed format my USB drive to have a msdos
> filesystem at /dev/sda and happily mount it /dev/sda (not that mkfs(8)
> was particular helpful, but there are tricks). Now to teach HAL to do
> the same :-)
> 
> >  Perhaps,
> > maybe, one solution is to simply see if the main block device got a
> > valid partition table? In fact, the kernel knows this, it reads the
> > partition tables; it should export it through sysfs.
> 
> It might be easier to put in some partition table detect code ourselves
> in HAL - would be more portable as well. 

Yes, I can do this. But the kernel scans the main device for any known
partition table and creates subdevices if it finds volumes described by
any patition table.
Isn't it enough to watch if the kernel has creates sub devices for the
main device. If we get a hda1 or a sda1, we can be sure, that there is a
valid partition table on the disk.

> In fact what we need is just the "negative filter", e.g. being able to
> say this raw disk doesn't appear to have any known partition schemes
> (within reasonable definitions of known), rather than fully identifying
> every detail with a given partitioning scheme (cause if the disk is
> already partitioned the kernel will need to deal with this anyway). 
> 
> Btw, here is an interesting page
> 
>  http://disktype.sourceforge.net/

Yes, this was my starting point for the HFS code, but disktype uses
magic offset values and hard coded numbers for reading the values, so
one can't understand, what's going on. Later, I found the apple darwin
tools :)

Kay

_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list