From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Date: Thu, 06 May 2004 09:30:23 +0000 Subject: Re: [PATCH] udev callout for reading filesystem labels Message-Id: <200405061130.26733.arnd@arndb.de> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-02=_yWgmACzkkKu63ci" List-Id: References: <20040429210446.GA9836@vrfy.org> In-Reply-To: <20040429210446.GA9836@vrfy.org> To: linux-hotplug@vger.kernel.org --Boundary-02=_yWgmACzkkKu63ci Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday 29 April 2004 23:04, Kay Sievers wrote: > Hi, > here is a small udev toy, which enables udev to name partitions by > its filesystem label or uuid's. >=20 > The following udev rule: >=20 > =A0 KERNEL=3D"sd*", PROGRAM=3D"/sbin/udev_volume_id -M%M -m%m -u", SYMLIN= K=3D"%c" >=20 > creates a symlink with the uuid read from the filesystem. If no label or > uuid is found the program exits with nonzero and the rule will fail. Cool. I've tried to do something similar for dasd device labels before but not come up with a working solution yet. Do you think that udev_volume_id can be extended so that it can also read disk labels and not just partition labels? The method for detecting and reading a dasd label is the same as for fs labels, and I have the necessary parsing code here. The trouble is that the label is stored in the partition table, not in the partition itself, so I would need to pass the minor number from e.g. block/dasda/dev instead of block/dasda/dasda{1,2,3}/dev to udev_volume_id. > +/* open volume by major/minor */ > +struct volume_id *volume_id_open_dev_t(dev_t devt) > +{ > +=A0=A0=A0=A0=A0=A0=A0struct volume_id *id; > +=A0=A0=A0=A0=A0=A0=A0char tmp_node[VOLUME_ID_PATH_MAX]; > + > +=A0=A0=A0=A0=A0=A0=A0snprintf(tmp_node, VOLUME_ID_PATH_MAX, > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "/tmp/volume-%u-%u", major= (devt), minor(devt)); > +=A0=A0=A0=A0=A0=A0=A0tmp_node[VOLUME_ID_PATH_MAX] =3D '\0'; This looks like a malicious user can easily prevent it from working by creating files in /tmp. You might need to use something similar to tmpfile(3) here. Arnd <>< --Boundary-02=_yWgmACzkkKu63ci Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBAmgWy5t5GS2LDRf4RAtO9AJ0ZwdKSrOK1l7zs/MfZedjo2njK1ACggx2g N4oL1Ubj9ouTlrF+VtFbdUg= =VenM -----END PGP SIGNATURE----- --Boundary-02=_yWgmACzkkKu63ci-- ------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel