xref: /illumos-gate/usr/src/lib/libfstyp/common/libfstyp.h (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
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 /*
30  * libfstyp: filesystem identification library
31  */
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 #include <libnvpair.h>
38 
39 typedef struct fstyp_handle *fstyp_handle_t;
40 
41 enum {
42 	FSTYP_ERR_OK = 0,
43 	FSTYP_ERR_NO_MATCH,		/* no matches */
44 	FSTYP_ERR_MULT_MATCH,		/* multiple matches */
45 	FSTYP_ERR_HANDLE,		/* invalid handle */
46 	FSTYP_ERR_OFFSET,		/* invalid or unsupported offset */
47 	FSTYP_ERR_NO_PARTITION,		/* partition not found */
48 	FSTYP_ERR_NOP,			/* no such operation */
49 	FSTYP_ERR_DEV_OPEN,		/* cannot open device */
50 	FSTYP_ERR_IO,			/* I/O error */
51 	FSTYP_ERR_NOMEM,		/* out of memory */
52 	FSTYP_ERR_MOD_NOT_FOUND,	/* requested fs module not found */
53 	FSTYP_ERR_MOD_DIR_OPEN,		/* cannot open directory */
54 	FSTYP_ERR_MOD_OPEN,		/* cannot open module */
55 	FSTYP_ERR_MOD_VERSION,		/* invalid module version */
56 	FSTYP_ERR_MOD_INVALID,		/* invalid module */
57 	FSTYP_ERR_NAME_TOO_LONG		/* fs name exceeds FSTYPSZ */
58 };
59 
60 /*
61  * generic attribute names
62  *
63  * gen_clean (DATA_TYPE_BOOLEAN_VALUE)
64  * gen_guid (DATA_TYPE_STRING)
65  * gen_version (DATA_TYPE_STRING)
66  * gen_volume_label (DATA_TYPE_STRING)
67  */
68 
69 int fstyp_init(int fd, off64_t offset, char *module_dir,
70     fstyp_handle_t *handle);
71 void fstyp_fini(fstyp_handle_t handle);
72 int fstyp_ident(fstyp_handle_t handle, const char *fsname,
73     const char **ident);
74 int fstyp_get_attr(fstyp_handle_t handle, nvlist_t **attr);
75 int fstyp_dump(fstyp_handle_t handle, FILE *fout, FILE *ferr);
76 const char *fstyp_strerror(fstyp_handle_t handle, int error);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* _LIBFSTYP_H */
83