1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright (C) 2011 Lawrence Livermore National Security, LLC. 25 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). 26 * LLNL-CODE-403049. 27 * Rewritten for Linux by: 28 * Rohan Puri <rohan.puri15@gmail.com> 29 * Brian Behlendorf <behlendorf1@llnl.gov> 30 */ 31 32 #ifndef _ZFS_CTLDIR_H 33 #define _ZFS_CTLDIR_H 34 35 #include <sys/vnode.h> 36 #include <sys/pathname.h> 37 #include <sys/zfs_vfsops.h> 38 #include <sys/zfs_znode.h> 39 40 #define ZFS_CTLDIR_NAME ".zfs" 41 #define ZFS_SNAPDIR_NAME "snapshot" 42 #define ZFS_SHAREDIR_NAME "shares" 43 44 #define zfs_has_ctldir(zdp) \ 45 ((zdp)->z_id == ZTOZSB(zdp)->z_root && \ 46 (ZTOZSB(zdp)->z_ctldir != NULL)) 47 #define zfs_show_ctldir(zdp) \ 48 (zfs_has_ctldir(zdp) && \ 49 (ZTOZSB(zdp)->z_show_ctldir == ZFS_SNAPDIR_VISIBLE)) 50 51 extern int zfs_expire_snapshot; 52 53 /* zfsctl generic functions */ 54 extern int zfsctl_create(zfsvfs_t *); 55 extern void zfsctl_destroy(zfsvfs_t *); 56 extern struct inode *zfsctl_root(znode_t *); 57 extern void zfsctl_init(void); 58 extern void zfsctl_fini(void); 59 extern boolean_t zfsctl_is_node(struct inode *ip); 60 extern boolean_t zfsctl_is_snapdir(struct inode *ip); 61 extern int zfsctl_fid(struct inode *ip, fid_t *fidp); 62 63 /* zfsctl '.zfs' functions */ 64 extern int zfsctl_root_lookup(struct inode *dip, const char *name, 65 struct inode **ipp, int flags, cred_t *cr, int *direntflags, 66 pathname_t *realpnp); 67 68 /* zfsctl '.zfs/snapshot' functions */ 69 extern int zfsctl_snapdir_lookup(struct inode *dip, const char *name, 70 struct inode **ipp, int flags, cred_t *cr, int *direntflags, 71 pathname_t *realpnp); 72 extern int zfsctl_snapdir_rename(struct inode *sdip, const char *sname, 73 struct inode *tdip, const char *tname, cred_t *cr, int flags); 74 extern int zfsctl_snapdir_remove(struct inode *dip, const char *name, 75 cred_t *cr, int flags); 76 extern int zfsctl_snapdir_mkdir(struct inode *dip, const char *dirname, 77 vattr_t *vap, struct inode **ipp, cred_t *cr, int flags); 78 extern int zfsctl_snapshot_mount(struct path *path, int flags); 79 extern int zfsctl_snapshot_unmount(const char *snapname, int flags); 80 extern int zfsctl_snapshot_unmount_delay(spa_t *spa, uint64_t objsetid, 81 int delay); 82 extern int zfsctl_snapdir_vget(struct super_block *sb, uint64_t objsetid, 83 int gen, struct inode **ipp); 84 85 /* zfsctl '.zfs/shares' functions */ 86 extern int zfsctl_shares_lookup(struct inode *dip, char *name, 87 struct inode **ipp, int flags, cred_t *cr, int *direntflags, 88 pathname_t *realpnp); 89 90 /* 91 * These inodes numbers are reserved for the .zfs control directory. 92 * It is important that they be no larger that 48-bits because only 93 * 6 bytes are reserved in the NFS file handle for the object number. 94 * However, they should be as large as possible to avoid conflicts 95 * with the objects which are assigned monotonically by the dmu. 96 */ 97 #define ZFSCTL_INO_ROOT 0x0000FFFFFFFFFFFFULL 98 #define ZFSCTL_INO_SHARES 0x0000FFFFFFFFFFFEULL 99 #define ZFSCTL_INO_SNAPDIR 0x0000FFFFFFFFFFFDULL 100 #define ZFSCTL_INO_SNAPDIRS 0x0000FFFFFFFFFFFCULL 101 102 #define ZFSCTL_EXPIRE_SNAPSHOT 300 103 104 #endif /* _ZFS_CTLDIR_H */ 105