mdev: when found, print major,minor into mdev.log
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
		@@ -7,8 +7,14 @@
 | 
				
			|||||||
# instead of the default 0:0 660.
 | 
					# instead of the default 0:0 660.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Syntax:
 | 
					# Syntax:
 | 
				
			||||||
# %s %d:%d %s
 | 
					# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
 | 
				
			||||||
# devicename_regex user:group mode
 | 
					# [-]$ENVVAR=regex    user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
 | 
				
			||||||
 | 
					# [-]@maj,min[-min2]  user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# [-]: do not stop on this match, continue reading mdev.conf
 | 
				
			||||||
 | 
					# =: move, >: move and create a symlink
 | 
				
			||||||
 | 
					# !: do not create device node
 | 
				
			||||||
 | 
					# @|$|*: run@cmd if $ACTION=add,  $cmd if $ACTION=remove, *cmd in all cases
 | 
				
			||||||
 | 
					
 | 
				
			||||||
null		0:0 666
 | 
					null		0:0 666
 | 
				
			||||||
zero		0:0 666
 | 
					zero		0:0 666
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,10 +7,14 @@
 | 
				
			|||||||
# instead of the default 0:0 660.
 | 
					# instead of the default 0:0 660.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Syntax:
 | 
					# Syntax:
 | 
				
			||||||
# [-]devicename_regex user:group mode [>|=path] [@|$|*cmd args...]
 | 
					# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
 | 
				
			||||||
 | 
					# [-]$ENVVAR=regex    user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
 | 
				
			||||||
 | 
					# [-]@maj,min[-min2]  user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					# [-]: do not stop on this match, continue reading mdev.conf
 | 
				
			||||||
# =: move, >: move and create a symlink
 | 
					# =: move, >: move and create a symlink
 | 
				
			||||||
# @|$|*: run $cmd on delete, @cmd on create, *cmd on both
 | 
					# !: do not create device node
 | 
				
			||||||
 | 
					# @|$|*: run cmd if $ACTION=remove, @cmd if $ACTION=add, *cmd in all cases
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# support module loading on hotplug
 | 
					# support module loading on hotplug
 | 
				
			||||||
$MODALIAS=.*	root:root 660 @modprobe "$MODALIAS"
 | 
					$MODALIAS=.*	root:root 660 @modprobe "$MODALIAS"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -471,7 +471,7 @@ static void make_device(char *device_name, char *path, int operation)
 | 
				
			|||||||
	int major, minor, type, len;
 | 
						int major, minor, type, len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (G.verbose)
 | 
						if (G.verbose)
 | 
				
			||||||
		bb_error_msg("make_device: %s, %s, op:%d", device_name, path, operation);
 | 
							bb_error_msg("device: %s, %s", device_name, path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Try to read major/minor string.  Note that the kernel puts \n after
 | 
						/* Try to read major/minor string.  Note that the kernel puts \n after
 | 
				
			||||||
	 * the data, so we don't need to worry about null terminating the string
 | 
						 * the data, so we don't need to worry about null terminating the string
 | 
				
			||||||
@@ -479,7 +479,7 @@ static void make_device(char *device_name, char *path, int operation)
 | 
				
			|||||||
	 * We also depend on path having writeable space after it.
 | 
						 * We also depend on path having writeable space after it.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	major = -1;
 | 
						major = -1;
 | 
				
			||||||
	if (operation != OP_remove) {
 | 
						if (operation == OP_add) {
 | 
				
			||||||
		char *dev_maj_min = path + strlen(path);
 | 
							char *dev_maj_min = path + strlen(path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		strcpy(dev_maj_min, "/dev");
 | 
							strcpy(dev_maj_min, "/dev");
 | 
				
			||||||
@@ -490,7 +490,10 @@ static void make_device(char *device_name, char *path, int operation)
 | 
				
			|||||||
				return;
 | 
									return;
 | 
				
			||||||
			/* no "dev" file, but we can still run scripts
 | 
								/* no "dev" file, but we can still run scripts
 | 
				
			||||||
			 * based on device name */
 | 
								 * based on device name */
 | 
				
			||||||
		} else if (sscanf(++dev_maj_min, "%u:%u", &major, &minor) != 2) {
 | 
							} else if (sscanf(++dev_maj_min, "%u:%u", &major, &minor) == 2) {
 | 
				
			||||||
 | 
								if (G.verbose)
 | 
				
			||||||
 | 
									bb_error_msg("maj,min: %u,%u", major, minor);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			major = -1;
 | 
								major = -1;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -502,7 +505,8 @@ static void make_device(char *device_name, char *path, int operation)
 | 
				
			|||||||
	/* http://kernel.org/doc/pending/hotplug.txt says that only
 | 
						/* http://kernel.org/doc/pending/hotplug.txt says that only
 | 
				
			||||||
	 * "/sys/block/..." is for block devices. "/sys/bus" etc is not.
 | 
						 * "/sys/block/..." is for block devices. "/sys/bus" etc is not.
 | 
				
			||||||
	 * But since 2.6.25 block devices are also in /sys/class/block.
 | 
						 * But since 2.6.25 block devices are also in /sys/class/block.
 | 
				
			||||||
	 * We use strstr("/block/") to forestall future surprises. */
 | 
						 * We use strstr("/block/") to forestall future surprises.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	type = S_IFCHR;
 | 
						type = S_IFCHR;
 | 
				
			||||||
	if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0))
 | 
						if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0))
 | 
				
			||||||
		type = S_IFBLK;
 | 
							type = S_IFBLK;
 | 
				
			||||||
@@ -669,12 +673,12 @@ static void make_device(char *device_name, char *path, int operation)
 | 
				
			|||||||
				bb_error_msg("mknod: %s (%d,%d) %o", node_name, major, minor, rule->mode | type);
 | 
									bb_error_msg("mknod: %s (%d,%d) %o", node_name, major, minor, rule->mode | type);
 | 
				
			||||||
			if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST)
 | 
								if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST)
 | 
				
			||||||
				bb_perror_msg("can't create '%s'", node_name);
 | 
									bb_perror_msg("can't create '%s'", node_name);
 | 
				
			||||||
			if (major == G.root_major && minor == G.root_minor)
 | 
					 | 
				
			||||||
				symlink(node_name, "root");
 | 
					 | 
				
			||||||
			if (ENABLE_FEATURE_MDEV_CONF) {
 | 
								if (ENABLE_FEATURE_MDEV_CONF) {
 | 
				
			||||||
				chmod(node_name, rule->mode);
 | 
									chmod(node_name, rule->mode);
 | 
				
			||||||
				chown(node_name, rule->ugid.uid, rule->ugid.gid);
 | 
									chown(node_name, rule->ugid.uid, rule->ugid.gid);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if (major == G.root_major && minor == G.root_minor)
 | 
				
			||||||
 | 
									symlink(node_name, "root");
 | 
				
			||||||
			if (ENABLE_FEATURE_MDEV_RENAME && alias) {
 | 
								if (ENABLE_FEATURE_MDEV_RENAME && alias) {
 | 
				
			||||||
				if (aliaslink == '>') {
 | 
									if (aliaslink == '>') {
 | 
				
			||||||
//TODO: on devtmpfs, device_name already exists and symlink() fails.
 | 
					//TODO: on devtmpfs, device_name already exists and symlink() fails.
 | 
				
			||||||
@@ -890,13 +894,13 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 | 
				
			|||||||
		 * DEVPATH is like "/block/sda" or "/class/input/mice"
 | 
							 * DEVPATH is like "/block/sda" or "/class/input/mice"
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		action = getenv("ACTION");
 | 
							action = getenv("ACTION");
 | 
				
			||||||
 | 
							op = index_in_strings(keywords, action);
 | 
				
			||||||
		env_devname = getenv("DEVNAME"); /* can be NULL */
 | 
							env_devname = getenv("DEVNAME"); /* can be NULL */
 | 
				
			||||||
		env_devpath = getenv("DEVPATH");
 | 
							env_devpath = getenv("DEVPATH");
 | 
				
			||||||
		G.subsystem = getenv("SUBSYSTEM");
 | 
							G.subsystem = getenv("SUBSYSTEM");
 | 
				
			||||||
		if (!action || !env_devpath /*|| !G.subsystem*/)
 | 
							if (!action || !env_devpath /*|| !G.subsystem*/)
 | 
				
			||||||
			bb_show_usage();
 | 
								bb_show_usage();
 | 
				
			||||||
		fw = getenv("FIRMWARE");
 | 
							fw = getenv("FIRMWARE");
 | 
				
			||||||
		op = index_in_strings(keywords, action);
 | 
					 | 
				
			||||||
		/* If it exists, does /dev/mdev.seq match $SEQNUM?
 | 
							/* If it exists, does /dev/mdev.seq match $SEQNUM?
 | 
				
			||||||
		 * If it does not match, earlier mdev is running
 | 
							 * If it does not match, earlier mdev is running
 | 
				
			||||||
		 * in parallel, and we need to wait */
 | 
							 * in parallel, and we need to wait */
 | 
				
			||||||
@@ -927,7 +931,7 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 | 
				
			|||||||
			if (logfd >= 0) {
 | 
								if (logfd >= 0) {
 | 
				
			||||||
				xmove_fd(logfd, STDERR_FILENO);
 | 
									xmove_fd(logfd, STDERR_FILENO);
 | 
				
			||||||
				G.verbose = 1;
 | 
									G.verbose = 1;
 | 
				
			||||||
				bb_error_msg("pid: %u seq: %s action: %s", getpid(), seq, action);
 | 
									bb_error_msg("seq: %s action: %s", seq, action);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user