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 https://opensource.org/licenses/CDDL-1.0. 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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright (C) 2011 Lawrence Livermore National Security, LLC. 24 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). 25 * LLNL-CODE-403049. 26 * Rewritten for Linux by: 27 * Rohan Puri <rohan.puri15@gmail.com> 28 * Brian Behlendorf <behlendorf1@llnl.gov> 29 */ 30 31#ifndef _ZFS_CTLDIR_H 32#define _ZFS_CTLDIR_H 33 34#include <sys/vnode.h> 35#include <sys/pathname.h> 36#include <sys/zfs_vfsops.h> 37#include <sys/zfs_znode.h> 38 39#define ZFS_CTLDIR_NAME ".zfs" 40#define ZFS_SNAPDIR_NAME "snapshot" 41#define ZFS_SHAREDIR_NAME "shares" 42 43#define zfs_has_ctldir(zdp) \ 44 ((zdp)->z_id == ZTOZSB(zdp)->z_root && \ 45 (ZTOZSB(zdp)->z_ctldir != NULL)) 46#define zfs_show_ctldir(zdp) \ 47 (zfs_has_ctldir(zdp) && \ 48 (ZTOZSB(zdp)->z_show_ctldir)) 49 50extern int zfs_expire_snapshot; 51 52/* zfsctl generic functions */ 53extern int zfsctl_create(zfsvfs_t *); 54extern void zfsctl_destroy(zfsvfs_t *); 55extern struct inode *zfsctl_root(znode_t *); 56extern void zfsctl_init(void); 57extern void zfsctl_fini(void); 58extern boolean_t zfsctl_is_node(struct inode *ip); 59extern boolean_t zfsctl_is_snapdir(struct inode *ip); 60extern int zfsctl_fid(struct inode *ip, fid_t *fidp); 61 62/* zfsctl '.zfs' functions */ 63extern int zfsctl_root_lookup(struct inode *dip, const char *name, 64 struct inode **ipp, int flags, cred_t *cr, int *direntflags, 65 pathname_t *realpnp); 66 67/* zfsctl '.zfs/snapshot' functions */ 68extern int zfsctl_snapdir_lookup(struct inode *dip, const char *name, 69 struct inode **ipp, int flags, cred_t *cr, int *direntflags, 70 pathname_t *realpnp); 71extern int zfsctl_snapdir_rename(struct inode *sdip, const char *sname, 72 struct inode *tdip, const char *tname, cred_t *cr, int flags); 73extern int zfsctl_snapdir_remove(struct inode *dip, const char *name, 74 cred_t *cr, int flags); 75extern int zfsctl_snapdir_mkdir(struct inode *dip, const char *dirname, 76 vattr_t *vap, struct inode **ipp, cred_t *cr, int flags); 77extern int zfsctl_snapshot_mount(struct path *path, int flags); 78extern int zfsctl_snapshot_unmount(const char *snapname, int flags); 79extern int zfsctl_snapshot_unmount_delay(spa_t *spa, uint64_t objsetid, 80 int delay); 81extern int zfsctl_snapdir_vget(struct super_block *sb, uint64_t objsetid, 82 int gen, struct inode **ipp); 83 84/* zfsctl '.zfs/shares' functions */ 85extern int zfsctl_shares_lookup(struct inode *dip, char *name, 86 struct inode **ipp, int flags, cred_t *cr, int *direntflags, 87 pathname_t *realpnp); 88 89/* 90 * These inodes numbers are reserved for the .zfs control directory. 91 * It is important that they be no larger that 48-bits because only 92 * 6 bytes are reserved in the NFS file handle for the object number. 93 * However, they should be as large as possible to avoid conflicts 94 * with the objects which are assigned monotonically by the dmu. 95 */ 96#define ZFSCTL_INO_ROOT 0x0000FFFFFFFFFFFFULL 97#define ZFSCTL_INO_SHARES 0x0000FFFFFFFFFFFEULL 98#define ZFSCTL_INO_SNAPDIR 0x0000FFFFFFFFFFFDULL 99#define ZFSCTL_INO_SNAPDIRS 0x0000FFFFFFFFFFFCULL 100 101#define ZFSCTL_EXPIRE_SNAPSHOT 300 102 103#endif /* _ZFS_CTLDIR_H */ 104