From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Thu, 06 May 2004 20:18:41 +0000 Subject: Re: [PATCH] udev callout for reading filesystem labels Message-Id: <20040506201841.GA661@vrfy.org> List-Id: References: <20040429210446.GA9836@vrfy.org> In-Reply-To: <20040429210446.GA9836@vrfy.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: linux-hotplug@vger.kernel.org On Thu, May 06, 2004 at 11:30:23AM +0200, Arnd Bergmann wrote: > 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. > > > > The following udev rule: > > > >   KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c" > > > > 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. Sure, we can do this. How much code do we need, for the parsing? > 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) > > +{ > > +       struct volume_id *id; > > +       char tmp_node[VOLUME_ID_PATH_MAX]; > > + > > +       snprintf(tmp_node, VOLUME_ID_PATH_MAX, > > +                "/tmp/volume-%u-%u", major(devt), minor(devt)); > > +       tmp_node[VOLUME_ID_PATH_MAX] = '\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. Hmm, I really like to be able to compile with klibc and it doesn't support tmpfile(). What about simply unlinking it, before creating the node? thanks, Kay ------------------------------------------------------- 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_______________________________________________ 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