main.c (7c478bd95313f5f23a4c958a745db2134aa03244) main.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 (c) 1998-2000 by Sun Microsystems, Inc.
24 * 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/stat.h>
30#include <locale.h>
31#include <unistd.h>
32#include <stdlib.h>

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

48int
49main(int argc, char *argv[])
50{
51 const char *pname = getpname(argv[0]);
52
53 u_longlong_t minf;
54 struct stat st;
55 int c;
25 */
26
27#pragma ident "%Z%%M% %I% %E% SMI"
28
29#include <sys/stat.h>
30#include <locale.h>
31#include <unistd.h>
32#include <stdlib.h>

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

48int
49main(int argc, char *argv[])
50{
51 const char *pname = getpname(argv[0]);
52
53 u_longlong_t minf;
54 struct stat st;
55 int c;
56
56 int dflag = 0; /* for checking in use during -d ops */
57 int dcmode = DC_CURRENT; /* kernel settings override unless -u */
58 int modified = 0; /* have we modified the dump config? */
59 char *minfstr = NULL; /* string value of -m argument */
60 dumpconf_t dc; /* current configuration */
61
62 (void) setlocale(LC_ALL, "");
63 (void) textdomain(TEXT_DOMAIN);
64

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

111 for (optind = 1; optind < argc; optind++) {
112 while ((c = getopt(argc, argv, OPTS)) != (int)EOF) {
113 switch (c) {
114 case 'c':
115 if (dconf_str2content(&dc, optarg) == -1)
116 return (E_USAGE);
117 modified++;
118 break;
57 int dcmode = DC_CURRENT; /* kernel settings override unless -u */
58 int modified = 0; /* have we modified the dump config? */
59 char *minfstr = NULL; /* string value of -m argument */
60 dumpconf_t dc; /* current configuration */
61
62 (void) setlocale(LC_ALL, "");
63 (void) textdomain(TEXT_DOMAIN);
64

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

111 for (optind = 1; optind < argc; optind++) {
112 while ((c = getopt(argc, argv, OPTS)) != (int)EOF) {
113 switch (c) {
114 case 'c':
115 if (dconf_str2content(&dc, optarg) == -1)
116 return (E_USAGE);
117 modified++;
118 break;
119
120 case 'd':
121 if (dconf_str2device(&dc, optarg) == -1)
122 return (E_USAGE);
119 case 'd':
120 if (dconf_str2device(&dc, optarg) == -1)
121 return (E_USAGE);
122 dflag++;
123 modified++;
124 break;
125
126 case 'm':
127 minfstr = optarg;
128 break;
129
130 case 'n':

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

161 }
162
163 if (dcmode == DC_OVERRIDE) {
164 /*
165 * In override mode, we try to force an update. If this
166 * fails, we re-load the kernel configuration and write that
167 * out to the file in order to force the file in sync.
168 */
123 modified++;
124 break;
125
126 case 'm':
127 minfstr = optarg;
128 break;
129
130 case 'n':

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

161 }
162
163 if (dcmode == DC_OVERRIDE) {
164 /*
165 * In override mode, we try to force an update. If this
166 * fails, we re-load the kernel configuration and write that
167 * out to the file in order to force the file in sync.
168 */
169 if (dconf_update(&dc) == -1)
169 if (dconf_update(&dc, 0) == -1)
170 (void) dconf_getdev(&dc);
171 if (dconf_write(&dc) == -1)
172 return (E_ERROR);
173
174 } else if (modified) {
175 /*
176 * If we're modifying the configuration, then try
177 * to update it, and write out the file if successful.
178 */
170 (void) dconf_getdev(&dc);
171 if (dconf_write(&dc) == -1)
172 return (E_ERROR);
173
174 } else if (modified) {
175 /*
176 * If we're modifying the configuration, then try
177 * to update it, and write out the file if successful.
178 */
179 if (dconf_update(&dc) == -1 || dconf_write(&dc) == -1)
179 if (dconf_update(&dc, dflag) == -1 ||
180 dconf_write(&dc) == -1)
180 return (E_ERROR);
181 }
182
183 if (dcmode == DC_CURRENT)
184 dconf_print(&dc, stdout);
185
186 if (dconf_close(&dc) == -1)
187 warn(gettext("failed to close configuration file"));
188
189 return (E_SUCCESS);
190}
181 return (E_ERROR);
182 }
183
184 if (dcmode == DC_CURRENT)
185 dconf_print(&dc, stdout);
186
187 if (dconf_close(&dc) == -1)
188 warn(gettext("failed to close configuration file"));
189
190 return (E_SUCCESS);
191}