/* vi: set sw=4 ts=4: */
/*
 * mdev - Mini udev for busybox
 *
 * Copyright 2005 Rob Landley <rob@landley.net>
 * Copyright 2005 Frank Sorenson <frank@tuxrocks.com>
 *
 * Licensed under GPLv2, see file LICENSE in this source tree.
 */
//config:config MDEV
//config:	bool "mdev (17 kb)"
//config:	default y
//config:	help
//config:	mdev is a mini-udev implementation for dynamically creating device
//config:	nodes in the /dev directory.
//config:
//config:	For more information, please see docs/mdev.txt
//config:
//config:config FEATURE_MDEV_CONF
//config:	bool "Support /etc/mdev.conf"
//config:	default y
//config:	depends on MDEV
//config:	help
//config:	Add support for the mdev config file to control ownership and
//config:	permissions of the device nodes.
//config:
//config:	For more information, please see docs/mdev.txt
//config:
//config:config FEATURE_MDEV_RENAME
//config:	bool "Support subdirs/symlinks"
//config:	default y
//config:	depends on FEATURE_MDEV_CONF
//config:	help
//config:	Add support for renaming devices and creating symlinks.
//config:
//config:	For more information, please see docs/mdev.txt
//config:
//config:config FEATURE_MDEV_RENAME_REGEXP
//config:	bool "Support regular expressions substitutions when renaming device"
//config:	default y
//config:	depends on FEATURE_MDEV_RENAME
//config:	help
//config:	Add support for regular expressions substitutions when renaming
//config:	device.
//config:
//config:config FEATURE_MDEV_EXEC
//config:	bool "Support command execution at device addition/removal"
//config:	default y
//config:	depends on FEATURE_MDEV_CONF
//config:	help
//config:	This adds support for an optional field to /etc/mdev.conf for
//config:	executing commands when devices are created/removed.
//config:
//config:	For more information, please see docs/mdev.txt
//config:
//config:config FEATURE_MDEV_LOAD_FIRMWARE
//config:	bool "Support loading of firmware"
//config:	default y
//config:	depends on MDEV
//config:	help
//config:	Some devices need to load firmware before they can be usable.
//config:
//config:	These devices will request userspace look up the files in
//config:	/lib/firmware/ and if it exists, send it to the kernel for
//config:	loading into the hardware.
//config:
//config:config FEATURE_MDEV_DAEMON
//config:	bool "Support daemon mode"
//config:	default y
//config:	depends on MDEV
//config:	help
//config:	Adds the -d option to run mdev in daemon mode handling hotplug
//config:	events from the kernel like udev. If the system generates many
//config:	hotplug events this mode of operation will consume less
//config:	resources than registering mdev as hotplug helper or using the
//config:	uevent applet.

//applet:IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP))

//kbuild:lib-$(CONFIG_MDEV) += mdev.o

//usage:#define mdev_trivial_usage
//usage:       "[-vS] " IF_FEATURE_MDEV_DAEMON("{ ") "[-s]" IF_FEATURE_MDEV_DAEMON(" | [-df] }")
//usage:#define mdev_full_usage "\n\n"
//usage:       "	-v	Verbose\n"
//usage:       "	-S	Log to syslog too\n"
//usage:       "	-s	Scan /sys and populate /dev\n"
//usage:	IF_FEATURE_MDEV_DAEMON(
//usage:       "	-d	Daemon, listen on netlink\n"
//usage:       "	-f	Run in foreground\n"
//usage:	)
//usage:       "\n"
//usage:       "Bare mdev is a kernel hotplug helper. To activate it:\n"
//usage:       "	echo /sbin/mdev >/proc/sys/kernel/hotplug\n"
//usage:	IF_FEATURE_MDEV_CONF(
//usage:       "\n"
//usage:       "It uses /etc/mdev.conf with lines\n"
//usage:       "	[-][ENV=regex;]...DEVNAME UID:GID PERM"
//usage:			IF_FEATURE_MDEV_RENAME(" [>|=PATH]|[!]")
//usage:			IF_FEATURE_MDEV_EXEC(" [@|$|*PROG]")
//usage:       "\n"
//usage:       "where DEVNAME is device name regex, @major,minor[-minor2], or\n"
//usage:       "environment variable regex. A common use of the latter is\n"
//usage:       "to load modules for hotplugged devices:\n"
//usage:       "	$MODALIAS=.* 0:0 660 @modprobe \"$MODALIAS\"\n"
//usage:	)
//usage:       "\n"
//usage:       "If /dev/mdev.seq file exists, mdev will wait for its value\n"
//usage:       "to match $SEQNUM variable. This prevents plug/unplug races.\n"
//usage:       "To activate this feature, create empty /dev/mdev.seq at boot.\n"
//usage:       "\n"
//usage:       "If /dev/mdev.log file exists, debug log will be appended to it."

#include "libbb.h"
#include "common_bufsiz.h"
#include "xregex.h"
#include <linux/netlink.h>
#include <syslog.h>

/* "mdev -s" scans /sys/class/xxx, looking for directories which have dev
 * file (it is of the form "M:m\n"). Example: /sys/class/tty/tty0/dev
 * contains "4:0\n". Directory name is taken as device name, path component
 * directly after /sys/class/ as subsystem. In this example, "tty0" and "tty".
 * Then mdev creates the /dev/device_name node.
 * If /sys/class/.../dev file does not exist, mdev still may act
 * on this device: see "@|$|*command args..." parameter in config file.
 *
 * mdev w/o parameters is called as hotplug helper. It takes device
 * and subsystem names from $DEVPATH and $SUBSYSTEM, extracts
 * maj,min from "/sys/$DEVPATH/dev" and also examines
 * $ACTION ("add"/"delete") and $FIRMWARE.
 *
 * If action is "add", mdev creates /dev/device_name similarly to mdev -s.
 * (todo: explain "delete" and $FIRMWARE)
 *
 * If /etc/mdev.conf exists, it may modify /dev/device_name's properties.
 *
 * Leading minus in 1st field means "don't stop on this line", otherwise
 * search is stopped after the matching line is encountered.
 *
 * $envvar=regex format is useful for loading modules for hot-plugged devices
 * which do not have driver loaded yet. In this case /sys/class/.../dev
 * does not exist, but $MODALIAS is set to needed module's name
 * (actually, an alias to it) by kernel. This rule instructs mdev
 * to load the module and exit:
 *    $MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"
 * The kernel will generate another hotplug event when /sys/class/.../dev
 * file appears.
 *
 * When line matches, the device node is created, chmod'ed and chown'ed,
 * moved to path, and if >path, a symlink to moved node is created,
 * all this if /sys/class/.../dev exists.
 *    Examples:
 *    =loop/      - moves to /dev/loop
 *    >disk/sda%1 - moves to /dev/disk/sdaN, makes /dev/sdaN a symlink
 *
 * Then "command args..." is executed (via sh -c 'command args...').
 * @:execute on creation, $:on deletion, *:on both.
 * This happens regardless of /sys/class/.../dev existence.
 */

/* Kernel's hotplug environment constantly changes.
 * Here are new cases I observed on 3.1.0:
 *
 * Case with $DEVNAME and $DEVICE, not just $DEVPATH:
 * ACTION=add
 * BUSNUM=001
 * DEVICE=/proc/bus/usb/001/003
 * DEVNAME=bus/usb/001/003
 * DEVNUM=003
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5
 * DEVTYPE=usb_device
 * MAJOR=189
 * MINOR=2
 * PRODUCT=18d1/4e12/227
 * SUBSYSTEM=usb
 * TYPE=0/0/0
 *
 * Case with $DEVICE, but no $DEVNAME - apparenty, usb iface notification?
 * "Please load me a module" thing?
 * ACTION=add
 * DEVICE=/proc/bus/usb/001/003
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0
 * DEVTYPE=usb_interface
 * INTERFACE=8/6/80
 * MODALIAS=usb:v18D1p4E12d0227dc00dsc00dp00ic08isc06ip50
 * PRODUCT=18d1/4e12/227
 * SUBSYSTEM=usb
 * TYPE=0/0/0
 *
 * ACTION=add
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5
 * DEVTYPE=scsi_host
 * SUBSYSTEM=scsi
 *
 * ACTION=add
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/scsi_host/host5
 * SUBSYSTEM=scsi_host
 *
 * ACTION=add
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0
 * DEVTYPE=scsi_target
 * SUBSYSTEM=scsi
 *
 * Case with strange $MODALIAS:
 * ACTION=add
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0
 * DEVTYPE=scsi_device
 * MODALIAS=scsi:t-0x00
 * SUBSYSTEM=scsi
 *
 * ACTION=add
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0/scsi_disk/5:0:0:0
 * SUBSYSTEM=scsi_disk
 *
 * ACTION=add
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0/scsi_device/5:0:0:0
 * SUBSYSTEM=scsi_device
 *
 * Case with explicit $MAJOR/$MINOR (no need to read /sys/$DEVPATH/dev?):
 * ACTION=add
 * DEVNAME=bsg/5:0:0:0
 * DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0/bsg/5:0:0:0
 * MAJOR=253
 * MINOR=1
 * SUBSYSTEM=bsg
 *
 * ACTION=add
 * DEVPATH=/devices/virtual/bdi/8:16
 * SUBSYSTEM=bdi
 *
 * ACTION=add
 * DEVNAME=sdb
 * DEVPATH=/block/sdb
 * DEVTYPE=disk
 * MAJOR=8
 * MINOR=16
 * SUBSYSTEM=block
 *
 * Case with ACTION=change:
 * ACTION=change
 * DEVNAME=sdb
 * DEVPATH=/block/sdb
 * DEVTYPE=disk
 * DISK_MEDIA_CHANGE=1
 * MAJOR=8
 * MINOR=16
 * SUBSYSTEM=block
 */

#define DEBUG_LVL 2

#if DEBUG_LVL >= 1
# define dbg1(...) do { if (G.verbose) bb_error_msg(__VA_ARGS__); } while(0)
# define dbg1s(msg) do { if (G.verbose) bb_simple_error_msg(msg); } while(0)
#else
# define dbg1(...) ((void)0)
# define dbg1s(msg) ((void)0)
#endif
#if DEBUG_LVL >= 2
# define dbg2(...) do { if (G.verbose >= 2) bb_error_msg(__VA_ARGS__); } while(0)
# define dbg2s(msg) do { if (G.verbose >= 2) bb_simple_error_msg(msg); } while(0)
#else
# define dbg2(...) ((void)0)
# define dbg2s(msg) ((void)0)
#endif
#if DEBUG_LVL >= 3
# define dbg3(...) do { if (G.verbose >= 3) bb_error_msg(__VA_ARGS__); } while(0)
# define dbg3s(msg) do { if (G.verbose >= 3) bb_simple_error_msg(msg); } while(0)
#else
# define dbg3(...) ((void)0)
# define dbg3s(msg) ((void)0)
#endif

static const char keywords[] ALIGN1 = "add\0remove\0"; // "change\0"
enum { OP_add, OP_remove };

struct envmatch {
	struct envmatch *next;
	char *envname;
	regex_t match;
};

struct rule {
	bool keep_matching;
	bool regex_compiled;
	mode_t mode;
	int maj, min0, min1;
	struct bb_uidgid_t ugid;
	char *envvar;
	char *ren_mov;
	IF_FEATURE_MDEV_EXEC(char *r_cmd;)
	regex_t match;
	struct envmatch *envmatch;
};

struct globals {
	int root_major, root_minor;
	int verbose;
	char *subsystem;
	char *subsys_env; /* for putenv("SUBSYSTEM=subsystem") */
#if ENABLE_FEATURE_MDEV_CONF
	const char *filename;
	parser_t *parser;
	struct rule **rule_vec;
	unsigned rule_idx;
#endif
	struct rule cur_rule;
	char timestr[sizeof("HH:MM:SS.123456")];
} FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
	setup_common_bufsiz(); \
	IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.maj = -1;) \
	IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.mode = 0660;) \
} while (0)


/* Prevent infinite loops in /sys symlinks */
#define MAX_SYSFS_DEPTH 3

/* We use additional bytes in make_device() */
#define SCRATCH_SIZE 128

#if ENABLE_FEATURE_MDEV_CONF

static void make_default_cur_rule(void)
{
	memset(&G.cur_rule, 0, sizeof(G.cur_rule));
	G.cur_rule.maj = -1; /* "not a @major,minor rule" */
	G.cur_rule.mode = 0660;
}

static void clean_up_cur_rule(void)
{
	struct envmatch *e;

	free(G.cur_rule.envvar);
	free(G.cur_rule.ren_mov);
	if (G.cur_rule.regex_compiled)
		regfree(&G.cur_rule.match);
	IF_FEATURE_MDEV_EXEC(free(G.cur_rule.r_cmd);)
	e = G.cur_rule.envmatch;
	while (e) {
		free(e->envname);
		regfree(&e->match);
		e = e->next;
	}
	make_default_cur_rule();
}

static char *parse_envmatch_pfx(char *val)
{
	struct envmatch **nextp = &G.cur_rule.envmatch;

	for (;;) {
		struct envmatch *e;
		char *semicolon;
		char *eq = strchr(val, '=');
		if (!eq /* || eq == val? */)
			return val;
		if (endofname(val) != eq)
			return val;
		semicolon = strchr(eq, ';');
		if (!semicolon)
			return val;
		/* ENVVAR=regex;... */
		*nextp = e = xzalloc(sizeof(*e));
		nextp = &e->next;
		e->envname = xstrndup(val, eq - val);
		*semicolon = '\0';
		xregcomp(&e->match, eq + 1, REG_EXTENDED);
		*semicolon = ';';
		val = semicolon + 1;
	}
}

static void parse_next_rule(void)
{
	/* Note: on entry, G.cur_rule is set to default */
	while (1) {
		char *tokens[4];
		char *val;

		/* No PARSE_EOL_COMMENTS, because command may contain '#' chars */
		if (!config_read(G.parser, tokens, 4, 3, "# \t", PARSE_NORMAL & ~PARSE_EOL_COMMENTS))
			break;

		/* Fields: [-]regex uid:gid mode [alias] [cmd] */
		dbg3("token1:'%s'", tokens[1]);

		/* 1st field */
		val = tokens[0];
		G.cur_rule.keep_matching = ('-' == val[0]);
		val += G.cur_rule.keep_matching; /* swallow leading dash */
		val = parse_envmatch_pfx(val);
		if (val[0] == '@') {
			/* @major,minor[-minor2] */
			/* (useful when name is ambiguous:
			 * "/sys/class/usb/lp0" and
			 * "/sys/class/printer/lp0")
			 */
			int sc = sscanf(val, "@%u,%u-%u", &G.cur_rule.maj, &G.cur_rule.min0, &G.cur_rule.min1);
			if (sc < 2 || G.cur_rule.maj < 0) {
				bb_error_msg("bad @maj,min on line %d", G.parser->lineno);
				goto next_rule;
			}
			if (sc == 2)
				G.cur_rule.min1 = G.cur_rule.min0;
		} else {
			char *eq = strchr(val, '=');
			if (val[0] == '$') {
				/* $ENVVAR=regex ... */
				val++;
				if (!eq) {
					bb_error_msg("bad $envvar=regex on line %d", G.parser->lineno);
					goto next_rule;
				}
				G.cur_rule.envvar = xstrndup(val, eq - val);
				val = eq + 1;
			}
			xregcomp(&G.cur_rule.match, val, REG_EXTENDED);
			G.cur_rule.regex_compiled = 1;
		}

		/* 2nd field: uid:gid - device ownership */
		if (get_uidgid(&G.cur_rule.ugid, tokens[1]) == 0) {
			bb_error_msg("unknown user/group '%s' on line %d", tokens[1], G.parser->lineno);
			goto next_rule;
		}

		/* 3rd field: mode - device permissions */
		G.cur_rule.mode = bb_parse_mode(tokens[2], G.cur_rule.mode);

		/* 4th field (opt): ">|=alias" or "!" to not create the node */
		val = tokens[3];
		if (ENABLE_FEATURE_MDEV_RENAME && val && strchr(">=!", val[0])) {
			char *s = skip_non_whitespace(val);
			G.cur_rule.ren_mov = xstrndup(val, s - val);
			val = skip_whitespace(s);
		}

		if (ENABLE_FEATURE_MDEV_EXEC && val && val[0]) {
			const char *s = "$@*";
			const char *s2 = strchr(s, val[0]);
			if (!s2) {
				bb_error_msg("bad line %u", G.parser->lineno);
				goto next_rule;
			}
			IF_FEATURE_MDEV_EXEC(G.cur_rule.r_cmd = xstrdup(val);)
		}

		return;
 next_rule:
		clean_up_cur_rule();
	} /* while (config_read) */

	dbg3("config_close(G.parser)");
	config_close(G.parser);
	G.parser = NULL;

	return;
}

/* If mdev -s, we remember rules in G.rule_vec[].
 * Otherwise, there is no point in doing it, and we just
 * save only one parsed rule in G.cur_rule.
 */
static const struct rule *next_rule(void)
{
	struct rule *rule;

	/* Open conf file if we didn't do it yet */
	if (!G.parser && G.filename) {
		dbg3("config_open('%s')", G.filename);
		G.parser = config_open2(G.filename, fopen_for_read);
		G.filename = NULL;
	}

	if (G.rule_vec) {
		/* mdev -s */
		/* Do we have rule parsed already? */
		if (G.rule_vec[G.rule_idx]) {
			dbg3("< G.rule_vec[G.rule_idx:%d]=%p", G.rule_idx, G.rule_vec[G.rule_idx]);
			return G.rule_vec[G.rule_idx++];
		}
		make_default_cur_rule();
	} else {
		/* not mdev -s */
		clean_up_cur_rule();
	}

	/* Parse one more rule if file isn't fully read */
	rule = &G.cur_rule;
	if (G.parser) {
		parse_next_rule();
		if (G.rule_vec) { /* mdev -s */
			rule = xmemdup(&G.cur_rule, sizeof(G.cur_rule));
			G.rule_vec = xrealloc_vector(G.rule_vec, 4, G.rule_idx);
			G.rule_vec[G.rule_idx++] = rule;
			dbg3("> G.rule_vec[G.rule_idx:%d]=%p", G.rule_idx, G.rule_vec[G.rule_idx]);
		}
	}

	return rule;
}

static int env_matches(struct envmatch *e)
{
	while (e) {
		int r;
		char *val = getenv(e->envname);
		if (!val)
			return 0;
		r = regexec(&e->match, val, /*size*/ 0, /*range[]*/ NULL, /*eflags*/ 0);
		if (r != 0) /* no match */
			return 0;
		e = e->next;
	}
	return 1;
}

#else

# define next_rule() (&G.cur_rule)

#endif

static void mkdir_recursive(char *name)
{
	/* if name has many levels ("dir1/dir2"),
	 * bb_make_directory() will create dir1 according to umask,
	 * not according to its "mode" parameter.
	 * Since we run with umask=0, need to temporarily switch it.
	 */
	umask(022); /* "dir1" (if any) will be 0755 too */
	bb_make_directory(name, 0755, FILEUTILS_RECUR);
	umask(0);
}

/* Builds an alias path.
 * This function potentionally reallocates the alias parameter.
 * Only used for ENABLE_FEATURE_MDEV_RENAME
 */
static char *build_alias(char *alias, const char *device_name)
{
	char *dest;

	/* ">bar/": rename to bar/device_name */
	/* ">bar[/]baz": rename to bar[/]baz */
	dest = strrchr(alias, '/');
	if (dest) { /* ">bar/[baz]" ? */
		*dest = '\0'; /* mkdir bar */
		mkdir_recursive(alias);
		*dest = '/';
		if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
			dest = alias;
			alias = concat_path_file(alias, device_name);
			free(dest);
		}
	}

	return alias;
}

/* mknod in /dev based on a path like "/sys/block/hda/hda1"
 * NB1: path parameter needs to have SCRATCH_SIZE scratch bytes
 * after NUL, but we promise to not mangle it (IOW: to restore NUL if needed).
 * NB2: "mdev -s" may call us many times, do not leak memory/fds!
 *
 * device_name = $DEVNAME (may be NULL)
 * path        = /sys/$DEVPATH
 */
static void make_device(char *device_name, char *path, int operation)
{
	int major, minor, type, len;
	char *path_end = path + strlen(path);

	/* 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
	 * because sscanf() will stop at the first nondigit, which \n is.
	 * We also depend on path having writeable space after it.
	 */
	major = -1;
	if (operation == OP_add) {
		strcpy(path_end, "/dev");
		len = open_read_close(path, path_end + 1, SCRATCH_SIZE - 1);
		*path_end = '\0';
		if (len < 1) {
			if (!ENABLE_FEATURE_MDEV_EXEC)
				return;
			/* no "dev" file, but we can still run scripts
			 * based on device name */
		} else if (sscanf(path_end + 1, "%u:%u", &major, &minor) == 2) {
			dbg1("dev %u,%u", major, minor);
		} else {
			major = -1;
		}
	}
	/* else: for delete, -1 still deletes the node, but < -1 suppresses that */

	/* Determine device name */
	if (!device_name) {
		/*
		 * There was no $DEVNAME envvar (for example, mdev -s never has).
		 * But it is very useful: it contains the *path*, not only basename,
		 * Thankfully, uevent file has it.
		 * Example of .../sound/card0/controlC0/uevent file on Linux-3.7.7:
		 * MAJOR=116
		 * MINOR=7
		 * DEVNAME=snd/controlC0
		 */
		strcpy(path_end, "/uevent");
		len = open_read_close(path, path_end + 1, SCRATCH_SIZE - 1);
		if (len < 0)
			len = 0;
		*path_end = '\0';
		path_end[1 + len] = '\0';
		device_name = strstr(path_end + 1, "\nDEVNAME=");
		if (device_name) {
			device_name += sizeof("\nDEVNAME=")-1;
			strchrnul(device_name, '\n')[0] = '\0';
		} else {
			/* Fall back to just basename */
			device_name = (char*) bb_basename(path);
		}
	}
	/* Determine device type */
	/*
	 * http://kernel.org/doc/pending/hotplug.txt says that only
	 * "/sys/block/..." is for block devices. "/sys/bus" etc is not.
	 * But since 2.6.25 block devices are also in /sys/class/block.
	 * We use strstr("/block/") to forestall future surprises.
	 */
	type = S_IFCHR;
	if (strstr(path, "/block/") || (G.subsystem && is_prefixed_with(G.subsystem, "block")))
		type = S_IFBLK;

#if ENABLE_FEATURE_MDEV_CONF
	G.rule_idx = 0; /* restart from the beginning (think mdev -s) */
#endif
	for (;;) {
		const char *str_to_match;
		regmatch_t off[1 + 9 * ENABLE_FEATURE_MDEV_RENAME_REGEXP];
		char *command;
		char *alias;
		char aliaslink = aliaslink; /* for compiler */
		char *node_name;
		const struct rule *rule;

		str_to_match = device_name;

		rule = next_rule();

#if ENABLE_FEATURE_MDEV_CONF
		if (!env_matches(rule->envmatch))
			continue;
		if (rule->maj >= 0) {  /* @maj,min rule */
			if (major != rule->maj)
				continue;
			if (minor < rule->min0 || minor > rule->min1)
				continue;
			memset(off, 0, sizeof(off));
			goto rule_matches;
		}
		if (rule->envvar) { /* $envvar=regex rule */
			str_to_match = getenv(rule->envvar);
			dbg3("getenv('%s'):'%s'", rule->envvar, str_to_match);
			if (!str_to_match)
				continue;
		}
		/* else: str_to_match = device_name */

		if (rule->regex_compiled) {
			int regex_match = regexec(&rule->match, str_to_match, ARRAY_SIZE(off), off, 0);
			dbg3("regex_match for '%s':%d", str_to_match, regex_match);
			//bb_error_msg("matches:");
			//for (int i = 0; i < ARRAY_SIZE(off); i++) {
			//	if (off[i].rm_so < 0) continue;
			//	bb_error_msg("match %d: '%.*s'\n", i,
			//		(int)(off[i].rm_eo - off[i].rm_so),
			//		device_name + off[i].rm_so);
			//}

			if (regex_match != 0
			/* regexec returns whole pattern as "range" 0 */
			 || off[0].rm_so != 0
			 || (int)off[0].rm_eo != (int)strlen(str_to_match)
			) {
				continue; /* this rule doesn't match */
			}
		}
		/* else: it's final implicit "match-all" rule */
 rule_matches:
		dbg2("rule matched, line %d", G.parser ? G.parser->lineno : -1);
#endif
		/* Build alias name */
		alias = NULL;
		if (ENABLE_FEATURE_MDEV_RENAME && rule->ren_mov) {
			aliaslink = rule->ren_mov[0];
			if (aliaslink == '!') {
				/* "!": suppress node creation/deletion */
				major = -2;
			}
			else if (aliaslink == '>' || aliaslink == '=') {
				if (ENABLE_FEATURE_MDEV_RENAME_REGEXP) {
					char *s;
					char *p;
					unsigned n;

					/* substitute %1..9 with off[1..9], if any */
					n = 0;
					s = rule->ren_mov;
					while (*s)
						if (*s++ == '%')
							n++;

					p = alias = xzalloc(strlen(rule->ren_mov) + n * strlen(str_to_match));
					s = rule->ren_mov + 1;
					while (*s) {
						*p = *s;
						if ('%' == *s) {
							unsigned i = (s[1] - '0');
							if (i <= 9 && off[i].rm_so >= 0) {
								n = off[i].rm_eo - off[i].rm_so;
								strncpy(p, str_to_match + off[i].rm_so, n);
								p += n - 1;
								s++;
							}
						}
						p++;
						s++;
					}
				} else {
					alias = xstrdup(rule->ren_mov + 1);
				}
			}
		}
		dbg3("alias:'%s'", alias);

		command = NULL;
		IF_FEATURE_MDEV_EXEC(command = rule->r_cmd;)
		if (command) {
			/* Are we running this command now?
			 * Run @cmd on create, $cmd on delete, *cmd on any
			 */
			if ((command[0] == '@' && operation == OP_add)
			 || (command[0] == '$' && operation == OP_remove)
			 || (command[0] == '*')
			) {
				command++;
			} else {
				command = NULL;
			}
		}
		dbg3("command:'%s'", command);

		/* "Execute" the line we found */
		node_name = device_name;
		if (ENABLE_FEATURE_MDEV_RENAME && alias) {
			node_name = alias = build_alias(alias, device_name);
			dbg3("alias2:'%s'", alias);
		}

		if (operation == OP_add && major >= 0) {
			char *slash = strrchr(node_name, '/');
			if (slash) {
				*slash = '\0';
				mkdir_recursive(node_name);
				*slash = '/';
			}
			if (ENABLE_FEATURE_MDEV_CONF) {
				dbg1("mknod %s (%d,%d) %o"
					" %u:%u",
					node_name, major, minor, rule->mode | type,
					rule->ugid.uid, rule->ugid.gid
				);
			} else {
				dbg1("mknod %s (%d,%d) %o",
					node_name, major, minor, rule->mode | type
				);
			}
			if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST)
				bb_perror_msg("can't create '%s'", node_name);
			if (ENABLE_FEATURE_MDEV_CONF) {
				chmod(node_name, rule->mode);
				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 (aliaslink == '>') {
//TODO: on devtmpfs, device_name already exists and symlink() fails.
//End result is that instead of symlink, we have two nodes.
//What should be done?
					dbg1("symlink: %s", device_name);
					symlink(node_name, device_name);
				}
			}
		}

		if (ENABLE_FEATURE_MDEV_EXEC && command) {
			/* setenv will leak memory, use putenv/unsetenv/free */
			char *s = xasprintf("%s=%s", "MDEV", node_name);
			putenv(s);
			dbg1("running: %s", command);
			if (system(command) == -1)
				bb_perror_msg("can't run '%s'", command);
			bb_unsetenv_and_free(s);
		}

		if (operation == OP_remove && major >= -1) {
			if (ENABLE_FEATURE_MDEV_RENAME && alias) {
				if (aliaslink == '>') {
					dbg1("unlink: %s", device_name);
					unlink(device_name);
				}
			}
			dbg1("unlink: %s", node_name);
			unlink(node_name);
		}

		if (ENABLE_FEATURE_MDEV_RENAME)
			free(alias);

		/* We found matching line.
		 * Stop unless it was prefixed with '-'
		 */
		if (!ENABLE_FEATURE_MDEV_CONF || !rule->keep_matching)
			break;
	} /* for (;;) */
}

static ssize_t readlink2(char *buf, size_t bufsize)
{
	// Grr... gcc 8.1.1:
	// "passing argument 2 to restrict-qualified parameter aliases with argument 1"
	// dance around that...
	char *obuf FIX_ALIASING;
	obuf = buf;
	return readlink(buf, obuf, bufsize);
}

/* File callback for /sys/ traversal.
 * We act only on "/sys/.../dev" (pseudo)file
 */
static int FAST_FUNC fileAction(struct recursive_state *state,
		const char *fileName,
		struct stat *statbuf UNUSED_PARAM)
{
	size_t len = strlen(fileName) - 4; /* can't underflow */
	char *path = state->userData;	/* char array[PATH_MAX + SCRATCH_SIZE] */
	char subsys[PATH_MAX];
	int res;

	/* Is it a ".../dev" file? (len check is for paranoid reasons) */
	if (strcmp(fileName + len, "/dev") != 0 || len >= PATH_MAX - 32)
		return FALSE; /* not .../dev */

	strcpy(path, fileName);
	path[len] = '\0';

	/* Read ".../subsystem" symlink in the same directory where ".../dev" is */
	strcpy(subsys, path);
	strcpy(subsys + len, "/subsystem");
	res = readlink2(subsys, sizeof(subsys)-1);
	if (res > 0) {
		subsys[res] = '\0';
		free(G.subsystem);
		if (G.subsys_env) {
			bb_unsetenv_and_free(G.subsys_env);
			G.subsys_env = NULL;
		}
		/* Set G.subsystem and $SUBSYSTEM from symlink's last component */
		G.subsystem = strrchr(subsys, '/');
		if (G.subsystem) {
			G.subsystem = xstrdup(G.subsystem + 1);
			G.subsys_env = xasprintf("%s=%s", "SUBSYSTEM", G.subsystem);
			putenv(G.subsys_env);
		}
	}

	make_device(/*DEVNAME:*/ NULL, path, OP_add);

	return TRUE;
}

/* Directory callback for /sys/ traversal */
static int FAST_FUNC dirAction(struct recursive_state *state,
		const char *fileName UNUSED_PARAM,
		struct stat *statbuf UNUSED_PARAM)
{
	return (state->depth >= MAX_SYSFS_DEPTH ? SKIP : TRUE);
}

/* For the full gory details, see linux/Documentation/firmware_class/README
 *
 * Firmware loading works like this:
 * - kernel sets FIRMWARE env var
 * - userspace checks /lib/firmware/$FIRMWARE
 * - userspace waits for /sys/$DEVPATH/loading to appear
 * - userspace writes "1" to /sys/$DEVPATH/loading
 * - userspace copies /lib/firmware/$FIRMWARE into /sys/$DEVPATH/data
 * - userspace writes "0" (worked) or "-1" (failed) to /sys/$DEVPATH/loading
 * - kernel loads firmware into device
 */
static void load_firmware(const char *firmware, const char *sysfs_path)
{
	int cnt;
	int firmware_fd, loading_fd;

	/* check for /lib/firmware/$FIRMWARE */
	firmware_fd = -1;
	if (chdir("/lib/firmware") == 0)
		firmware_fd = open(firmware, O_RDONLY); /* can fail */

	/* check for /sys/$DEVPATH/loading ... give 30 seconds to appear */
	xchdir(sysfs_path);
	for (cnt = 0; cnt < 30; ++cnt) {
		loading_fd = open("loading", O_WRONLY);
		if (loading_fd >= 0)
			goto loading;
		sleep1();
	}
	goto out;

 loading:
	cnt = 0;
	if (firmware_fd >= 0) {
		int data_fd;

		/* tell kernel we're loading by "echo 1 > /sys/$DEVPATH/loading" */
		if (full_write(loading_fd, "1", 1) != 1)
			goto out;

		/* load firmware into /sys/$DEVPATH/data */
		data_fd = open("data", O_WRONLY);
		if (data_fd < 0)
			goto out;
		cnt = bb_copyfd_eof(firmware_fd, data_fd);
		if (ENABLE_FEATURE_CLEAN_UP)
			close(data_fd);
	}

	/* Tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading"
	 * Note: we emit -1 also if firmware file wasn't found.
	 * There are cases when otherwise kernel would wait for minutes
	 * before timing out.
	 */
	if (cnt > 0)
		full_write(loading_fd, "0", 1);
	else
		full_write(loading_fd, "-1", 2);

 out:
	xchdir("/dev");
	if (ENABLE_FEATURE_CLEAN_UP) {
		close(firmware_fd);
		close(loading_fd);
	}
}

static char *curtime(void)
{
	struct timeval tv;
	xgettimeofday(&tv);
	sprintf(
		strftime_HHMMSS(G.timestr, sizeof(G.timestr), &tv.tv_sec),
		".%06u",
		(unsigned)tv.tv_usec
	);
	return G.timestr;
}

static void open_mdev_log(const char *seq, unsigned my_pid)
{
	int logfd = open("mdev.log", O_WRONLY | O_APPEND);
	if (logfd >= 0) {
		xmove_fd(logfd, STDERR_FILENO);
		G.verbose = 2;
		applet_name = xasprintf("%s[%s]", applet_name, seq ? seq : utoa(my_pid));
	}
}

/* If it exists, does /dev/mdev.seq match $SEQNUM?
 * If it does not match, earlier mdev is running
 * in parallel, and we need to wait.
 * Active mdev pokes us with SIGCHLD to check the new file.
 */
static int
wait_for_seqfile(unsigned expected_seq)
{
	/* We time out after 2 sec */
	static const struct timespec ts = { 0, 32*1000*1000 };
	int timeout = 2000 / 32;
	int seq_fd = -1;
	int do_once = 1;
	sigset_t set_CHLD;

	sigemptyset(&set_CHLD);
	sigaddset(&set_CHLD, SIGCHLD);
	sigprocmask(SIG_BLOCK, &set_CHLD, NULL);

	for (;;) {
		int seqlen;
		char seqbuf[sizeof(long)*3 + 2];
		unsigned seqbufnum;

		if (seq_fd < 0) {
			seq_fd = open("mdev.seq", O_RDWR);
			if (seq_fd < 0)
				break;
			close_on_exec_on(seq_fd);
		}
		seqlen = pread(seq_fd, seqbuf, sizeof(seqbuf) - 1, 0);
		if (seqlen < 0) {
			close(seq_fd);
			seq_fd = -1;
			break;
		}
		seqbuf[seqlen] = '\0';
		if (seqbuf[0] == '\n' || seqbuf[0] == '\0') {
			/* seed file: write out seq ASAP */
			xwrite_str(seq_fd, utoa(expected_seq));
			xlseek(seq_fd, 0, SEEK_SET);
			dbg2s("first seq written");
			break;
		}
		seqbufnum = atoll(seqbuf);
		if (seqbufnum == expected_seq) {
			/* correct idx */
			break;
		}
		if (seqbufnum > expected_seq) {
			/* a later mdev runs already (this was seen by users to happen) */
			/* do not overwrite seqfile on exit */
			close(seq_fd);
			seq_fd = -1;
			break;
		}
		if (do_once) {
			dbg2("%s mdev.seq='%s', need '%u'", curtime(), seqbuf, expected_seq);
			do_once = 0;
		}
		if (sigtimedwait(&set_CHLD, NULL, &ts) >= 0) {
			dbg3("woken up");
			continue; /* don't decrement timeout! */
		}
		if (--timeout == 0) {
			dbg1("%s mdev.seq='%s'", "timed out", seqbuf);
			break;
		}
	}
	sigprocmask(SIG_UNBLOCK, &set_CHLD, NULL);
	return seq_fd;
}

static void signal_mdevs(unsigned my_pid)
{
	procps_status_t* p = NULL;
	while ((p = procps_scan(p, PSSCAN_ARGV0)) != NULL) {
		if (p->pid != my_pid
		 && p->argv0
		 && strcmp(bb_basename(p->argv0), "mdev") == 0
		) {
			kill(p->pid, SIGCHLD);
		}
	}
}

static void process_action(char *temp, unsigned my_pid)
{
	char *fw;
	char *seq;
	char *action;
	char *env_devname;
	char *env_devpath;
	unsigned seqnum = seqnum; /* for compiler */
	int seq_fd;
	smalluint op;

	/* Hotplug:
	 * env ACTION=... DEVPATH=... SUBSYSTEM=... [SEQNUM=...] mdev
	 * ACTION can be "add", "remove", "change"
	 * DEVPATH is like "/block/sda" or "/class/input/mice"
	 */
	env_devname = getenv("DEVNAME"); /* can be NULL */
	G.subsystem = getenv("SUBSYSTEM");
	action = getenv("ACTION");
	env_devpath = getenv("DEVPATH");
	if (!action || !env_devpath /*|| !G.subsystem*/)
		bb_show_usage();
	fw = getenv("FIRMWARE");
	seq = getenv("SEQNUM");
	op = index_in_strings(keywords, action);

	if (my_pid)
		open_mdev_log(seq, my_pid);

	seq_fd = -1;
	if (my_pid && seq) {
		seqnum = atoll(seq);
		seq_fd = wait_for_seqfile(seqnum);
	}

	dbg1("%s "
		"ACTION:%s SEQNUM:%s SUBSYSTEM:%s DEVNAME:%s DEVPATH:%s"
		"%s%s",
		curtime(),
		action, seq, G.subsystem, env_devname, env_devpath,
		fw ? " FW:" : "", fw ? fw : ""
	);

	snprintf(temp, PATH_MAX, "/sys%s", env_devpath);
	if (op == OP_remove) {
		/* Ignoring "remove firmware". It was reported
		 * to happen and to cause erroneous deletion
		 * of device nodes. */
		if (!fw)
			make_device(env_devname, temp, op);
	}
	else {
		make_device(env_devname, temp, op);
		if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
			if (op == OP_add && fw)
				load_firmware(fw, temp);
		}
	}

	if (seq_fd >= 0) {
		xwrite_str(seq_fd, utoa(seqnum + 1));
		signal_mdevs(my_pid);
	}
}

static void initial_scan(char *temp)
{
	struct stat st;

	xstat("/", &st);
	G.root_major = major(st.st_dev);
	G.root_minor = minor(st.st_dev);

	putenv((char*)"ACTION=add");

	/* Create all devices from /sys/dev hierarchy */
	recursive_action("/sys/dev",
			 ACTION_RECURSE | ACTION_FOLLOWLINKS,
			 fileAction, dirAction, temp);
}

#if ENABLE_FEATURE_MDEV_DAEMON

/*
 * The kernel (as of v5.4) will pass up to 32 environment variables with a
 * total of 2kiB on each event. On top of that the action string and device
 * path are added. Using a 3kiB buffer for the event should suffice in any
 * case.
 *
 * As far as the socket receive buffer size is concerned 2MiB proved to be too
 * small (see [1]). Udevd seems to use a whooping 128MiB. The socket receive
 * buffer size is just a resource limit. The buffers are allocated lazily so
 * the memory is not wasted.
 *
 * [1] http://lists.busybox.net/pipermail/busybox/2019-December/087665.html
 */
# define USER_RCVBUF (3 * 1024)
# define KERN_RCVBUF (128 * 1024 * 1024)
# define MAX_ENV 32

static int daemon_init(char *temp)
{
	int fd;

	/* Subscribe for UEVENT kernel messages */
	/* Without a sufficiently big RCVBUF, a ton of simultaneous events
	 * can trigger ENOBUFS on read, which is unrecoverable.
	 * Reproducer:
	 *	mdev -d
	 *	find /sys -name uevent -exec sh -c 'echo add >"{}"' ';'
	 */
	fd = create_and_bind_to_netlink(NETLINK_KOBJECT_UEVENT, 1 << 0, KERN_RCVBUF);

	/*
	 * Make inital scan after the uevent socket is alive and
	 * _before_ we fork away. Already open mdev.log because we work
	 * in daemon mode.
	 */
	initial_scan(temp);

	return fd;
}

static void daemon_loop(char *temp, int fd)
{
	for (;;) {
		char netbuf[USER_RCVBUF];
		char *env[MAX_ENV];
		char *s, *end;
		ssize_t len;
		int idx;

		len = safe_read(fd, netbuf, sizeof(netbuf) - 1);
		if (len < 0) {
			if (errno == ENOBUFS) {
				/*
				 * We ran out of socket receive buffer space.
				 * Start from scratch.
				 */
				dbg1s("uevent overrun, rescanning");
				close(fd);
				fd = daemon_init(temp);
				continue;
			}
			bb_simple_perror_msg_and_die("read");
		}
		end = netbuf + len;
		*end = '\0';

		idx = 0;
		s = netbuf;
		while (s < end && idx < MAX_ENV) {
			if (endofname(s)[0] == '=') {
				env[idx++] = s;
				putenv(s);
			}
			s += strlen(s) + 1;
		}

		process_action(temp, 0);

		while (idx)
			bb_unsetenv(env[--idx]);
	}
}
#endif

int mdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mdev_main(int argc UNUSED_PARAM, char **argv)
{
	enum {
		MDEV_OPT_SCAN       = 1 << 0,
		MDEV_OPT_SYSLOG     = 1 << 1,
		MDEV_OPT_DAEMON     = 1 << 2,
		MDEV_OPT_FOREGROUND = 1 << 3,
	};
	int opt;
	RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);

	INIT_G();

	/* We can be called as hotplug helper */
	/* Kernel cannot provide suitable stdio fds for us, do it ourself */
	bb_sanitize_stdio();

	/* Force the configuration file settings exactly */
	umask(0);

	xchdir("/dev");

	opt = getopt32(argv, "^"
		"sS" IF_FEATURE_MDEV_DAEMON("df") "v"
		"\0"
		"vv",
		&G.verbose);

#if ENABLE_FEATURE_MDEV_CONF
	G.filename = "/etc/mdev.conf";
	if (opt & (MDEV_OPT_SCAN|MDEV_OPT_DAEMON)) {
		/* Same as xrealloc_vector(NULL, 4, 0): */
		G.rule_vec = xzalloc((1 << 4) * sizeof(*G.rule_vec));
	}
#endif

	if (opt & MDEV_OPT_SYSLOG) {
		openlog(applet_name, LOG_PID, LOG_DAEMON);
		logmode |= LOGMODE_SYSLOG;
	}

#if ENABLE_FEATURE_MDEV_DAEMON
	if (opt & MDEV_OPT_DAEMON) {
		/* Daemon mode listening on uevent netlink socket. Fork away
		 * after initial scan so that caller can be sure everything
		 * is up-to-date when mdev process returns.
		 */
		int fd = daemon_init(temp);

		if (!(opt & MDEV_OPT_FOREGROUND)) {
			/* there is no point in logging to /dev/null */
			logmode &= ~LOGMODE_STDIO;
			bb_daemonize_or_rexec(0, argv);
		}

		daemon_loop(temp, fd);
	}
#endif
	if (opt & MDEV_OPT_SCAN) {
		/*
		 * Scan: mdev -s
		 */
		initial_scan(temp);
	} else {
		process_action(temp, getpid());

		dbg1("%s exiting", curtime());
	}

	if (ENABLE_FEATURE_CLEAN_UP)
		RELEASE_CONFIG_BUFFER(temp);

	return EXIT_SUCCESS;
}
