[PATCH] read drive serial number

David Zeuthen david at fubar.dk
Sun Aug 1 16:44:09 PDT 2004


On Sun, 2004-08-01 at 22:49 +0200, Kay Sievers wrote:
> > At this point, I think the only case that remains to be solved are
> > volumes missing both label and UUID - this is especially true for e.g.
> > swap partitions. 
> 
> Should we use the parent udi and the partition number or the starting
> disk block for the udi composing?
> 

Good question. It also raises some issues we should probably fix
beforehand :-)

First, for non-removable media parent udi + partition number sounds like
a good idea.

Second, for removable media we ideally want the UDI to be totally
independent of the drive and this we achieve today with your UUID and
label work. When we lack either, I remembered that Alexander Larsson was
suggesting to perhaps use an MD5 of the first few sectors (ideally the
partition table), but what if the media doesn't have a partition table? 

Which reminds me; today we use heuristics (like is it a floppy or an
optical drive; looking at Linux driver names, ugghh) to determine if the
media uses partitions (the property block.no_partitions), that's a bit
sketchy. 

I say it's sketchy, because is it a property of the drive or a property
of the media? I say, it's the latter and that's why the property is in
the block.* namespace (hence we can set it when we discover the drive)
and not the storage namespace (which is assumed to be constant). But the
way we set it today is by looking at the drive. 

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. 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.

On the other hand, can I make a partition table on a floppy disk and
have partitions /dev/sda1, /dev/sda2 appearing when inserting said
floppy disk in my USB floppy drive which is /dev/sda? What will happen
when inserting this into a legacy floppy drive, e.g. /dev/hda?

Oh, and determining whether media is removable or not is difficult
enough as is cf. the buggy USB drives, and it's not quite right the way
we do it today (my 6in1 drives shows up with storage.removable set to
FALSE). In fact, and I think you sent me that in private, this has been
solved in the kernel by sysfs exporting a file removable like this

 http://linus.bkbits.net:8080/linux-2.5/cset@1.1784.15.8 

so we should probably read that sysfs file and if it's not there just
assume removable media. Of course, the only got merged into mainline
like two weeks ago so we'll probably have to wait a bit :-/

So many questions for dealing with the varying kernel interfaces, I'm
just making notes :-)

> Attached is a trivial cleanup of the enum names, cause 'ALL' is not a very
> good name in a global namespace. I've prepended the libname to all names.

Thanks, committed!

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



More information about the Hal mailing list