174 * is removed when the ctldir is destroyed in the unmount. |
175 * is removed when the ctldir is destroyed in the unmount. |
175 */ |
176 */ |
176 void |
177 void |
177 zfsctl_create(zfsvfs_t *zfsvfs) |
178 zfsctl_create(zfsvfs_t *zfsvfs) |
178 { |
179 { |
179 vnode_t *vp; |
180 vnode_t *vp, *rvp; |
180 zfsctl_node_t *zcp; |
181 zfsctl_node_t *zcp; |
181 |
182 |
182 ASSERT(zfsvfs->z_ctldir == NULL); |
183 ASSERT(zfsvfs->z_ctldir == NULL); |
183 |
184 |
184 vp = gfs_root_create(sizeof (zfsctl_node_t), zfsvfs->z_vfs, |
185 vp = gfs_root_create(sizeof (zfsctl_node_t), zfsvfs->z_vfs, |
185 zfsctl_ops_root, ZFSCTL_INO_ROOT, zfsctl_root_entries, |
186 zfsctl_ops_root, ZFSCTL_INO_ROOT, zfsctl_root_entries, |
186 zfsctl_root_inode_cb, MAXNAMELEN, NULL, NULL); |
187 zfsctl_root_inode_cb, MAXNAMELEN, NULL, NULL); |
187 zcp = vp->v_data; |
188 zcp = vp->v_data; |
188 zcp->zc_id = ZFSCTL_INO_ROOT; |
189 zcp->zc_id = ZFSCTL_INO_ROOT; |
189 |
190 |
|
191 VERIFY(VFS_ROOT(zfsvfs->z_vfs, &rvp) == 0); |
|
192 ZFS_TIME_DECODE(&zcp->zc_cmtime, VTOZ(rvp)->z_phys->zp_crtime); |
|
193 VN_RELE(rvp); |
|
194 |
190 /* |
195 /* |
191 * We're only faking the fact that we have a root of a filesystem for |
196 * We're only faking the fact that we have a root of a filesystem for |
192 * the sake of the GFS interfaces. Undo the flag manipulation it did |
197 * the sake of the GFS interfaces. Undo the flag manipulation it did |
193 * for us. |
198 * for us. |
194 */ |
199 */ |
279 vap->va_fsid = vp->v_vfsp->vfs_dev; |
285 vap->va_fsid = vp->v_vfsp->vfs_dev; |
280 vap->va_mode = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | |
286 vap->va_mode = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | |
281 S_IROTH | S_IXOTH; |
287 S_IROTH | S_IXOTH; |
282 vap->va_type = VDIR; |
288 vap->va_type = VDIR; |
283 /* |
289 /* |
284 * We live in the now. |
290 * We live in the now (for atime). |
285 */ |
291 */ |
286 gethrestime(&now); |
292 gethrestime(&now); |
287 vap->va_mtime = vap->va_ctime = vap->va_atime = now; |
293 vap->va_atime = now; |
|
294 vap->va_mtime = vap->va_ctime = zcp->zc_cmtime; |
288 } |
295 } |
289 |
296 |
290 static int |
297 static int |
291 zfsctl_common_fid(vnode_t *vp, fid_t *fidp) |
298 zfsctl_common_fid(vnode_t *vp, fid_t *fidp) |
292 { |
299 { |
734 vp = gfs_dir_create(sizeof (zfsctl_snapdir_t), pvp, |
741 vp = gfs_dir_create(sizeof (zfsctl_snapdir_t), pvp, |
735 zfsctl_ops_snapdir, NULL, NULL, MAXNAMELEN, |
742 zfsctl_ops_snapdir, NULL, NULL, MAXNAMELEN, |
736 zfsctl_snapdir_readdir_cb, NULL); |
743 zfsctl_snapdir_readdir_cb, NULL); |
737 sdp = vp->v_data; |
744 sdp = vp->v_data; |
738 sdp->sd_node.zc_id = ZFSCTL_INO_SNAPDIR; |
745 sdp->sd_node.zc_id = ZFSCTL_INO_SNAPDIR; |
|
746 sdp->sd_node.zc_cmtime = ((zfsctl_node_t *)pvp->v_data)->zc_cmtime; |
739 mutex_init(&sdp->sd_lock, NULL, MUTEX_DEFAULT, NULL); |
747 mutex_init(&sdp->sd_lock, NULL, MUTEX_DEFAULT, NULL); |
740 avl_create(&sdp->sd_snaps, snapentry_compare, |
748 avl_create(&sdp->sd_snaps, snapentry_compare, |
741 sizeof (zfs_snapentry_t), offsetof(zfs_snapentry_t, se_node)); |
749 sizeof (zfs_snapentry_t), offsetof(zfs_snapentry_t, se_node)); |
742 return (vp); |
750 return (vp); |
743 } |
751 } |