savecore: accept device names without the /dev/ prefix
dumpon has accepted device names without the prefix ever since r291207. Since dumpon and savecore are always paired, they ought to accept the same arguments. Prior to this change, specifying 'dumpdev="da3"' in /etc/rc.conf, for example, would result in dumpon working just fine but savecore complaining that "Dump device does not exist". PR: 247618 Reviewed by: cem, bcr MFC after: 2 weeks Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D25500
This commit is contained in:
parent
46cac10b3b
commit
81884a247c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362790
@ -973,6 +973,44 @@ DoFile(const char *savedir, int savedirfd, const char *device)
|
|||||||
close(fddev);
|
close(fddev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Prepend "/dev/" to any arguments that don't already have it */
|
||||||
|
static char **
|
||||||
|
devify(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char **devs;
|
||||||
|
int i, l;
|
||||||
|
|
||||||
|
devs = malloc(argc * sizeof(*argv));
|
||||||
|
if (devs == NULL) {
|
||||||
|
logmsg(LOG_ERR, "malloc(): %m");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
for (i = 0; i < argc; i++) {
|
||||||
|
if (strncmp(argv[i], _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||||
|
devs[i] = strdup(argv[i]);
|
||||||
|
else {
|
||||||
|
char *fullpath;
|
||||||
|
|
||||||
|
fullpath = malloc(PATH_MAX);
|
||||||
|
if (fullpath == NULL) {
|
||||||
|
logmsg(LOG_ERR, "malloc(): %m");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
l = snprintf(fullpath, PATH_MAX, "%s%s", _PATH_DEV,
|
||||||
|
argv[i]);
|
||||||
|
if (l < 0) {
|
||||||
|
logmsg(LOG_ERR, "snprintf(): %m");
|
||||||
|
exit(1);
|
||||||
|
} else if (l >= PATH_MAX) {
|
||||||
|
logmsg(LOG_ERR, "device name too long");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
devs[i] = fullpath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (devs);
|
||||||
|
}
|
||||||
|
|
||||||
static char **
|
static char **
|
||||||
enum_dumpdevs(int *argcp)
|
enum_dumpdevs(int *argcp)
|
||||||
{
|
{
|
||||||
@ -1069,6 +1107,7 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
cap_rights_t rights;
|
cap_rights_t rights;
|
||||||
const char *savedir;
|
const char *savedir;
|
||||||
|
char **devs;
|
||||||
int i, ch, error, savedirfd;
|
int i, ch, error, savedirfd;
|
||||||
|
|
||||||
checkfor = compress = clear = force = keep = verbose = 0;
|
checkfor = compress = clear = force = keep = verbose = 0;
|
||||||
@ -1132,7 +1171,9 @@ main(int argc, char **argv)
|
|||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
argv = enum_dumpdevs(&argc);
|
devs = enum_dumpdevs(&argc);
|
||||||
|
else
|
||||||
|
devs = devify(argc, argv);
|
||||||
|
|
||||||
savedirfd = open(savedir, O_RDONLY | O_DIRECTORY);
|
savedirfd = open(savedir, O_RDONLY | O_DIRECTORY);
|
||||||
if (savedirfd < 0) {
|
if (savedirfd < 0) {
|
||||||
@ -1148,10 +1189,10 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Enter capability mode. */
|
/* Enter capability mode. */
|
||||||
init_caps(argc, argv);
|
init_caps(argc, devs);
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
DoFile(savedir, savedirfd, argv[i]);
|
DoFile(savedir, savedirfd, devs[i]);
|
||||||
|
|
||||||
/* Emit minimal output. */
|
/* Emit minimal output. */
|
||||||
if (nfound == 0) {
|
if (nfound == 0) {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 23, 2020
|
.Dd June 28, 2020
|
||||||
.Dt RC.CONF 5
|
.Dt RC.CONF 5
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -3469,7 +3469,9 @@ the first suitable swap device listed in
|
|||||||
.Pa /etc/fstab
|
.Pa /etc/fstab
|
||||||
will be used as dump device.
|
will be used as dump device.
|
||||||
Otherwise, the value of this variable is passed as the argument to
|
Otherwise, the value of this variable is passed as the argument to
|
||||||
.Xr dumpon 8 .
|
.Xr dumpon 8
|
||||||
|
and
|
||||||
|
.Xr savecore 8 .
|
||||||
To disable crash dumps, set this variable to
|
To disable crash dumps, set this variable to
|
||||||
.Dq Li NO .
|
.Dq Li NO .
|
||||||
.It Va dumpon_flags
|
.It Va dumpon_flags
|
||||||
|
Loading…
Reference in New Issue
Block a user