xref: /illumos-gate/usr/src/uts/common/sys/fs/mntdata.h (revision 7248adcb841e89c33c8b56bb2616710a788afbf5)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_MNTFS_MNTDATA_H
27 #define	_SYS_MNTFS_MNTDATA_H
28 
29 #include <sys/vnode.h>
30 #include <sys/poll.h>
31 #include <sys/mnttab.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 struct zone;
74 
75 typedef struct mntdata {
76 	struct zone *mnt_zone;		/* zone for mount point */
77 	uint_t mnt_nopen;		/* count of vnodes open */
78 	size_t mnt_size;		/* size of last normal snapshot */
79 	size_t mnt_hidden_size;		/* size of last hidden snapshot */
80 	timespec_t mnt_mtime;		/* mtime at last normal snapshot */
81 	timespec_t mnt_hidden_mtime;	/* mtime at last hidden snapshot */
82 	struct mntnode mnt_node;	/* embedded mntnode */
83 } mntdata_t;
84 
85 /*
86  * Conversion macros.
87  */
88 #define	VTOM(vp)	((struct mntnode *)(vp)->v_data)
89 #define	MTOV(pnp)	((pnp)->mnt_vnode)
90 #define	MTOD(pnp)	((struct mntdata *)MTOV(pnp)->v_vfsp->vfs_data)
91 
92 #define	MNTFS_ELEM_IS_DEAD(x)	((x)->mnte_death.tv_sec || \
93 				(x)->mnte_death.tv_nsec)
94 #define	MNTFS_ELEM_IS_ALIVE(x)	!MNTFS_ELEM_IS_DEAD(x)
95 
96 #if defined(_KERNEL)
97 
98 /*
99  * Value for a mntsnap_t's mnts_flags.
100  */
101 #define	MNTS_SHOWHIDDEN	0x1	/* This snapshot contains hidden mounts. */
102 #define	MNTS_REWIND	0x2	/* This snapshot must be refreshed. */
103 /*
104  * Values for a mntnode_t's mnt_flags.
105  */
106 #define	MNT_SHOWHIDDEN	0x1	/* Include MS_NOMNTTAB mounts in snapshots. */
107 
108 extern	struct vnodeops	*mntvnodeops;
109 extern	void mntfs_getmntopts(struct vfs *, char **, size_t *);
110 
111 #endif	/* _KERNEL */
112 
113 #ifdef	__cplusplus
114 }
115 #endif
116 
117 #endif	/* _SYS_MNTFS_MNTDATA_H */
118