1*86d7f5d3SJohn Marino /* $NetBSD: dm-ioctl.h,v 1.1.1.2 2009/12/02 00:26:09 haad Exp $ */ 2*86d7f5d3SJohn Marino 3*86d7f5d3SJohn Marino /* 4*86d7f5d3SJohn Marino * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited. 5*86d7f5d3SJohn Marino * Copyright (C) 2004 - 2009 Red Hat, Inc. All rights reserved. 6*86d7f5d3SJohn Marino * 7*86d7f5d3SJohn Marino * This file is released under the LGPL. 8*86d7f5d3SJohn Marino */ 9*86d7f5d3SJohn Marino 10*86d7f5d3SJohn Marino #ifndef _LINUX_DM_IOCTL_V4_H 11*86d7f5d3SJohn Marino #define _LINUX_DM_IOCTL_V4_H 12*86d7f5d3SJohn Marino 13*86d7f5d3SJohn Marino #ifdef linux 14*86d7f5d3SJohn Marino # include <linux/types.h> 15*86d7f5d3SJohn Marino #endif 16*86d7f5d3SJohn Marino 17*86d7f5d3SJohn Marino #define DM_DIR "mapper" /* Slashes not supported */ 18*86d7f5d3SJohn Marino #define DM_MAX_TYPE_NAME 16 19*86d7f5d3SJohn Marino #define DM_NAME_LEN 128 20*86d7f5d3SJohn Marino #define DM_UUID_LEN 129 21*86d7f5d3SJohn Marino 22*86d7f5d3SJohn Marino /* 23*86d7f5d3SJohn Marino * A traditional ioctl interface for the device mapper. 24*86d7f5d3SJohn Marino * 25*86d7f5d3SJohn Marino * Each device can have two tables associated with it, an 26*86d7f5d3SJohn Marino * 'active' table which is the one currently used by io passing 27*86d7f5d3SJohn Marino * through the device, and an 'inactive' one which is a table 28*86d7f5d3SJohn Marino * that is being prepared as a replacement for the 'active' one. 29*86d7f5d3SJohn Marino * 30*86d7f5d3SJohn Marino * DM_VERSION: 31*86d7f5d3SJohn Marino * Just get the version information for the ioctl interface. 32*86d7f5d3SJohn Marino * 33*86d7f5d3SJohn Marino * DM_REMOVE_ALL: 34*86d7f5d3SJohn Marino * Remove all dm devices, destroy all tables. Only really used 35*86d7f5d3SJohn Marino * for debug. 36*86d7f5d3SJohn Marino * 37*86d7f5d3SJohn Marino * DM_LIST_DEVICES: 38*86d7f5d3SJohn Marino * Get a list of all the dm device names. 39*86d7f5d3SJohn Marino * 40*86d7f5d3SJohn Marino * DM_DEV_CREATE: 41*86d7f5d3SJohn Marino * Create a new device, neither the 'active' or 'inactive' table 42*86d7f5d3SJohn Marino * slots will be filled. The device will be in suspended state 43*86d7f5d3SJohn Marino * after creation, however any io to the device will get errored 44*86d7f5d3SJohn Marino * since it will be out-of-bounds. 45*86d7f5d3SJohn Marino * 46*86d7f5d3SJohn Marino * DM_DEV_REMOVE: 47*86d7f5d3SJohn Marino * Remove a device, destroy any tables. 48*86d7f5d3SJohn Marino * 49*86d7f5d3SJohn Marino * DM_DEV_RENAME: 50*86d7f5d3SJohn Marino * Rename a device. 51*86d7f5d3SJohn Marino * 52*86d7f5d3SJohn Marino * DM_SUSPEND: 53*86d7f5d3SJohn Marino * This performs both suspend and resume, depending which flag is 54*86d7f5d3SJohn Marino * passed in. 55*86d7f5d3SJohn Marino * Suspend: This command will not return until all pending io to 56*86d7f5d3SJohn Marino * the device has completed. Further io will be deferred until 57*86d7f5d3SJohn Marino * the device is resumed. 58*86d7f5d3SJohn Marino * Resume: It is no longer an error to issue this command on an 59*86d7f5d3SJohn Marino * unsuspended device. If a table is present in the 'inactive' 60*86d7f5d3SJohn Marino * slot, it will be moved to the active slot, then the old table 61*86d7f5d3SJohn Marino * from the active slot will be _destroyed_. Finally the device 62*86d7f5d3SJohn Marino * is resumed. 63*86d7f5d3SJohn Marino * 64*86d7f5d3SJohn Marino * DM_DEV_STATUS: 65*86d7f5d3SJohn Marino * Retrieves the status for the table in the 'active' slot. 66*86d7f5d3SJohn Marino * 67*86d7f5d3SJohn Marino * DM_DEV_WAIT: 68*86d7f5d3SJohn Marino * Wait for a significant event to occur to the device. This 69*86d7f5d3SJohn Marino * could either be caused by an event triggered by one of the 70*86d7f5d3SJohn Marino * targets of the table in the 'active' slot, or a table change. 71*86d7f5d3SJohn Marino * 72*86d7f5d3SJohn Marino * DM_TABLE_LOAD: 73*86d7f5d3SJohn Marino * Load a table into the 'inactive' slot for the device. The 74*86d7f5d3SJohn Marino * device does _not_ need to be suspended prior to this command. 75*86d7f5d3SJohn Marino * 76*86d7f5d3SJohn Marino * DM_TABLE_CLEAR: 77*86d7f5d3SJohn Marino * Destroy any table in the 'inactive' slot (ie. abort). 78*86d7f5d3SJohn Marino * 79*86d7f5d3SJohn Marino * DM_TABLE_DEPS: 80*86d7f5d3SJohn Marino * Return a set of device dependencies for the 'active' table. 81*86d7f5d3SJohn Marino * 82*86d7f5d3SJohn Marino * DM_TABLE_STATUS: 83*86d7f5d3SJohn Marino * Return the targets status for the 'active' table. 84*86d7f5d3SJohn Marino * 85*86d7f5d3SJohn Marino * DM_TARGET_MSG: 86*86d7f5d3SJohn Marino * Pass a message string to the target at a specific offset of a device. 87*86d7f5d3SJohn Marino * 88*86d7f5d3SJohn Marino * DM_DEV_SET_GEOMETRY: 89*86d7f5d3SJohn Marino * Set the geometry of a device by passing in a string in this format: 90*86d7f5d3SJohn Marino * 91*86d7f5d3SJohn Marino * "cylinders heads sectors_per_track start_sector" 92*86d7f5d3SJohn Marino * 93*86d7f5d3SJohn Marino * Beware that CHS geometry is nearly obsolete and only provided 94*86d7f5d3SJohn Marino * for compatibility with dm devices that can be booted by a PC 95*86d7f5d3SJohn Marino * BIOS. See struct hd_geometry for range limits. Also note that 96*86d7f5d3SJohn Marino * the geometry is erased if the device size changes. 97*86d7f5d3SJohn Marino */ 98*86d7f5d3SJohn Marino 99*86d7f5d3SJohn Marino /* 100*86d7f5d3SJohn Marino * All ioctl arguments consist of a single chunk of memory, with 101*86d7f5d3SJohn Marino * this structure at the start. If a uuid is specified any 102*86d7f5d3SJohn Marino * lookup (eg. for a DM_INFO) will be done on that, *not* the 103*86d7f5d3SJohn Marino * name. 104*86d7f5d3SJohn Marino */ 105*86d7f5d3SJohn Marino struct dm_ioctl { 106*86d7f5d3SJohn Marino /* 107*86d7f5d3SJohn Marino * The version number is made up of three parts: 108*86d7f5d3SJohn Marino * major - no backward or forward compatibility, 109*86d7f5d3SJohn Marino * minor - only backwards compatible, 110*86d7f5d3SJohn Marino * patch - both backwards and forwards compatible. 111*86d7f5d3SJohn Marino * 112*86d7f5d3SJohn Marino * All clients of the ioctl interface should fill in the 113*86d7f5d3SJohn Marino * version number of the interface that they were 114*86d7f5d3SJohn Marino * compiled with. 115*86d7f5d3SJohn Marino * 116*86d7f5d3SJohn Marino * All recognised ioctl commands (ie. those that don't 117*86d7f5d3SJohn Marino * return -ENOTTY) fill out this field, even if the 118*86d7f5d3SJohn Marino * command failed. 119*86d7f5d3SJohn Marino */ 120*86d7f5d3SJohn Marino uint32_t version[3]; /* in/out */ 121*86d7f5d3SJohn Marino uint32_t data_size; /* total size of data passed in 122*86d7f5d3SJohn Marino * including this struct */ 123*86d7f5d3SJohn Marino 124*86d7f5d3SJohn Marino uint32_t data_start; /* offset to start of data 125*86d7f5d3SJohn Marino * relative to start of this struct */ 126*86d7f5d3SJohn Marino 127*86d7f5d3SJohn Marino uint32_t target_count; /* in/out */ 128*86d7f5d3SJohn Marino int32_t open_count; /* out */ 129*86d7f5d3SJohn Marino uint32_t flags; /* in/out */ 130*86d7f5d3SJohn Marino 131*86d7f5d3SJohn Marino /* 132*86d7f5d3SJohn Marino * event_nr holds either the event number (input and output) or the 133*86d7f5d3SJohn Marino * udev cookie value (input only). 134*86d7f5d3SJohn Marino * The DM_DEV_WAIT ioctl takes an event number as input. 135*86d7f5d3SJohn Marino * The DM_SUSPEND, DM_DEV_REMOVE and DM_DEV_RENAME ioctls 136*86d7f5d3SJohn Marino * use the field as a cookie to return in the DM_COOKIE 137*86d7f5d3SJohn Marino * variable with the uevents they issue. 138*86d7f5d3SJohn Marino * For output, the ioctls return the event number, not the cookie. 139*86d7f5d3SJohn Marino */ 140*86d7f5d3SJohn Marino uint32_t event_nr; /* in/out */ 141*86d7f5d3SJohn Marino uint32_t padding; 142*86d7f5d3SJohn Marino 143*86d7f5d3SJohn Marino uint64_t dev; /* in/out */ 144*86d7f5d3SJohn Marino 145*86d7f5d3SJohn Marino char name[DM_NAME_LEN]; /* device name */ 146*86d7f5d3SJohn Marino char uuid[DM_UUID_LEN]; /* unique identifier for 147*86d7f5d3SJohn Marino * the block device */ 148*86d7f5d3SJohn Marino char data[7]; /* padding or data */ 149*86d7f5d3SJohn Marino }; 150*86d7f5d3SJohn Marino 151*86d7f5d3SJohn Marino /* 152*86d7f5d3SJohn Marino * Used to specify tables. These structures appear after the 153*86d7f5d3SJohn Marino * dm_ioctl. 154*86d7f5d3SJohn Marino */ 155*86d7f5d3SJohn Marino struct dm_target_spec { 156*86d7f5d3SJohn Marino uint64_t sector_start; 157*86d7f5d3SJohn Marino uint64_t length; 158*86d7f5d3SJohn Marino int32_t status; /* used when reading from kernel only */ 159*86d7f5d3SJohn Marino 160*86d7f5d3SJohn Marino /* 161*86d7f5d3SJohn Marino * Location of the next dm_target_spec. 162*86d7f5d3SJohn Marino * - When specifying targets on a DM_TABLE_LOAD command, this value is 163*86d7f5d3SJohn Marino * the number of bytes from the start of the "current" dm_target_spec 164*86d7f5d3SJohn Marino * to the start of the "next" dm_target_spec. 165*86d7f5d3SJohn Marino * - When retrieving targets on a DM_TABLE_STATUS command, this value 166*86d7f5d3SJohn Marino * is the number of bytes from the start of the first dm_target_spec 167*86d7f5d3SJohn Marino * (that follows the dm_ioctl struct) to the start of the "next" 168*86d7f5d3SJohn Marino * dm_target_spec. 169*86d7f5d3SJohn Marino */ 170*86d7f5d3SJohn Marino uint32_t next; 171*86d7f5d3SJohn Marino 172*86d7f5d3SJohn Marino char target_type[DM_MAX_TYPE_NAME]; 173*86d7f5d3SJohn Marino 174*86d7f5d3SJohn Marino /* 175*86d7f5d3SJohn Marino * Parameter string starts immediately after this object. 176*86d7f5d3SJohn Marino * Be careful to add padding after string to ensure correct 177*86d7f5d3SJohn Marino * alignment of subsequent dm_target_spec. 178*86d7f5d3SJohn Marino */ 179*86d7f5d3SJohn Marino }; 180*86d7f5d3SJohn Marino 181*86d7f5d3SJohn Marino /* 182*86d7f5d3SJohn Marino * Used to retrieve the target dependencies. 183*86d7f5d3SJohn Marino */ 184*86d7f5d3SJohn Marino struct dm_target_deps { 185*86d7f5d3SJohn Marino uint32_t count; /* Array size */ 186*86d7f5d3SJohn Marino uint32_t padding; /* unused */ 187*86d7f5d3SJohn Marino uint64_t dev[0]; /* out */ 188*86d7f5d3SJohn Marino }; 189*86d7f5d3SJohn Marino 190*86d7f5d3SJohn Marino /* 191*86d7f5d3SJohn Marino * Used to get a list of all dm devices. 192*86d7f5d3SJohn Marino */ 193*86d7f5d3SJohn Marino struct dm_name_list { 194*86d7f5d3SJohn Marino uint64_t dev; 195*86d7f5d3SJohn Marino uint32_t next; /* offset to the next record from 196*86d7f5d3SJohn Marino the _start_ of this */ 197*86d7f5d3SJohn Marino char name[0]; 198*86d7f5d3SJohn Marino }; 199*86d7f5d3SJohn Marino 200*86d7f5d3SJohn Marino /* 201*86d7f5d3SJohn Marino * Used to retrieve the target versions 202*86d7f5d3SJohn Marino */ 203*86d7f5d3SJohn Marino struct dm_target_versions { 204*86d7f5d3SJohn Marino uint32_t next; 205*86d7f5d3SJohn Marino uint32_t version[3]; 206*86d7f5d3SJohn Marino 207*86d7f5d3SJohn Marino char name[0]; 208*86d7f5d3SJohn Marino }; 209*86d7f5d3SJohn Marino 210*86d7f5d3SJohn Marino /* 211*86d7f5d3SJohn Marino * Used to pass message to a target 212*86d7f5d3SJohn Marino */ 213*86d7f5d3SJohn Marino struct dm_target_msg { 214*86d7f5d3SJohn Marino uint64_t sector; /* Device sector */ 215*86d7f5d3SJohn Marino 216*86d7f5d3SJohn Marino char message[0]; 217*86d7f5d3SJohn Marino }; 218*86d7f5d3SJohn Marino 219*86d7f5d3SJohn Marino /* 220*86d7f5d3SJohn Marino * If you change this make sure you make the corresponding change 221*86d7f5d3SJohn Marino * to dm-ioctl.c:lookup_ioctl() 222*86d7f5d3SJohn Marino */ 223*86d7f5d3SJohn Marino enum { 224*86d7f5d3SJohn Marino /* Top level cmds */ 225*86d7f5d3SJohn Marino DM_VERSION_CMD = 0, 226*86d7f5d3SJohn Marino DM_REMOVE_ALL_CMD, 227*86d7f5d3SJohn Marino DM_LIST_DEVICES_CMD, 228*86d7f5d3SJohn Marino 229*86d7f5d3SJohn Marino /* device level cmds */ 230*86d7f5d3SJohn Marino DM_DEV_CREATE_CMD, 231*86d7f5d3SJohn Marino DM_DEV_REMOVE_CMD, 232*86d7f5d3SJohn Marino DM_DEV_RENAME_CMD, 233*86d7f5d3SJohn Marino DM_DEV_SUSPEND_CMD, 234*86d7f5d3SJohn Marino DM_DEV_STATUS_CMD, 235*86d7f5d3SJohn Marino DM_DEV_WAIT_CMD, 236*86d7f5d3SJohn Marino 237*86d7f5d3SJohn Marino /* Table level cmds */ 238*86d7f5d3SJohn Marino DM_TABLE_LOAD_CMD, 239*86d7f5d3SJohn Marino DM_TABLE_CLEAR_CMD, 240*86d7f5d3SJohn Marino DM_TABLE_DEPS_CMD, 241*86d7f5d3SJohn Marino DM_TABLE_STATUS_CMD, 242*86d7f5d3SJohn Marino 243*86d7f5d3SJohn Marino /* Added later */ 244*86d7f5d3SJohn Marino DM_LIST_VERSIONS_CMD, 245*86d7f5d3SJohn Marino DM_TARGET_MSG_CMD, 246*86d7f5d3SJohn Marino DM_DEV_SET_GEOMETRY_CMD 247*86d7f5d3SJohn Marino }; 248*86d7f5d3SJohn Marino 249*86d7f5d3SJohn Marino #define DM_IOCTL 0xfd 250*86d7f5d3SJohn Marino 251*86d7f5d3SJohn Marino #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl) 252*86d7f5d3SJohn Marino #define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl) 253*86d7f5d3SJohn Marino #define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl) 254*86d7f5d3SJohn Marino 255*86d7f5d3SJohn Marino #define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl) 256*86d7f5d3SJohn Marino #define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl) 257*86d7f5d3SJohn Marino #define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl) 258*86d7f5d3SJohn Marino #define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl) 259*86d7f5d3SJohn Marino #define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl) 260*86d7f5d3SJohn Marino #define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl) 261*86d7f5d3SJohn Marino 262*86d7f5d3SJohn Marino #define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl) 263*86d7f5d3SJohn Marino #define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl) 264*86d7f5d3SJohn Marino #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl) 265*86d7f5d3SJohn Marino #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl) 266*86d7f5d3SJohn Marino 267*86d7f5d3SJohn Marino #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl) 268*86d7f5d3SJohn Marino 269*86d7f5d3SJohn Marino #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl) 270*86d7f5d3SJohn Marino #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) 271*86d7f5d3SJohn Marino 272*86d7f5d3SJohn Marino #define DM_VERSION_MAJOR 4 273*86d7f5d3SJohn Marino #define DM_VERSION_MINOR 16 274*86d7f5d3SJohn Marino #define DM_VERSION_PATCHLEVEL 0 275*86d7f5d3SJohn Marino #define DM_VERSION_EXTRA "-ioctl (2009-11-05)" 276*86d7f5d3SJohn Marino 277*86d7f5d3SJohn Marino /* Status bits */ 278*86d7f5d3SJohn Marino #define DM_READONLY_FLAG (1 << 0) /* In/Out */ 279*86d7f5d3SJohn Marino #define DM_SUSPEND_FLAG (1 << 1) /* In/Out */ 280*86d7f5d3SJohn Marino #define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */ 281*86d7f5d3SJohn Marino 282*86d7f5d3SJohn Marino /* 283*86d7f5d3SJohn Marino * Flag passed into ioctl STATUS command to get table information 284*86d7f5d3SJohn Marino * rather than current status. 285*86d7f5d3SJohn Marino */ 286*86d7f5d3SJohn Marino #define DM_STATUS_TABLE_FLAG (1 << 4) /* In */ 287*86d7f5d3SJohn Marino 288*86d7f5d3SJohn Marino /* 289*86d7f5d3SJohn Marino * Flags that indicate whether a table is present in either of 290*86d7f5d3SJohn Marino * the two table slots that a device has. 291*86d7f5d3SJohn Marino */ 292*86d7f5d3SJohn Marino #define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */ 293*86d7f5d3SJohn Marino #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */ 294*86d7f5d3SJohn Marino 295*86d7f5d3SJohn Marino /* 296*86d7f5d3SJohn Marino * Indicates that the buffer passed in wasn't big enough for the 297*86d7f5d3SJohn Marino * results. 298*86d7f5d3SJohn Marino */ 299*86d7f5d3SJohn Marino #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */ 300*86d7f5d3SJohn Marino 301*86d7f5d3SJohn Marino /* 302*86d7f5d3SJohn Marino * This flag is now ignored. 303*86d7f5d3SJohn Marino */ 304*86d7f5d3SJohn Marino #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */ 305*86d7f5d3SJohn Marino 306*86d7f5d3SJohn Marino /* 307*86d7f5d3SJohn Marino * Set this to avoid attempting to freeze any filesystem when suspending. 308*86d7f5d3SJohn Marino */ 309*86d7f5d3SJohn Marino #define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */ 310*86d7f5d3SJohn Marino 311*86d7f5d3SJohn Marino /* 312*86d7f5d3SJohn Marino * Set this to suspend without flushing queued ios. 313*86d7f5d3SJohn Marino */ 314*86d7f5d3SJohn Marino #define DM_NOFLUSH_FLAG (1 << 11) /* In */ 315*86d7f5d3SJohn Marino 316*86d7f5d3SJohn Marino /* 317*86d7f5d3SJohn Marino * If set, any table information returned will relate to the inactive 318*86d7f5d3SJohn Marino * table instead of the live one. Always check DM_INACTIVE_PRESENT_FLAG 319*86d7f5d3SJohn Marino * is set before using the data returned. 320*86d7f5d3SJohn Marino */ 321*86d7f5d3SJohn Marino #define DM_QUERY_INACTIVE_TABLE_FLAG (1 << 12) /* In */ 322*86d7f5d3SJohn Marino 323*86d7f5d3SJohn Marino #endif /* _LINUX_DM_IOCTL_H */ 324