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
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Checks for a match with the the dump slice.
38 #include <sys/param.h>
39 #include <sys/types.h>
42 #include <sys/dumpadm.h>
44 #include "libdiskmgt.h"
45 #include "disks_private.h"
47 /* Cached file descriptor for /dev/dump. */
48 static int dump_fd
= -1;
50 static mutex_t dump_lock
= DEFAULTMUTEX
;
53 * Check the dump device against the input slice.
56 inuse_dump(char *slice
, nvlist_t
*attrs
, int *errp
)
60 char device
[MAXPATHLEN
];
68 * We only want to open /dev/dump once instead of for every
69 * slice so we cache the open file descriptor. The ioctl
70 * is cheap so we can do that for every slice.
72 (void) mutex_lock(&dump_lock
);
75 if ((dump_fd
= open("/dev/dump", O_RDONLY
)) >= 0)
76 (void) fcntl(dump_fd
, F_SETFD
, FD_CLOEXEC
);
81 (void) mutex_unlock(&dump_lock
);
84 if (ioctl(fd
, DIOCGETDEV
, device
) != -1) {
85 if (strcmp(slice
, device
) == 0) {
86 libdiskmgt_add_str(attrs
, DM_USED_BY
,
88 libdiskmgt_add_str(attrs
, DM_USED_NAME
,