xref: /titanic_41/usr/src/uts/common/sys/fs/mntdata.h (revision 571909175b4f9a1ef15ec4afead6d6d463dbe760)
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 2009 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 	krwlock_t mnt_contents;	/* protects mnt_read, mnt_ioctl, mnt_offset */
66 	uint_t mnt_flags;	/* flags; see below */
67 	vnode_t *mnt_mountvp;	/* vnode mounted on */
68 	vnode_t *mnt_vnode;	/* vnode for this mntnode */
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;		/* latest snapshot size for mount */
79 	struct mntnode mnt_node;	/* embedded mntnode */
80 } mntdata_t;
81 
82 /*
83  * Conversion macros.
84  */
85 #define	VTOM(vp)	((struct mntnode *)(vp)->v_data)
86 #define	MTOV(pnp)	((pnp)->mnt_vnode)
87 #define	MTOD(pnp)	((struct mntdata *)MTOV(pnp)->v_vfsp->vfs_data)
88 
89 #define	MNTFS_ELEM_IS_DEAD(x)	((x)->mnte_death.tv_sec || \
90 				(x)->mnte_death.tv_nsec)
91 #define	MNTFS_ELEM_IS_ALIVE(x)	!MNTFS_ELEM_IS_DEAD(x)
92 
93 #if defined(_KERNEL)
94 
95 /*
96  * Value for a mntsnap_t's mnts_flags.
97  */
98 #define	MNTS_SHOWHIDDEN	0x1	/* This snapshot contains hidden mounts. */
99 #define	MNTS_REWIND	0x2	/* This snapshot must be refreshed. */
100 /*
101  * Values for a mntnode_t's mnt_flags.
102  */
103 #define	MNT_SHOWHIDDEN	0x1	/* Include MS_NOMNTTAB mounts in snapshots. */
104 
105 extern	struct vnodeops	*mntvnodeops;
106 extern	void mntfs_getmntopts(struct vfs *, char **, size_t *);
107 
108 #endif	/* _KERNEL */
109 
110 #ifdef	__cplusplus
111 }
112 #endif
113 
114 #endif	/* _SYS_MNTFS_MNTDATA_H */
115