xref: /titanic_50/usr/src/uts/common/sys/fs/mntdata.h (revision 84ba300aaa958c8e8427c2ec66a932d86bee71c4)
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 (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _SYS_MNTFS_MNTDATA_H
26 #define	_SYS_MNTFS_MNTDATA_H
27 
28 #include <sys/vnode.h>
29 #include <sys/poll.h>
30 #include <sys/mnttab.h>
31 #include <sys/zone.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 typedef struct mntelem {
38 	/* Metadata. */
39 	struct mntelem 	*mnte_next;
40 	struct mntelem 	*mnte_prev;
41 	timespec_t	mnte_birth;
42 	timespec_t	mnte_death;
43 	timespec_t	mnte_vfs_ctime;
44 	int		mnte_refcnt;
45 	/* Payload. */
46 	int		mnte_hidden;
47 	char		*mnte_text;
48 	size_t		mnte_text_size;
49 	struct extmnttab mnte_tab;
50 } mntelem_t;
51 
52 typedef struct mntsnap {
53 	timespec_t mnts_time;		/* Time of this snapshot. */
54 	timespec_t mnts_last_mtime;	/* mnttab modification time. */
55 	mntelem_t *mnts_first;		/* First element in this snapshot. */
56 	mntelem_t *mnts_next;		/* Next element to use. */
57 	int mnts_flags;			/* flags; see below. */
58 	size_t mnts_nmnts;		/* # of elements in this snapshot. */
59 	size_t mnts_text_size;		/* Text size for this snapshot. */
60 	size_t mnts_foffset;		/* File offset of last read(). */
61 	size_t mnts_ieoffset;		/* Offset of last read() in element. */
62 } mntsnap_t;
63 
64 typedef struct mntnode {
65 	vnode_t *mnt_vnode;	/* vnode for this mntnode */
66 	vnode_t *mnt_mountvp;	/* vnode mounted on */
67 	krwlock_t mnt_contents;	/* protects mnt_flags, mnt_read & mnt_ioctl */
68 	uint_t mnt_flags;	/* flags; see below */
69 	mntsnap_t mnt_read;	/* data for read() */
70 	mntsnap_t mnt_ioctl;	/* data for ioctl() */
71 } mntnode_t;
72 
73 /*
74  * Conversion macros.
75  */
76 #define	VTOM(vp)	((struct mntnode *)(vp)->v_data)
77 #define	MTOV(pnp)	((pnp)->mnt_vnode)
78 #define	MTOD(pnp)	((struct mntdata *)MTOV(pnp)->v_vfsp->vfs_data)
79 
80 #define	MNTFS_ELEM_IS_DEAD(x)	((x)->mnte_death.tv_sec || \
81 				(x)->mnte_death.tv_nsec)
82 #define	MNTFS_ELEM_IS_ALIVE(x)	!MNTFS_ELEM_IS_DEAD(x)
83 
84 #if defined(_KERNEL)
85 
86 typedef struct mntdata {
87 	zone_ref_t mnt_zone_ref;	/* zone for mount point */
88 	uint_t mnt_nopen;		/* count of vnodes open */
89 	size_t mnt_size;		/* size of last normal snapshot */
90 	size_t mnt_hidden_size;		/* size of last hidden snapshot */
91 	timespec_t mnt_mtime;		/* mtime at last normal snapshot */
92 	timespec_t mnt_hidden_mtime;	/* mtime at last hidden snapshot */
93 	struct mntnode mnt_node;	/* embedded mntnode */
94 } mntdata_t;
95 
96 /*
97  * Value for a mntsnap_t's mnts_flags.
98  */
99 #define	MNTS_SHOWHIDDEN	0x1	/* This snapshot contains hidden mounts. */
100 #define	MNTS_REWIND	0x2	/* This snapshot must be refreshed. */
101 /*
102  * Values for a mntnode_t's mnt_flags.
103  */
104 #define	MNT_SHOWHIDDEN	0x1	/* Include MS_NOMNTTAB mounts in snapshots. */
105 
106 extern	struct vnodeops	*mntvnodeops;
107 extern	void mntfs_getmntopts(struct vfs *, char **, size_t *);
108 
109 #endif	/* _KERNEL */
110 
111 #ifdef	__cplusplus
112 }
113 #endif
114 
115 #endif	/* _SYS_MNTFS_MNTDATA_H */
116