/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <libdiskmgt.h>
#include <libzfs.h>
#include "dconf.h"
#include "minfree.h"
#include "utils.h"
#include "swap.h"
typedef struct dc_token {
const char *tok_name;
} dc_token_t;
};
/* The pages included in the dump */
/*
* Permissions and ownership for the configuration file:
*/
static void
{
/*
* Default device for dumps is 'swap' (appropriate swap device),
* which is compatible with pre-dumpadm behavior.
*/
}
/*
* Default is contents kernel, savecore enabled on reboot,
* savecore saves compressed core files.
*/
}
int
{
int line;
return (-1);
}
/*
* Attempt to open the file read-only.
*/
return (-1);
}
fpmode = "r";
}
return (-1);
}
/*
* If we're in override mode, the current kernel settings override the
* default settings and anything invalid in the configuration file.
*/
if (dcmode == DC_OVERRIDE)
(void) dconf_getdev(dcp);
int len;
continue;
/*
* Look for "name=value", with optional whitespace on either
* side, terminated by a newline, and consuming the whole line.
*/
/* LINTED - unbounded string specifier */
/*
* Locate a matching token in the tokens[] table,
* and invoke its parsing function.
*/
"warning: invalid %s\n"),
}
break;
}
}
/*
* If we hit the end of the tokens[] table,
* no matching token was found.
*/
}
} else {
}
}
/*
* If we're not in override mode, the current kernel settings
* override the settings read from the configuration file.
*/
if (dcmode == DC_CURRENT)
return (dconf_getdev(dcp));
return (0);
}
int
{
int status = 0;
status = -1;
}
status = -1;
} else
}
return (status);
}
int
{
return (0);
}
return (-1);
}
int
{
return (-1);
}
return (-1);
}
(void) fputs("#\n# dumpadm.conf\n#\n"
"# Configuration parameters for system crash dump.\n"
"# Do NOT edit this file by hand -- use dumpadm(1m) instead.\n"
return (-1);
}
}
return (0);
}
static int
{
if (fd >= 0) {
return (status);
}
return (-1);
}
static int
{
/*
* First try: open and fstat each swap entry. If either system
* call fails, arbitrarily prefer the other entry.
*/
return (prefer_s2);
return (prefer_s1);
/*
* Second try: if both entries are block devices, or if
* neither is a block device, prefer the larger.
*/
return (prefer_s2);
return (prefer_s1);
}
/*
* Third try: prefer the entry that is a block device.
*/
return (prefer_s2);
return (prefer_s1);
}
static int
{
return (0);
switch (errno) {
case ENOTSUP:
break;
case EBUSY:
break;
case EBADR:
/* ZFS pool is too fragmented to support a dump device */
break;
default:
/*
* NOTE: The stmsboot(1M) command's boot-up script parses this
* error to get the dump device name. If you change the format
* of this message, make sure that stmsboot(1M) is in sync.
*/
}
return (-1);
}
int
{
int oconf;
int error;
char *msg;
error = 0;
if (error != 0) {
} else {
return (-1);
}
}
/*
* Save the existing dump configuration in case something goes wrong.
*/
return (-1);
}
oconf &= DUMP_CONTENT;
return (-1);
}
int i;
goto err;
goto err;
}
(int (*)(const void *, const void *))dconf_swap_compare);
/*
* Iterate through the prioritized list of swap entries,
* trying to configure one as the dump device.
*/
break;
}
}
"as the dump device\n"));
goto err;
}
return (-1);
}
/*
* If we're not in forcible update mode, then fail the change
* if the selected device cannot be used as the dump device,
* or if it is not big enough to hold the dump.
*/
uint64_t d;
goto err;
goto err;
}
if ((error = zvol_check_dump_config(
goto err;
goto err;
}
"hold a system dump\ndump size %llu "
"bytes, device size %lld bytes\n"),
goto err;
}
}
goto err;
}
/*
* Now that we've updated the dump device, we need to issue another
* ioctl to re-read the config flags to determine whether we
* obtained DUMP_EXCL access on our dump device.
*/
return (-1);
}
return (0);
err:
return (-1);
}
int
{
int err;
if (err)
return (err == 0);
}
int
{
uint64_t d;
return (-1);
}
return (0);
}
void
{
char *content;
else
} else {
"(dumps disabled)\n"));
}
else
min / 1024);
}
gettext("on"));
}
int
{
return (0);
}
return (0);
}
if (valid_abspath(buf)) {
return (0);
}
return (-1);
}
int
{
if (valid_abspath(buf)) {
return (0);
}
return (-1);
}
int
{
return (0);
}
return (0);
}
return (0);
}
return (-1);
}
int
{
return (0);
}
return (0);
}
return (-1);
}
int
{
return (0);
}
return (0);
}
return (-1);
}
static int
{
const char *content;
else
}
static int
{
}
static int
{
DC_STR_NO : DC_STR_YES));
}
static int
{
DC_STR_ON : DC_STR_OFF));
}
static int
{
}