From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arioch Date: Mon, 15 Aug 2005 06:09:15 +0000 Subject: +rule: query device inode by Major and Minor - am i inventing brand Message-Id: <4300318B.8040505@nm.ru> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------080602080907030404030506" List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------080602080907030404030506 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Hello! I made (and attached) a tiny rule, and hope it will be interesting to some of you. See attach. Rule is very simple ( i think someone already did that, but i'm just offline and cannot check it ) I made it with two thought in background: 1) Some drivers with incomplete SYSFS support (namely, wbsd on my box) publiches major and minor, but not the device inode name :-( If i wantr to find it from script - how ? ls -lR | grep ? BRR! :-) Hate RegExp's :-) 2) On my box pktsetup (packet-mode CD-RW burning helper, part of udfhelper) creates two block device per drive! I wanted to catch this. After all it seems that it creates second inode by mknod, not kernel call and UDEV. But surprisingly i saw a number of other duplicate inodes with the identical major-minor So, as i want to be famous, would You, please, considering including this rule into UDEV examples ? :-) Ouugh, almost forgot to state a wish: Can there be on more key for rules ? Similar to RETURN, but matching not string form stdout, but the return code of program ( $? ) ? Why - cause i wanted to do if/else/then. I run a program to check if a symlink already exists - then i run another program to check if it does not exists ! And i cannot use /bin/ls or /bin/readlink and then use RESULT - it puts its output onto stderr if file not found, which seems to make UDEV ignore that rule inn the future (i could not find this in man, but i guess it is said somewhere on some wiki - but i'm still offline) . As well, stderr is not intercepted and user sees that unpretty sign of my sillyness :) And i didn't want to create a separate file (bash script) for such a simple task. To end this mindflow, if i mentioned man's, i'd like to say that i saw a typo in the "man udev". When describing "=" operation, there is word "iNplicit" instead of "iMplicit". If it is not my English - it is is a typo :-) Good luck and thank you all ! --------------080602080907030404030506 Content-Type: text/plain; name="99-reverse_lookup.rules" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="99-reverse_lookup.rules" # mailto:the_Arioch@nm.ru, xmpp:arioch@jabber.ru # # I want to be able to easily look for dev name by major and minor numbers # for example - from scripts # So i think of having dedicated folder for symlinks to devices # # I should check that symlinks are not overwitten - i saw udftools' pktsetup # created 2 block dev-inodes per drive ! # After all, pktsetup creates its fantom by direct mknod w/o udev interaction, # but i found a number of other dups # PROGRAM="/bin/sh -c ' [ -e %r/.lookup_by_numbers/major%M@minor%m ] ' ", SYMLINK+=".lookup_by_numbers/DUP/major%M@minor%m_DUP%e" # this rule makes easy check if any duplicate exist - dups are stored in separate dir # enter with Midnight Commander / Nautilu / Konqueror etc - and if You can see DUP folder... PROGRAM="/bin/sh -c ' [ -e %r/.lookup_by_numbers/major%M@minor%m ] ' ", SYMLINK+=".lookup_by_numbers/DUP/major%M@minor%m_DUP%e" # this rule makes easy matching - scroll through symlinks - and all DUPs and 1st link are together PROGRAM="/bin/sh -c ' [ ! -e %r/.lookup_by_numbers/major%M@minor%m ] ' ", SYMLINK+=".lookup_by_numbers/major%M@minor%m" --------------080602080907030404030506-- ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ 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