* Can udev match on metadata from the partition table map itself?
@ 2009-08-07 21:35 James Cheng
2009-08-08 3:12 ` Bryan Kadzban
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: James Cheng @ 2009-08-07 21:35 UTC (permalink / raw)
To: linux-hotplug
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?
-James
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can udev match on metadata from the partition table map itself?
2009-08-07 21:35 Can udev match on metadata from the partition table map itself? James Cheng
@ 2009-08-08 3:12 ` Bryan Kadzban
2009-08-08 20:07 ` David Zeuthen
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Bryan Kadzban @ 2009-08-08 3:12 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]
James Cheng wrote:
> 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?
That "ugly hack" is actually exactly what udev does to find the ext2
filesystem label. (Though it doesn't use PROGRAM, it uses IMPORT. But
either way.) It runs /lib/udev/vol_id in older versions of udev, and
/sbin/blkid (from util-linux-ng >= 2.15) in udev >= 142 or 143 or some
version around there. This program reads the ext2 label from the FS
metadata, and prints it out (along with lots of other values, like the
filesystem's UUID).
See /lib/udev/rules.d/60-persistent-storage.rules for the rule used to
call the program in question.
If the kernel driver for the partition map exposes this name in sysfs
somewhere, then you can probably use that value instead -- but I think
that's unlikely...
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can udev match on metadata from the partition table map itself?
2009-08-07 21:35 Can udev match on metadata from the partition table map itself? James Cheng
2009-08-08 3:12 ` Bryan Kadzban
@ 2009-08-08 20:07 ` David Zeuthen
2009-08-08 20:29 ` Kay Sievers
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Zeuthen @ 2009-08-08 20:07 UTC (permalink / raw)
To: linux-hotplug
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_SIZE2218389504
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ÎD0A0A2-B9E5-4433-87C0-68B6B72699C7
E: DKD_PARTITION_SIZE\x199982592
E: DKD_PARTITION_LABEL=A Partition Label
E: DKD_PARTITION_UUID202CF41-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_SIZE2256
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ñ7680
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can udev match on metadata from the partition table map itself?
2009-08-07 21:35 Can udev match on metadata from the partition table map itself? James Cheng
2009-08-08 3:12 ` Bryan Kadzban
2009-08-08 20:07 ` David Zeuthen
@ 2009-08-08 20:29 ` Kay Sievers
2009-08-11 1:19 ` James Cheng
2009-08-18 23:43 ` Karel Zak
4 siblings, 0 replies; 6+ messages in thread
From: Kay Sievers @ 2009-08-08 20:29 UTC (permalink / raw)
To: linux-hotplug
On Sat, Aug 8, 2009 at 22:07, David Zeuthen<david@fubar.dk> wrote:
> 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.
I think Karel is working on it:
http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git;a=commit;h¹46282a5fc0621c95bd3e0c19e4f72359bd731d
It really belongs into blkid, and as soon as it is available, udev
will provide this information with the default installation.
Thanks,
Kay
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Can udev match on metadata from the partition table map itself?
2009-08-07 21:35 Can udev match on metadata from the partition table map itself? James Cheng
` (2 preceding siblings ...)
2009-08-08 20:29 ` Kay Sievers
@ 2009-08-11 1:19 ` James Cheng
2009-08-18 23:43 ` Karel Zak
4 siblings, 0 replies; 6+ messages in thread
From: James Cheng @ 2009-08-11 1:19 UTC (permalink / raw)
To: linux-hotplug
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 1184 bytes --]
These are just what I needed, thanks! I'll look into DeviceKit-disks, since it looks like blkid isn't ready yet. I'll have to see what the build requirements are for DeviceKit-disks, to see whether I want to import it into my build environment.
-James
-----Original Message-----
From: Kay Sievers [mailto:kay.sievers@vrfy.org]
Sent: Saturday, August 08, 2009 1:30 PM
To: David Zeuthen
Cc: James Cheng; linux-hotplug@vger.kernel.org
Subject: Re: Can udev match on metadata from the partition table map itself?
On Sat, Aug 8, 2009 at 22:07, David Zeuthen<david@fubar.dk> wrote:
> 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.
I think Karel is working on it:
http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git;a=commit;h¹46282a5fc0621c95bd3e0c19e4f72359bd731d
It really belongs into blkid, and as soon as it is available, udev
will provide this information with the default installation.
Thanks,
Kay
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þ\x1a-¦[ þ)í
æèw*\x1fjg¬±¨\x1e¶Ý¢jÿ¾\a«þG«éÿ¢¸\f¢·¦j:+v¨wèjØm¶ÿþø\x1e¯ù\x1e®w¥þàþf£¢·hâúÿÙ¥
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can udev match on metadata from the partition table map itself?
2009-08-07 21:35 Can udev match on metadata from the partition table map itself? James Cheng
` (3 preceding siblings ...)
2009-08-11 1:19 ` James Cheng
@ 2009-08-18 23:43 ` Karel Zak
4 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2009-08-18 23:43 UTC (permalink / raw)
To: linux-hotplug
On Sat, Aug 08, 2009 at 10:29:56PM +0200, Kay Sievers wrote:
> On Sat, Aug 8, 2009 at 22:07, David Zeuthen<david@fubar.dk> wrote:
> > 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.
>
> I think Karel is working on it:
> http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git;a=commit;h¹46282a5fc0621c95bd3e0c19e4f72359bd731d
>
> It really belongs into blkid, and as soon as it is available, udev
> will provide this information with the default installation.
Yes. I'd like to try to export partition labels (e.g. mac partition
name) and partition UUIDs (e.g. EFI GUID partition UUID) to mount(8),
fsck(8), swapon(8), ... So it will be possible to indicate block
devices independently on filesystems.
Karel
--
Karel Zak <kzak@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-08-18 23:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-07 21:35 Can udev match on metadata from the partition table map itself? James Cheng
2009-08-08 3:12 ` Bryan Kadzban
2009-08-08 20:07 ` David Zeuthen
2009-08-08 20:29 ` Kay Sievers
2009-08-11 1:19 ` James Cheng
2009-08-18 23:43 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).