#define mdev_full_usage "\n\n" \
" -s Scan /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."
+ "It can be run by kernel as a hotplug helper. To activate it:\n" \
+ " echo /bin/mdev >/proc/sys/kernel/hotplug\n" \
+ USE_FEATURE_MDEV_CONF( \
+ "It uses /etc/mdev.conf with lines\n" \
+ "DEVNAME UID:GID PERM" \
+ USE_FEATURE_MDEV_RENAME(" [>|=PATH]") \
+ USE_FEATURE_MDEV_EXEC(" [@|$|*COMMAND]") \
+ ) \
#define mdev_notes_usage "" \
USE_FEATURE_MDEV_CONFIG( \
struct bb_uidgid_t ugid = { 0, 0 };
parser_t *parser;
char *tokens[5];
-#endif
-#if ENABLE_FEATURE_MDEV_EXEC
+# if ENABLE_FEATURE_MDEV_EXEC
char *command = NULL;
-#endif
-#if ENABLE_FEATURE_MDEV_RENAME
+# endif
+# if ENABLE_FEATURE_MDEV_RENAME
char *alias = NULL;
char aliaslink = aliaslink; /* for compiler */
+# endif
#endif
char *dev_maj_min = path + strlen(path);
val = tokens[3];
/* 4th field (opt): >alias */
-#if ENABLE_FEATURE_MDEV_RENAME
+# if ENABLE_FEATURE_MDEV_RENAME
if (!val)
break;
aliaslink = *val;
if (aliaslink == '>' || aliaslink == '=') {
char *s;
-#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
+# if ENABLE_FEATURE_MDEV_RENAME_REGEXP
char *p;
unsigned i, n;
-#endif
+# endif
char *a = val;
s = strchrnul(val, ' ');
val = (s[0] && s[1]) ? s+1 : NULL;
s[0] = '\0';
-#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
+# if ENABLE_FEATURE_MDEV_RENAME_REGEXP
/* substitute %1..9 with off[1..9], if any */
n = 0;
s = a;
p++;
s++;
}
-#else
+# else
alias = xstrdup(a + 1);
-#endif
+# endif
}
-#endif /* ENABLE_FEATURE_MDEV_RENAME */
+# endif /* ENABLE_FEATURE_MDEV_RENAME */
-#if ENABLE_FEATURE_MDEV_EXEC
+# if ENABLE_FEATURE_MDEV_EXEC
/* The rest (opt): command to run */
if (!val)
break;
command = xstrdup(val + 1);
}
}
-#endif
+# endif
/* end of field parsing */
break; /* we found matching line, stop */
} /* end of "while line is read from /etc/mdev.conf" */
#if ENABLE_FEATURE_MDEV_CONF
chown(device_name, ugid.uid, ugid.gid);
-#if ENABLE_FEATURE_MDEV_RENAME
+# if ENABLE_FEATURE_MDEV_RENAME
if (alias) {
alias = build_alias(alias, device_name);
free(alias);
}
-#endif
+# endif
#endif
}
xchdir("/dev");
- if (argv[1] && !strcmp(argv[1], "-s")) {
+ if (argv[1] && strcmp(argv[1], "-s") == 0) {
/* Scan:
* mdev -s
*/
if (ENABLE_FEATURE_CLEAN_UP)
RELEASE_CONFIG_BUFFER(temp);
- return 0;
+ return EXIT_SUCCESS;
}