xref: /titanic_41/usr/src/lib/libfstyp/common/libfstyp.h (revision 9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bb)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBFSTYP_H
27 #define	_LIBFSTYP_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * libfstyp: filesystem identification library
33  */
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #include <sys/types.h>
39 #include <libnvpair.h>
40 
41 typedef struct fstyp_handle *fstyp_handle_t;
42 
43 enum {
44 	FSTYP_ERR_OK = 0,
45 	FSTYP_ERR_NO_MATCH,		/* no matches */
46 	FSTYP_ERR_MULT_MATCH,		/* multiple matches */
47 	FSTYP_ERR_HANDLE,		/* invalid handle */
48 	FSTYP_ERR_OFFSET,		/* invalid or unsupported offset */
49 	FSTYP_ERR_NO_PARTITION,		/* partition not found */
50 	FSTYP_ERR_NOP,			/* no such operation */
51 	FSTYP_ERR_DEV_OPEN,		/* cannot open device */
52 	FSTYP_ERR_IO,			/* I/O error */
53 	FSTYP_ERR_NOMEM,		/* out of memory */
54 	FSTYP_ERR_MOD_NOT_FOUND,	/* requested fs module not found */
55 	FSTYP_ERR_MOD_DIR_OPEN,		/* cannot open directory */
56 	FSTYP_ERR_MOD_OPEN,		/* cannot open module */
57 	FSTYP_ERR_MOD_VERSION,		/* invalid module version */
58 	FSTYP_ERR_MOD_INVALID,		/* invalid module */
59 	FSTYP_ERR_NAME_TOO_LONG		/* fs name exceeds FSTYPSZ */
60 };
61 
62 /*
63  * generic attribute names
64  *
65  * gen_clean (DATA_TYPE_BOOLEAN_VALUE)
66  * gen_guid (DATA_TYPE_STRING)
67  * gen_version (DATA_TYPE_STRING)
68  * gen_volume_label (DATA_TYPE_STRING)
69  */
70 
71 int fstyp_init(int fd, off64_t offset, char *module_dir,
72     fstyp_handle_t *handle);
73 void fstyp_fini(fstyp_handle_t handle);
74 int fstyp_ident(fstyp_handle_t handle, const char *fsname,
75     const char **ident);
76 int fstyp_get_attr(fstyp_handle_t handle, nvlist_t **attr);
77 int fstyp_dump(fstyp_handle_t handle, FILE *fout, FILE *ferr);
78 const char *fstyp_strerror(fstyp_handle_t handle, int error);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* _LIBFSTYP_H */
85