summaryrefslogtreecommitdiff
path: root/usr/src/cmd/dumpadm
diff options
context:
space:
mode:
authorsjelinek <none@none>2005-10-27 09:01:18 -0700
committersjelinek <none@none>2005-10-27 09:01:18 -0700
commit3e1bd7a2aaeb6188caef90679b98088cfef1edc6 (patch)
treef96d6ce4a25ea39514dd8b1fd2a23978cabc5055 /usr/src/cmd/dumpadm
parent108322fb1c3ed341aba9c80c9774df0ed9e35768 (diff)
downloadillumos-joyent-3e1bd7a2aaeb6188caef90679b98088cfef1edc6.tar.gz
PSARC 2004/776 device checking for fs utilities
PSARC 2005/461 Device in use checking environment variables 5084421 libdiskmgt needs to detect in use ZFS data 5085739 remove workaround for bug 4725434 6194015 Device in use checking for Solaris utilities-PSARC/2004/776 6261853 libdiskmgt does not work correctly in all cases on amd64 6268374 libdiskmgt allocates incorrect size for readdir_r() dirent argument 6291309 PSARC/2005/461 - libdiskmgt should enable bypassing of inuse checking 6301815 PSARC/2005/461-Need Sun private libdiskmgt flag for use during install to disable sysevent starting --HG-- rename : usr/src/cmd/format/checkmount.c => usr/src/cmd/format/checkdev.c rename : usr/src/cmd/format/checkmount.h => usr/src/cmd/format/checkdev.h
Diffstat (limited to 'usr/src/cmd/dumpadm')
-rw-r--r--usr/src/cmd/dumpadm/Makefile5
-rw-r--r--usr/src/cmd/dumpadm/dconf.c24
-rw-r--r--usr/src/cmd/dumpadm/dconf.h6
-rw-r--r--usr/src/cmd/dumpadm/main.c13
4 files changed, 35 insertions, 13 deletions
diff --git a/usr/src/cmd/dumpadm/Makefile b/usr/src/cmd/dumpadm/Makefile
index 64084c9094..108a0f9fe4 100644
--- a/usr/src/cmd/dumpadm/Makefile
+++ b/usr/src/cmd/dumpadm/Makefile
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
@@ -32,6 +32,7 @@ SVCMETHOD= svc-dumpadm
OBJS = main.o dconf.o minfree.o utils.o swap.o
SRCS = $(OBJS:.o=.c)
+
lint := LINTFLAGS = -mx
include ../Makefile.cmd
@@ -45,6 +46,8 @@ GROUP = bin
ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
$(ROOTMANIFEST) := FILEMODE = 0444
+LDLIBS += -ldiskmgt
+
.KEEP_STATE:
all: $(PROG)
diff --git a/usr/src/cmd/dumpadm/dconf.c b/usr/src/cmd/dumpadm/dconf.c
index a67f1a55ec..ec287078d7 100644
--- a/usr/src/cmd/dumpadm/dconf.c
+++ b/usr/src/cmd/dumpadm/dconf.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
+#include <libdiskmgt.h>
#include "dconf.h"
#include "minfree.h"
@@ -50,6 +51,7 @@ typedef struct dc_token {
int (*tok_print)(const dumpconf_t *, FILE *);
} dc_token_t;
+
static int print_device(const dumpconf_t *, FILE *);
static int print_savdir(const dumpconf_t *, FILE *);
static int print_content(const dumpconf_t *, FILE *);
@@ -344,9 +346,25 @@ dconf_dev_ioctl(dumpconf_t *dcp, int cmd)
}
int
-dconf_update(dumpconf_t *dcp)
+dconf_update(dumpconf_t *dcp, int checkinuse)
{
- int oconf;
+ int oconf;
+ int error;
+ char *msg;
+
+ error = 0;
+
+ if (checkinuse && (dm_inuse(dcp->dc_device, &msg, DM_WHO_DUMP,
+ &error) || error)) {
+ if (error != 0) {
+ warn(gettext("failed to determine if %s is"
+ " in use"), dcp->dc_device);
+ } else {
+ warn(msg);
+ free(msg);
+ return (-1);
+ }
+ }
/*
* Save the existing dump configuration in case something goes wrong.
diff --git a/usr/src/cmd/dumpadm/dconf.h b/usr/src/cmd/dumpadm/dconf.h
index 0a35bc9217..b22488ec2a 100644
--- a/usr/src/cmd/dumpadm/dconf.h
+++ b/usr/src/cmd/dumpadm/dconf.h
@@ -20,8 +20,8 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1998 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
#ifndef _DCONF_H
@@ -64,7 +64,7 @@ extern int dconf_open(dumpconf_t *, const char *, const char *, int);
extern int dconf_getdev(dumpconf_t *);
extern int dconf_close(dumpconf_t *);
extern int dconf_write(dumpconf_t *);
-extern int dconf_update(dumpconf_t *);
+extern int dconf_update(dumpconf_t *, int);
extern void dconf_print(dumpconf_t *, FILE *);
extern int dconf_str2device(dumpconf_t *, char *);
diff --git a/usr/src/cmd/dumpadm/main.c b/usr/src/cmd/dumpadm/main.c
index e6c8c45f6d..a1255a7ae6 100644
--- a/usr/src/cmd/dumpadm/main.c
+++ b/usr/src/cmd/dumpadm/main.c
@@ -20,8 +20,8 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1998-2000 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -53,7 +53,7 @@ main(int argc, char *argv[])
u_longlong_t minf;
struct stat st;
int c;
-
+ int dflag = 0; /* for checking in use during -d ops */
int dcmode = DC_CURRENT; /* kernel settings override unless -u */
int modified = 0; /* have we modified the dump config? */
char *minfstr = NULL; /* string value of -m argument */
@@ -116,10 +116,10 @@ main(int argc, char *argv[])
return (E_USAGE);
modified++;
break;
-
case 'd':
if (dconf_str2device(&dc, optarg) == -1)
return (E_USAGE);
+ dflag++;
modified++;
break;
@@ -166,7 +166,7 @@ main(int argc, char *argv[])
* fails, we re-load the kernel configuration and write that
* out to the file in order to force the file in sync.
*/
- if (dconf_update(&dc) == -1)
+ if (dconf_update(&dc, 0) == -1)
(void) dconf_getdev(&dc);
if (dconf_write(&dc) == -1)
return (E_ERROR);
@@ -176,7 +176,8 @@ main(int argc, char *argv[])
* If we're modifying the configuration, then try
* to update it, and write out the file if successful.
*/
- if (dconf_update(&dc) == -1 || dconf_write(&dc) == -1)
+ if (dconf_update(&dc, dflag) == -1 ||
+ dconf_write(&dc) == -1)
return (E_ERROR);
}