xref: /titanic_52/usr/src/uts/common/sys/fs/bootfs_impl.h (revision 76ca3cb000306bc4052fe820a7e4a6998dbcf932)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright (c) 2014 Joyent, Inc.  All rights reserved.
14  */
15 
16 #ifndef _SYS_FS_BOOTFS_IMPL_H
17 #define	_SYS_FS_BOOTFS_IMPL_H
18 
19 #include <sys/types.h>
20 #include <sys/list.h>
21 #include <sys/avl.h>
22 #include <sys/vnode.h>
23 #include <sys/vfs_opreg.h>
24 #include <sys/kstat.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /*
31  * The bootfs node is the file system specific version of the vnode for the
32  * bootfs file system. Because the bootfs file system is entirely a read-only
33  * file system, this structure requires no locking as the contents are
34  * immutable.
35  */
36 typedef struct bootfs_node {
37 	char			*bvn_name;	/* entry name */
38 	struct vnode		*bvn_vnp;	/* Corresponding vnode */
39 	avl_tree_t		bvn_dir;	/* directory entries, if VDIR */
40 	avl_node_t		bvn_link;	/* dirent link */
41 	list_node_t		bvn_alink;	/* link for all nodes */
42 	uint64_t		bvn_addr;	/* Address in pmem */
43 	uint64_t		bvn_size;	/* Size of the file */
44 	struct bootfs_node	*bvn_parent;	/* .. */
45 	vattr_t			bvn_attr;	/* attributes for the node */
46 } bootfs_node_t;
47 
48 typedef struct bootfs_stat {
49 	kstat_named_t	bfss_nfiles;
50 	kstat_named_t	bfss_ndirs;
51 	kstat_named_t	bfss_nbytes;
52 	kstat_named_t	bfss_ndups;
53 	kstat_named_t	bfss_ndiscards;
54 } bootfs_stat_t;
55 
56 typedef struct bootfs {
57 	vfs_t			*bfs_vfsp;
58 	char			*bfs_mntpath;
59 	bootfs_node_t		*bfs_rootvn;
60 	kstat_t			*bfs_kstat;
61 	list_t			bfs_nodes;
62 	minor_t			bfs_minor;
63 	uint_t			bfs_ninode;
64 	bootfs_stat_t		bfs_stat;
65 } bootfs_t;
66 
67 extern void bootfs_construct(bootfs_t *);
68 extern void bootfs_destruct(bootfs_t *);
69 extern int bootfs_node_constructor(void *, void *, int);
70 extern void bootfs_node_destructor(void *, void *);
71 
72 extern struct vnodeops *bootfs_vnodeops;
73 extern const fs_operation_def_t bootfs_vnodeops_template[];
74 extern kmem_cache_t *bootfs_node_cache;
75 extern major_t bootfs_major;
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /* _SYS_FS_BOOTFS_IMPL_H */
82