linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Zeuthen <david@fubar.dk>
To: linux-hotplug@vger.kernel.org
Subject: Re: Can udev match on metadata from the partition table map itself?
Date: Sat, 08 Aug 2009 20:07:14 +0000	[thread overview]
Message-ID: <1249762034.13248.14.camel@localhost.localdomain> (raw)
In-Reply-To: <A97D4F83D18D5641B3223ECA2D8E2ED05AB82BBB13@CORPEX01.Tivo.com>

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

  parent reply	other threads:[~2009-08-08 20:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2009-08-08 20:29 ` Kay Sievers
2009-08-11  1:19 ` James Cheng
2009-08-18 23:43 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1249762034.13248.14.camel@localhost.localdomain \
    --to=david@fubar.dk \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).