From ef10d52745a72f524e36edc375a6a05d3365ede4 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 26 Jun 2006 14:11:33 +0000 Subject: Upgrade mdev to allow commands to be run on create/delete. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both Jason Schoon and Giuseppe Ciotta deserve credit for this, I used elements of both.  It's been upgraded so that you can specify that a given command should run at create, at delete, or at both using different special characters (@, $, and * respectively).  It uses the system() method of running command lines which means you can use environment variables on the command line (it sets $MDEV to the name of the current device being created/deleted, which is useful if you matched it via regex), and the documentation warns that you need a /bin/sh to make that work, so you probably want to pick a default shell. --- include/usage.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/usage.h b/include/usage.h index 8defbd1fc..712eede63 100644 --- a/include/usage.h +++ b/include/usage.h @@ -1799,19 +1799,25 @@ USE_FEATURE_DATE_ISOFMT( \ "\t-s\tScan /sys and populate /dev during system boot\n\n" \ "Called with no options (via hotplug) it uses environment variables\n" \ "to determine which device to add/remove." -#ifdef CONFIG_FEATURE_MDEV_CONFIG -#define mdev_notes_usage \ +#define mdev_notes_usage "" \ +USE_FEATURE_MDEV_CONFIG( \ "The mdev config file contains lines that look like:\n" \ " hd[a-z][0-9]* 0:3 660\n\n" \ "That's device name (with regex match), uid:gid, and permissions.\n\n" \ - "Optionally, that can be followed (on the same line) by an asterisk\n" \ - "and a command line to run after creating the corresponding device(s),\n"\ - "ala:\n\n" \ - " hdc root:cdrom 660 *ln -s hdc cdrom\n\n" \ + USE_FEATURE_MDEV_EXEC( \ + "Optionally, that can be followed (on the same line) by a special character\n" \ + "and a command line to run after creating/before deleting the corresponding\n" \ + "device(s). The environment variable $MDEV indicates the active device node\n" \ + "(which is useful if it's a regex match). For example:\n\n" \ + " hdc root:cdrom 660 *ln -s $MDEV cdrom\n\n" \ + "The special characters are @ (run after creating), $ (run before deleting),\n" \ + "and * (run both after creating and before deleting). The commands run in\n" \ + "the /dev directory, and use system() which calls /bin/sh.\n\n" \ + ) \ "Config file parsing stops on the first matching line. If no config\n"\ "entry is matched, devices are created with default 0:0 660. (Make\n"\ - "the last line match .* to override this.)\n\n" -#endif + "the last line match .* to override this.)\n\n" \ +) #define mesg_trivial_usage \ "[y|n]" -- cgit v1.2.3