mdev: make usage text more useful
function old new delta packed_usage 26235 26291 +56
This commit is contained in:
parent
e8a796828e
commit
aafbae6181
@ -2556,8 +2556,14 @@
|
|||||||
#define mdev_full_usage "\n\n" \
|
#define mdev_full_usage "\n\n" \
|
||||||
" -s Scan /sys and populate /dev during system boot\n" \
|
" -s Scan /sys and populate /dev during system boot\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
"Called with no options (via hotplug) it uses environment variables\n" \
|
"It can be run by kernel as a hotplug helper. To activate it:\n" \
|
||||||
"to determine which device to add/remove."
|
" 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 "" \
|
#define mdev_notes_usage "" \
|
||||||
USE_FEATURE_MDEV_CONFIG( \
|
USE_FEATURE_MDEV_CONFIG( \
|
||||||
|
@ -62,13 +62,13 @@ static void make_device(char *path, int delete)
|
|||||||
struct bb_uidgid_t ugid = { 0, 0 };
|
struct bb_uidgid_t ugid = { 0, 0 };
|
||||||
parser_t *parser;
|
parser_t *parser;
|
||||||
char *tokens[5];
|
char *tokens[5];
|
||||||
#endif
|
# if ENABLE_FEATURE_MDEV_EXEC
|
||||||
#if ENABLE_FEATURE_MDEV_EXEC
|
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
#endif
|
# endif
|
||||||
#if ENABLE_FEATURE_MDEV_RENAME
|
# if ENABLE_FEATURE_MDEV_RENAME
|
||||||
char *alias = NULL;
|
char *alias = NULL;
|
||||||
char aliaslink = aliaslink; /* for compiler */
|
char aliaslink = aliaslink; /* for compiler */
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
char *dev_maj_min = path + strlen(path);
|
char *dev_maj_min = path + strlen(path);
|
||||||
|
|
||||||
@ -168,21 +168,21 @@ static void make_device(char *path, int delete)
|
|||||||
|
|
||||||
val = tokens[3];
|
val = tokens[3];
|
||||||
/* 4th field (opt): >alias */
|
/* 4th field (opt): >alias */
|
||||||
#if ENABLE_FEATURE_MDEV_RENAME
|
# if ENABLE_FEATURE_MDEV_RENAME
|
||||||
if (!val)
|
if (!val)
|
||||||
break;
|
break;
|
||||||
aliaslink = *val;
|
aliaslink = *val;
|
||||||
if (aliaslink == '>' || aliaslink == '=') {
|
if (aliaslink == '>' || aliaslink == '=') {
|
||||||
char *s;
|
char *s;
|
||||||
#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
|
# if ENABLE_FEATURE_MDEV_RENAME_REGEXP
|
||||||
char *p;
|
char *p;
|
||||||
unsigned i, n;
|
unsigned i, n;
|
||||||
#endif
|
# endif
|
||||||
char *a = val;
|
char *a = val;
|
||||||
s = strchrnul(val, ' ');
|
s = strchrnul(val, ' ');
|
||||||
val = (s[0] && s[1]) ? s+1 : NULL;
|
val = (s[0] && s[1]) ? s+1 : NULL;
|
||||||
s[0] = '\0';
|
s[0] = '\0';
|
||||||
#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
|
# if ENABLE_FEATURE_MDEV_RENAME_REGEXP
|
||||||
/* substitute %1..9 with off[1..9], if any */
|
/* substitute %1..9 with off[1..9], if any */
|
||||||
n = 0;
|
n = 0;
|
||||||
s = a;
|
s = a;
|
||||||
@ -206,13 +206,13 @@ static void make_device(char *path, int delete)
|
|||||||
p++;
|
p++;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
alias = xstrdup(a + 1);
|
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 */
|
/* The rest (opt): command to run */
|
||||||
if (!val)
|
if (!val)
|
||||||
break;
|
break;
|
||||||
@ -233,7 +233,7 @@ static void make_device(char *path, int delete)
|
|||||||
command = xstrdup(val + 1);
|
command = xstrdup(val + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
/* end of field parsing */
|
/* end of field parsing */
|
||||||
break; /* we found matching line, stop */
|
break; /* we found matching line, stop */
|
||||||
} /* end of "while line is read from /etc/mdev.conf" */
|
} /* end of "while line is read from /etc/mdev.conf" */
|
||||||
@ -255,7 +255,7 @@ static void make_device(char *path, int delete)
|
|||||||
#if ENABLE_FEATURE_MDEV_CONF
|
#if ENABLE_FEATURE_MDEV_CONF
|
||||||
chown(device_name, ugid.uid, ugid.gid);
|
chown(device_name, ugid.uid, ugid.gid);
|
||||||
|
|
||||||
#if ENABLE_FEATURE_MDEV_RENAME
|
# if ENABLE_FEATURE_MDEV_RENAME
|
||||||
if (alias) {
|
if (alias) {
|
||||||
alias = build_alias(alias, device_name);
|
alias = build_alias(alias, device_name);
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ static void make_device(char *path, int delete)
|
|||||||
|
|
||||||
free(alias);
|
free(alias);
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
xchdir("/dev");
|
xchdir("/dev");
|
||||||
|
|
||||||
if (argv[1] && !strcmp(argv[1], "-s")) {
|
if (argv[1] && strcmp(argv[1], "-s") == 0) {
|
||||||
/* Scan:
|
/* Scan:
|
||||||
* mdev -s
|
* mdev -s
|
||||||
*/
|
*/
|
||||||
@ -501,5 +501,5 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
RELEASE_CONFIG_BUFFER(temp);
|
RELEASE_CONFIG_BUFFER(temp);
|
||||||
|
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user