1 /* 2 * Copyright (c) 2011-2020 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Matthew Dillon <dillon@dragonflybsd.org> 6 * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the 17 * distribution. 18 * 3. Neither the name of The DragonFly Project nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific, prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36 #ifndef _VFS_HAMMER2_IOCTL_H_ 37 #define _VFS_HAMMER2_IOCTL_H_ 38 39 #include <sys/param.h> 40 #include <sys/syslimits.h> 41 42 #ifndef _SYS_IOCCOM_H_ 43 #include <sys/ioccom.h> 44 #endif 45 #ifndef _VFS_HAMMER2_DISK_H_ 46 #include "hammer2_disk.h" 47 #endif 48 #ifndef _VFS_HAMMER2_MOUNT_H_ 49 #include "hammer2_mount.h" 50 #endif 51 52 /* 53 * get_version 54 */ 55 struct hammer2_ioc_version { 56 int version; 57 char reserved[256 - 4]; 58 }; 59 60 typedef struct hammer2_ioc_version hammer2_ioc_version_t; 61 62 struct hammer2_ioc_recluster { 63 int fd; 64 char reserved[256 - 4]; 65 }; 66 67 typedef struct hammer2_ioc_recluster hammer2_ioc_recluster_t; 68 69 /* 70 * Ioctls to manage the volume->copyinfo[] array and to associate or 71 * disassociate sockets 72 */ 73 struct hammer2_ioc_remote { 74 int copyid; 75 int nextid; /* for iteration (get only) */ 76 int fd; /* socket descriptor if applicable */ 77 int reserved03; 78 int reserved04[8]; 79 hammer2_volconf_t copy1; /* copy spec */ 80 hammer2_volconf_t copy2; /* copy spec (rename ops only) */ 81 }; 82 83 typedef struct hammer2_ioc_remote hammer2_ioc_remote_t; 84 85 /* 86 * Ioctls to manage PFSs 87 * 88 * PFSs can be clustered by matching their pfs_clid, and the PFSs making up 89 * a cluster can be uniquely identified by combining the vol_id with 90 * the pfs_clid. 91 */ 92 struct hammer2_ioc_pfs { 93 hammer2_key_t name_key; /* super-root directory scan */ 94 hammer2_key_t name_next; /* (GET only) */ 95 uint8_t pfs_type; /* e.g. MASTER, SLAVE, ... */ 96 uint8_t pfs_subtype; /* e.g. SNAPSHOT */ 97 uint8_t reserved0012; 98 uint8_t reserved0013; 99 uint32_t pfs_flags; 100 uint64_t reserved0018; 101 uuid_t pfs_fsid; /* identifies PFS instance */ 102 uuid_t pfs_clid; /* identifies PFS cluster */ 103 char name[NAME_MAX+1]; /* PFS label */ 104 }; 105 106 typedef struct hammer2_ioc_pfs hammer2_ioc_pfs_t; 107 108 #define HAMMER2_PFSFLAGS_NOSYNC 0x00000001 109 110 /* 111 * Ioctls to manage inodes 112 */ 113 struct hammer2_ioc_inode { 114 uint32_t flags; 115 void *unused; 116 hammer2_key_t data_count; 117 hammer2_key_t inode_count; 118 hammer2_inode_data_t ip_data; 119 }; 120 121 typedef struct hammer2_ioc_inode hammer2_ioc_inode_t; 122 123 #define HAMMER2IOC_INODE_FLAG_IQUOTA 0x00000001 124 #define HAMMER2IOC_INODE_FLAG_DQUOTA 0x00000002 125 #define HAMMER2IOC_INODE_FLAG_COPIES 0x00000004 126 #define HAMMER2IOC_INODE_FLAG_CHECK 0x00000008 127 #define HAMMER2IOC_INODE_FLAG_COMP 0x00000010 128 129 /* 130 * Ioctl for bulkfree scan 131 */ 132 struct hammer2_ioc_bulkfree { 133 hammer2_off_t sbase; /* starting storage offset */ 134 hammer2_off_t sstop; /* (set on return) */ 135 size_t size; /* swapable kernel memory to use */ 136 hammer2_off_t count_allocated; /* alloc fixups this run */ 137 hammer2_off_t count_freed; /* bytes freed this run */ 138 hammer2_off_t total_fragmented; /* merged result */ 139 hammer2_off_t total_allocated; /* merged result */ 140 hammer2_off_t total_scanned; /* bytes of storage */ 141 }; 142 143 typedef struct hammer2_ioc_bulkfree hammer2_ioc_bulkfree_t; 144 145 /* 146 * Unconditionally delete a hammer2 directory entry or inode number 147 */ 148 struct hammer2_ioc_destroy { 149 enum { HAMMER2_DELETE_NOP, 150 HAMMER2_DELETE_FILE, 151 HAMMER2_DELETE_INUM } cmd; 152 char path[HAMMER2_INODE_MAXNAME]; 153 hammer2_key_t inum; 154 }; 155 156 typedef struct hammer2_ioc_destroy hammer2_ioc_destroy_t; 157 158 /* 159 * Grow the filesystem. If size is set to 0 H2 will auto-size to the 160 * partition it is in. The caller can resize the partition, then issue 161 * the ioctl. 162 */ 163 struct hammer2_ioc_growfs { 164 hammer2_off_t size; 165 int modified; 166 int unused01; 167 int unusedary[14]; 168 }; 169 170 typedef struct hammer2_ioc_growfs hammer2_ioc_growfs_t; 171 172 /* 173 * Ioctls to manage volumes 174 */ 175 struct hammer2_ioc_volume { 176 char path[MAXPATHLEN]; 177 int id; 178 hammer2_off_t offset; 179 hammer2_off_t size; 180 }; 181 182 typedef struct hammer2_ioc_volume hammer2_ioc_volume_t; 183 184 struct hammer2_ioc_volume_list { 185 hammer2_ioc_volume_t *volumes; 186 int nvolumes; 187 int version; 188 char pfs_name[HAMMER2_INODE_MAXNAME]; 189 }; 190 191 typedef struct hammer2_ioc_volume_list hammer2_ioc_volume_list_t; 192 193 /* 194 * Ioctl list 195 */ 196 197 #define HAMMER2IOC_VERSION_GET _IOWR('h', 64, struct hammer2_ioc_version) 198 #define HAMMER2IOC_RECLUSTER _IOWR('h', 65, struct hammer2_ioc_recluster) 199 200 #define HAMMER2IOC_REMOTE_SCAN _IOWR('h', 68, struct hammer2_ioc_remote) 201 #define HAMMER2IOC_REMOTE_ADD _IOWR('h', 69, struct hammer2_ioc_remote) 202 #define HAMMER2IOC_REMOTE_DEL _IOWR('h', 70, struct hammer2_ioc_remote) 203 #define HAMMER2IOC_REMOTE_REP _IOWR('h', 71, struct hammer2_ioc_remote) 204 205 #define HAMMER2IOC_SOCKET_GET _IOWR('h', 76, struct hammer2_ioc_remote) 206 #define HAMMER2IOC_SOCKET_SET _IOWR('h', 77, struct hammer2_ioc_remote) 207 208 #define HAMMER2IOC_PFS_GET _IOWR('h', 80, struct hammer2_ioc_pfs) 209 #define HAMMER2IOC_PFS_CREATE _IOWR('h', 81, struct hammer2_ioc_pfs) 210 #define HAMMER2IOC_PFS_DELETE _IOWR('h', 82, struct hammer2_ioc_pfs) 211 #define HAMMER2IOC_PFS_LOOKUP _IOWR('h', 83, struct hammer2_ioc_pfs) 212 #define HAMMER2IOC_PFS_SNAPSHOT _IOWR('h', 84, struct hammer2_ioc_pfs) 213 214 #define HAMMER2IOC_INODE_GET _IOWR('h', 86, struct hammer2_ioc_inode) 215 #define HAMMER2IOC_INODE_SET _IOWR('h', 87, struct hammer2_ioc_inode) 216 217 /* 218 * 88, 89, 90 - old copmression ioctls, now reserved 219 * 220 * 94 - note that this deletes a directory entry or inode number 221 * unconditionally. 222 */ 223 #define HAMMER2IOC_DEBUG_DUMP _IOWR('h', 91, int) 224 #define HAMMER2IOC_BULKFREE_SCAN _IOWR('h', 92, struct hammer2_ioc_bulkfree) 225 #define HAMMER2IOC_BULKFREE_ASYNC _IOWR('h', 93, struct hammer2_ioc_bulkfree) 226 #define HAMMER2IOC_DESTROY _IOWR('h', 94, struct hammer2_ioc_destroy) 227 #define HAMMER2IOC_EMERG_MODE _IOWR('h', 95, int) 228 #define HAMMER2IOC_GROWFS _IOWR('h', 96, struct hammer2_ioc_growfs) 229 #define HAMMER2IOC_VOLUME_LIST _IOWR('h', 97, struct hammer2_ioc_volume_list) 230 231 #endif /* !_VFS_HAMMER2_IOCTL_H_ */ 232