Re: Can udev match on metadata from the partition table map itself?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2009-08-07 at 14:35 -0700, James Cheng wrote:
> Hi,
> 
> I have system using the Apple Partition Map partition table, instead of the
> DOS-style Master Boot Record partition table format. The Apple Partition Map
> table has some metadata for each partition, regardless of the partition type.
> One of those pieces of metadata is the "partition name".
> 
> I have an ext2 filesystem  on one of the partitions. Ext2 itself has the
> concept of filesystem names.
> 
> I want to have a rule that matches against the name in the Apple Partition Map,
> rather than one that matches against the ext2 filesystem name.
> 
> Is there any easy way to do this? I can think of some ugly hack, by running a
> PROGRAM to set some variables with the name from the partition map, and then
> matching against those. Any ideas for alternatives?

DeviceKit-disks ships with a prober to do this since it is needed for
most disk utility programs. The prober currently supports Apple
Partition Map, Master Boot Record and GUID Partition Tables, see [1] for
output. It's GPL and the source is here

http://cgit.freedesktop.org/DeviceKit/DeviceKit-disks/tree/src/part-id.c

For performance reasons this program specifically avoids using libparted
for probing - this is because libparted likes to open all your block
devices and that kind of behavior is never ever going to work if you
want to run the program from an udev rule.

Anyway, I believe the long term plan is to teach libblkid about probing
for partition tables... that's why I never got to clean up the rather
ugly code that currently does this.

Hope this helps.

     David

[1] : # for i in /dev/sd[abc]* ; do echo "----- Device $i:"; (udevadm
info -q all -n $i |grep DKD_PARTITION); echo ""; done

----- Device /dev/sda:
E: DKD_PARTITION_TABLE=1
E: DKD_PARTITION_TABLE_SCHEME=mbr

----- Device /dev/sda1:
E: DKD_PARTITION=1
E: DKD_PARTITION_SCHEME=mbr
E: DKD_PARTITION_NUMBER=1
E: DKD_PARTITION_TYPE=0x83
E: DKD_PARTITION_SIZE=32218389504
E: DKD_PARTITION_FLAGS=boot

----- Device /dev/sdb:
E: DKD_PARTITION_TABLE=1
E: DKD_PARTITION_TABLE_SCHEME=gpt

----- Device /dev/sdb1:
E: DKD_PARTITION=1
E: DKD_PARTITION_SCHEME=gpt
E: DKD_PARTITION_NUMBER=1
E: DKD_PARTITION_TYPE=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
E: DKD_PARTITION_SIZE=199982592
E: DKD_PARTITION_LABEL=A Partition Label
E: DKD_PARTITION_UUID=3202CF41-E9D1-47D8-A841-CBBA8A707B2C

----- Device /dev/sdc:
E: DKD_PARTITION_TABLE=1
E: DKD_PARTITION_TABLE_SCHEME=apm

----- Device /dev/sdc1:
E: DKD_PARTITION=1
E: DKD_PARTITION_SCHEME=apm
E: DKD_PARTITION_NUMBER=1
E: DKD_PARTITION_TYPE=Apple_partition_map
E: DKD_PARTITION_SIZE=32256
E: DKD_PARTITION_LABEL=Apple

----- Device /dev/sdc2:
E: DKD_PARTITION=1
E: DKD_PARTITION_SCHEME=apm
E: DKD_PARTITION_NUMBER=2
E: DKD_PARTITION_TYPE=Apple_UNIX_SVR2
E: DKD_PARTITION_SIZE=967680
E: DKD_PARTITION_LABEL=PartitionLabel
E: DKD_PARTITION_FLAGS=allocated allow_read allow_write


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

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux