xref: /titanic_41/usr/src/common/lvm/md_revchk.c (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
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 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 /*
31  * Need to include md_mddb.h for the MDDB_REV_MAJOR and MDDB_REV_MINOR
32  * definitions.  The other files included are required for md_mddb.h.
33  */
34 #ifdef _KERNEL
35 #include <sys/lvm/md_basic.h>
36 #include <sys/lvm/mdvar.h>
37 #else /* !_KERNEL */
38 #include <meta.h>
39 #endif /* _KERNEL */
40 #include <sys/lvm/md_mddb.h>
41 
42 
43 /*
44  * revchk()
45  * Checks the major and minor revision numbers for either an in-core or on-disk
46  * directory block or record block against the currently defined major and
47  * minor numbers(MDDB_REV_MAJOR and MDDB_REV_MINOR) to make sure that they are
48  * compatible with this version of SVM.  For example, earlier versions of SVM
49  * don't understand dummy masterblocks or deviceIDs in disksets.
50  */
51 int
52 revchk(
53 	uint_t	my_rev,
54 	uint_t	data
55 )
56 {
57 	if ((MDDB_REV_MAJOR & my_rev) != (MDDB_REV_MAJOR & data))
58 		return (1);
59 	if ((MDDB_REV_MINOR & my_rev) < (MDDB_REV_MINOR & data))
60 		return (1);
61 	return (0);
62 }
63