xref: /titanic_41/usr/src/lib/lvm/libmeta/common/meta_userflags.c (revision 40db2e2b777b79f3dd0d6d9629593a07f86b9c0a)
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  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1993-2002 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 /*
30  * get/set user flags for the metadevices (FOR GUI USE ONLY)
31  */
32 
33 #include <meta.h>
34 
35 /*
36  * get user flags stored in the common unit structure.
37  */
38 int
39 meta_getuserflags(
40 	mdsetname_t	*sp,
41 	mdname_t	*np,
42 	uint_t		*userflags,
43 	md_error_t	*ep
44 )
45 {
46 	md_common_t	*mdp;
47 
48 	/* should have a set */
49 	assert(sp != NULL);
50 	assert(sp->setno == MD_MIN2SET(meta_getminor(np->dev)));
51 
52 	if ((mdp = meta_get_unit(sp, np, ep)) == NULL)
53 		return (-1);
54 
55 	*userflags = mdp->user_flags;
56 	return (0);
57 }
58 
59 
60 /*
61  * set user flags, stored in the common unit structure.
62  */
63 int
64 meta_setuserflags(
65 	mdsetname_t	*sp,
66 	mdname_t	*np,
67 	uint_t		userflags,
68 	md_error_t	*ep
69 )
70 {
71 	md_set_userflags_t	msu;
72 	char			*miscname;
73 
74 	/* should have a set */
75 	assert(sp != NULL);
76 	assert(sp->setno == MD_MIN2SET(meta_getminor(np->dev)));
77 
78 	/* check name */
79 	if (metachkmeta(np, ep) != 0)
80 		return (-1);
81 
82 	/* get misc name */
83 	if ((miscname = metagetmiscname(np, ep)) == NULL)
84 		return (-1);
85 
86 	/* set parameters */
87 	(void) memset(&msu, 0, sizeof (msu));
88 	MD_SETDRIVERNAME(&msu, miscname, sp->setno);
89 	msu.mnum = meta_getminor(np->dev);
90 	msu.userflags = userflags;
91 	if (metaioctl(MD_IOCSET_FLAGS, &msu, &msu.mde, np->cname) != 0)
92 		return (mdstealerror(ep, &msu.mde));
93 
94 	/* clear cache */
95 	meta_invalidate_name(np);
96 
97 	return (0);
98 }
99