dconf.c (7c478bd95313f5f23a4c958a745db2134aa03244) dconf.c (3e1bd7a2aaeb6188caef90679b98088cfef1edc6)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *

--- 6 unchanged lines hidden (view full) ---

15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *

--- 6 unchanged lines hidden (view full) ---

15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident "%Z%%M% %I% %E% SMI"
28
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <sys/swap.h>
32#include <sys/dumpadm.h>
33#include <sys/utsname.h>
34
35#include <unistd.h>
36#include <string.h>
37#include <stdlib.h>
38#include <stdio.h>
39#include <fcntl.h>
40#include <errno.h>
24 * Use is subject to license terms.
25 */
26
27#pragma ident "%Z%%M% %I% %E% SMI"
28
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <sys/swap.h>
32#include <sys/dumpadm.h>
33#include <sys/utsname.h>
34
35#include <unistd.h>
36#include <string.h>
37#include <stdlib.h>
38#include <stdio.h>
39#include <fcntl.h>
40#include <errno.h>
41#include <libdiskmgt.h>
41
42#include "dconf.h"
43#include "minfree.h"
44#include "utils.h"
45#include "swap.h"
46
47typedef struct dc_token {
48 const char *tok_name;
49 int (*tok_parse)(dumpconf_t *, char *);
50 int (*tok_print)(const dumpconf_t *, FILE *);
51} dc_token_t;
52
42
43#include "dconf.h"
44#include "minfree.h"
45#include "utils.h"
46#include "swap.h"
47
48typedef struct dc_token {
49 const char *tok_name;
50 int (*tok_parse)(dumpconf_t *, char *);
51 int (*tok_print)(const dumpconf_t *, FILE *);
52} dc_token_t;
53
54
53static int print_device(const dumpconf_t *, FILE *);
54static int print_savdir(const dumpconf_t *, FILE *);
55static int print_content(const dumpconf_t *, FILE *);
56static int print_enable(const dumpconf_t *, FILE *);
57
58static const dc_token_t tokens[] = {
59 { "DUMPADM_DEVICE", dconf_str2device, print_device },
60 { "DUMPADM_SAVDIR", dconf_str2savdir, print_savdir },

--- 278 unchanged lines hidden (view full) ---

339 * of this message, make sure that stmsboot(1M) is in sync.
340 */
341 warn(gettext("cannot use %s as dump device"), dcp->dc_device);
342 }
343 return (-1);
344}
345
346int
55static int print_device(const dumpconf_t *, FILE *);
56static int print_savdir(const dumpconf_t *, FILE *);
57static int print_content(const dumpconf_t *, FILE *);
58static int print_enable(const dumpconf_t *, FILE *);
59
60static const dc_token_t tokens[] = {
61 { "DUMPADM_DEVICE", dconf_str2device, print_device },
62 { "DUMPADM_SAVDIR", dconf_str2savdir, print_savdir },

--- 278 unchanged lines hidden (view full) ---

341 * of this message, make sure that stmsboot(1M) is in sync.
342 */
343 warn(gettext("cannot use %s as dump device"), dcp->dc_device);
344 }
345 return (-1);
346}
347
348int
347dconf_update(dumpconf_t *dcp)
349dconf_update(dumpconf_t *dcp, int checkinuse)
348{
350{
349 int oconf;
351 int oconf;
352 int error;
353 char *msg;
350
354
355 error = 0;
356
357 if (checkinuse && (dm_inuse(dcp->dc_device, &msg, DM_WHO_DUMP,
358 &error) || error)) {
359 if (error != 0) {
360 warn(gettext("failed to determine if %s is"
361 " in use"), dcp->dc_device);
362 } else {
363 warn(msg);
364 free(msg);
365 return (-1);
366 }
367 }
368
351 /*
352 * Save the existing dump configuration in case something goes wrong.
353 */
354 if ((oconf = ioctl(dcp->dc_dump_fd, DIOCGETCONF, 0)) == -1) {
355 warn(gettext("failed to get kernel dump configuration"));
356 return (-1);
357 }
358

--- 240 unchanged lines hidden ---
369 /*
370 * Save the existing dump configuration in case something goes wrong.
371 */
372 if ((oconf = ioctl(dcp->dc_dump_fd, DIOCGETCONF, 0)) == -1) {
373 warn(gettext("failed to get kernel dump configuration"));
374 return (-1);
375 }
376

--- 240 unchanged lines hidden ---