Print this page
XXXX don't fail device detach when it's physically removed
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/fs/dv_node.h
+++ new/usr/src/uts/common/sys/fs/dv_node.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 +
21 22 /*
22 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 24 * Use is subject to license terms.
24 25 */
25 26
27 +/*
28 + * Copyright 2018 Nexenta Systems, Inc.
29 + */
30 +
26 31 #ifndef _SYS_DV_NODE_H
27 32 #define _SYS_DV_NODE_H
28 33
29 34 /*
30 35 * dv_nodes are the file-system specific part of the
31 36 * vnodes for the device filesystem.
32 37 *
33 38 * The device filesystem exports two node types:
34 39 *
35 40 * VDIR nodes to represent nexus drivers
36 41 * VCHR & VBLK nodes to represent devices
37 42 */
38 43
39 44 #include <sys/dirent.h>
40 45 #include <sys/sunddi.h>
41 46 #include <sys/devops.h>
42 47 #include <sys/ddi_impldefs.h>
43 48 #include <sys/fs/sdev_impl.h>
44 49 #include <sys/devpolicy.h>
45 50 #include <sys/avl.h>
46 51
47 52 #ifdef _KERNEL
48 53 #include <sys/vfs_opreg.h>
49 54 #endif
50 55
51 56 #ifdef __cplusplus
52 57 extern "C" {
53 58 #endif
54 59
55 60 #ifdef _KERNEL
56 61
57 62
58 63 /*
59 64 * Here's the focal point of this filesystem
60 65 */
61 66 typedef struct dv_node {
62 67 char *dv_name; /* pointer to name */
63 68 size_t dv_namelen; /* strlen(dv_name) */
64 69 struct vnode *dv_vnode; /* vnode for this dv_node */
65 70
66 71 /*
67 72 * The dv_contents lock should be held (read) before looking at
68 73 * any of the fields below, and held (write) before modifying them.
69 74 */
70 75 krwlock_t dv_contents; /* held while anything is changing */
71 76
72 77 dev_info_t *dv_devi; /* VDIR: underlying devinfo node */
73 78 /* has ndi_devi_hold on device */
74 79
75 80 struct dv_node *dv_dotdot; /* parent: my parent dv_node */
76 81 avl_tree_t dv_entries; /* VDIR: contents as avl tree */
77 82 avl_node_t dv_avllink; /* avl node linkage */
78 83
79 84 struct vnode *dv_attrvp; /* persistent attribute store */
80 85 struct vattr *dv_attr; /* attributes not yet persistent */
81 86
82 87 ino64_t dv_ino; /* fake inode */
83 88 int dv_flags; /* state bits and stuff */
84 89 uint_t dv_nlink; /* link count */
85 90 uint_t dv_busy; /* directory busy count */
86 91 devplcy_t *dv_priv; /* access privilege */
87 92 mode_t dv_dflt_mode; /* create_priv_minor_node mode */
88 93 struct sdev_dv *dv_sdev; /* sdev node[s] if exists */
89 94 } dvnode_t;
90 95
91 96 #define DV_BUILD 0x1 /* directory out-of-date */
92 97 #define DV_NO_FSPERM 0x2 /* ignore fs permissions */
93 98 #define DV_INTERNAL 0x04 /* internal node */
94 99 #define DV_ACL 0x08 /* node has acl */
95 100 #define DV_DFLT_MODE 0x010 /* dv_dflt_mode set */
96 101
97 102 #define DV_ROOTINO ((ino_t)2) /* root inode no. for devfs */
98 103
99 104 #define DVTOV(n) ((struct vnode *)(n)->dv_vnode)
100 105 #define VTODV(vp) ((struct dv_node *)(vp)->v_data)
101 106 #define DV_STALE(dv) (dv->dv_devi == NULL)
102 107
↓ open down ↓ |
67 lines elided |
↑ open up ↑ |
103 108 #define DV_UID_DEFAULT 0 /* default uid for devs and dirs */
104 109 #define DV_GID_DEFAULT 3 /* default gid for devs and dirs */
105 110 #define DV_DIRMODE_DEFAULT (S_IFDIR | 0755) /* directories */
106 111 #define DV_DEVMODE_DEFAULT (0600) /* special files */
107 112 #define DV_DEVMODE_PRIV (0666) /* priv based access only */
108 113
109 114 /* flags for devfs_clean() */
110 115 #define DV_CLEAN_FORCE 0x01 /* force clean of refed directories */
111 116 #define DV_RESET_PERM 0x02 /* force resetting of node permission */
112 117 #define DV_CLEANDIR_LCK 0x04 /* dv_contents already held */
118 +#define DV_DEVI_GONE 0x08 /* force clean of refed files */
113 119
114 120 struct devfs_data {
115 121 struct dv_node *devfs_root;
116 122 struct vfs *devfs_vfsp;
117 123 };
118 124
119 125 #define VFSTODVFS(vfsp) ((struct devfs_data *)((vfsp)->vfs_data))
120 126
121 127 /* dv_fid overlays the fid structure (for VFS_VGET) */
122 128 struct dv_fid {
123 129 uint16_t dvfid_len;
124 130 ino32_t dvfid_ino;
125 131 int32_t dvfid_gen;
126 132 };
127 133
128 134 /*
129 135 * Compare a vattr's and mperm_t's minor permissions (uid, gid & mode)
130 136 */
131 137 #define VATTRP_MP_CMP(attrp, mp) \
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
132 138 (!((attrp->va_uid == mp.mp_uid) && \
133 139 (attrp->va_gid == mp.mp_gid) && \
134 140 ((attrp->va_mode & S_IAMB) == (mp.mp_mode & S_IAMB))))
135 141
136 142 /*
137 143 * Merge an mperm_t's minor permissions into a vattr
138 144 */
139 145 #define VATTR_MP_MERGE(attr, mp) \
140 146 attr.va_uid = mp.mp_uid; \
141 147 attr.va_gid = mp.mp_gid; \
142 - attr.va_mode = \
148 + attr.va_mode = \
143 149 (attr.va_mode & ~S_IAMB) | (mp.mp_mode & S_IAMB);
144 150
145 151 #define VATTRP_MP_MERGE(attrp, mp) \
146 152 attrp->va_uid = mp.mp_uid; \
147 153 attrp->va_gid = mp.mp_gid; \
148 - attrp->va_mode = \
154 + attrp->va_mode = \
149 155 (attrp->va_mode & ~S_IAMB) | (mp.mp_mode & S_IAMB);
150 156
151 157 /*
152 158 * dv_shadow_node flags
153 159 */
154 160 #define DV_SHADOW_CREATE 0x01 /* create attribute node */
155 161 #define DV_SHADOW_WRITE_HELD 0x02 /* dv_contents write held */
156 162
157 163 /*
158 164 * Directory tree traversal
159 165 */
160 166 #define DV_FIRST_ENTRY(ddv) avl_first(&(ddv)->dv_entries)
161 167 #define DV_NEXT_ENTRY(ddv, dv) AVL_NEXT(&(ddv)->dv_entries, (dv))
162 168
163 169 extern uint_t devfs_clean_key; /* tsd key */
164 170 extern const char dvnm[]; /* share some space.. */
165 171 extern struct dv_node *dvroot; /* devfs root node */
166 172
167 173 extern void dv_node_cache_init(void);
168 174 extern void dv_node_cache_fini(void);
169 175 extern struct dv_node *dv_mkdir(struct dv_node *, dev_info_t *, char *);
170 176 extern struct dv_node *dv_mkroot(struct vfs *, dev_t);
171 177 extern void dv_destroy(struct dv_node *, uint_t);
172 178 extern void dv_insert(struct dv_node *, struct dv_node *);
173 179 extern void dv_shadow_node(struct vnode *, char *nm, struct vnode *,
174 180 struct pathname *, struct vnode *, struct cred *, int);
175 181 extern int dv_find(struct dv_node *, char *, struct vnode **,
176 182 struct pathname *, struct vnode *, struct cred *, uint_t);
177 183 extern void dv_filldir(struct dv_node *);
178 184 extern int dv_cleandir(struct dv_node *, char *, uint_t);
179 185 extern void dv_vattr_merge(struct dv_node *, struct vattr *);
180 186 extern void dv_walk(struct dv_node *, char *,
181 187 void (*f)(struct dv_node *, void *), void *);
182 188
183 189 extern int devfs_clean(dev_info_t *, char *, uint_t);
184 190 extern int devfs_lookupname(char *, vnode_t **, vnode_t **);
185 191 extern int devfs_walk(char *, void (*f)(struct dv_node *, void *), void *);
186 192 extern int devfs_devpolicy(vnode_t *, devplcy_t **);
187 193 extern void devfs_get_defattr(vnode_t *, struct vattr *, int *);
188 194
189 195 extern struct dv_node *devfs_dip_to_dvnode(dev_info_t *);
190 196 extern int devfs_reset_perm(uint_t);
191 197 extern int devfs_remdrv_cleanup(const char *, const char *);
192 198
193 199 extern struct vnodeops *dv_vnodeops;
194 200 extern const struct fs_operation_def dv_vnodeops_template[];
195 201
196 202
197 203 #ifdef DEBUG
198 204 extern int devfs_debug;
199 205 #define DV_DEBUG 0x01
200 206 #define DV_DEBUG2 0x02
201 207 #define DV_DEBUG3 0x04
202 208 #define DV_DEBUG4 0x08
203 209 #define DV_DEBUG5 0x10
204 210 #define DV_SYSERR 0x1000
205 211 #define DV_SYSTRACE 0x2000
206 212 #define dcmn_err(args) if (devfs_debug & DV_DEBUG) printf args
207 213 #define dcmn_err2(args) if (devfs_debug & DV_DEBUG2) printf args
208 214 #define dcmn_err3(args) if (devfs_debug & DV_DEBUG3) printf args
209 215 #define dcmn_err4(args) if (devfs_debug & DV_DEBUG4) printf args
210 216 #define dcmn_err5(args) if (devfs_debug & DV_DEBUG5) printf args
211 217
212 218 #define dsysdebug(err, args) \
213 219 if ((err && (devfs_debug & DV_SYSERR)) || \
214 220 (devfs_debug & DV_SYSTRACE)) printf args
215 221 #else
216 222 #define dcmn_err(args) /* nothing */
217 223 #define dcmn_err2(args) /* nothing */
218 224 #define dcmn_err3(args) /* nothing */
219 225 #define dcmn_err4(args) /* nothing */
220 226 #define dcmn_err5(args) /* nothing */
221 227 #define dsysdebug(err, args) /* nothing */
222 228 #endif
223 229
224 230
225 231 #endif /* _KERNEL */
226 232
227 233 #ifdef __cplusplus
228 234 }
229 235 #endif
230 236
231 237 #endif /* _SYS_DV_NODE_H */
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX