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