| 1 | /* $NetBSD: netbsd-dm.h,v 1.7 2015/09/06 06:01:00 dholland Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * This code is derived from software contributed to The NetBSD Foundation |
| 8 | * by Adam Hamsik. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
| 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | #ifndef __NETBSD_DM_H__ |
| 33 | #define __NETBSD_DM_H__ |
| 34 | |
| 35 | #include <sys/ioccom.h> |
| 36 | #include <prop/proplib.h> |
| 37 | |
| 38 | #define DM_CMD_LEN 16 |
| 39 | |
| 40 | #define DM_IOCTL 0xfd |
| 41 | |
| 42 | #define DM_IOCTL_CMD 0 |
| 43 | |
| 44 | #define NETBSD_DM_IOCTL _IOWR(DM_IOCTL, DM_IOCTL_CMD, struct plistref) |
| 45 | |
| 46 | |
| 47 | /* |
| 48 | * DM-ioctl dictionary. |
| 49 | * |
| 50 | * This contains general information about dm device. |
| 51 | * |
| 52 | * <dict> |
| 53 | * <key>command</key> |
| 54 | * <string>...</string> |
| 55 | * |
| 56 | * <key>event_nr</key> |
| 57 | * <integer>...</integer> |
| 58 | * |
| 59 | * <key>name</key> |
| 60 | * <string>...</string> |
| 61 | * |
| 62 | * <key>uuid</key> |
| 63 | * <string>...</string> |
| 64 | * |
| 65 | * <key>dev</key> |
| 66 | * <integer></integer> |
| 67 | * |
| 68 | * <key>flags</key> |
| 69 | * <integer></integer> |
| 70 | * |
| 71 | * <key>version</key> |
| 72 | * <array> |
| 73 | * <integer>...</integer> |
| 74 | * <integer>...</integer> |
| 75 | * <integer>...</integer> |
| 76 | * </array> |
| 77 | * |
| 78 | * <key>cmd_data</key> |
| 79 | * <array> |
| 80 | * <!-- See below for command |
| 81 | * specific dictionaries --> |
| 82 | * </array> |
| 83 | * </dict> |
| 84 | * |
| 85 | * Available commands from _cmd_data_v4. |
| 86 | * |
| 87 | * create, reload, remove, remove_all, suspend, |
| 88 | * resume, info, deps, rename, version, status, |
| 89 | * table, waitevent, names, clear, mknodes, |
| 90 | * targets, message, setgeometry |
| 91 | * |
| 92 | */ |
| 93 | |
| 94 | /* |
| 95 | * DM_LIST_VERSIONS == "targets" command dictionary entry. |
| 96 | * Lists all available targets with their version. |
| 97 | * |
| 98 | * <array> |
| 99 | * <dict> |
| 100 | * <key>name<key> |
| 101 | * <string>...</string> |
| 102 | * |
| 103 | * <key>version</key> |
| 104 | * <array> |
| 105 | * <integer>...</integer> |
| 106 | * <integer>...</integer> |
| 107 | * <integer>...</integer> |
| 108 | * </array> |
| 109 | * </dict> |
| 110 | * </array> |
| 111 | * |
| 112 | */ |
| 113 | |
| 114 | /* |
| 115 | * DM_DEV_LIST == "names" |
| 116 | * Request list of device-mapper created devices from kernel. |
| 117 | * |
| 118 | * <array> |
| 119 | * <dict> |
| 120 | * <key>name<key> |
| 121 | * <string>...</string> |
| 122 | * |
| 123 | * <key>dev</key> |
| 124 | * <integer>...</integer> |
| 125 | * </dict> |
| 126 | * </array> |
| 127 | * |
| 128 | * dev is uint64_t |
| 129 | * |
| 130 | */ |
| 131 | |
| 132 | /* |
| 133 | * DM_DEV_RENAME == "rename" |
| 134 | * Rename device to string. |
| 135 | * |
| 136 | * <array> |
| 137 | * <string>...</string> |
| 138 | * </array> |
| 139 | * |
| 140 | */ |
| 141 | |
| 142 | /* |
| 143 | * DM_DEV_STATUS == "info, mknodes" |
| 144 | * Will change fields DM_IOCTL_OPEN, DM_IOCTL_DEV in received dictionary, |
| 145 | * with dm device values with name or uuid from list. |
| 146 | * |
| 147 | */ |
| 148 | |
| 149 | /* |
| 150 | * DM_TABLE_STATUS == "status,table" |
| 151 | * Request list of device-mapper created devices from kernel. |
| 152 | * |
| 153 | * <array> |
| 154 | * <dict> |
| 155 | * <key>type<key> |
| 156 | * <string>...</string> |
| 157 | * |
| 158 | * <key>start</key> |
| 159 | * <integer>...</integer> |
| 160 | * |
| 161 | * <key>length</key> |
| 162 | * <integer>...</integer> |
| 163 | * |
| 164 | * <key>params</key> |
| 165 | * <string>...</string> |
| 166 | * </dict> |
| 167 | * </array> |
| 168 | * |
| 169 | * params is string which contains {device} {parameters} |
| 170 | * |
| 171 | */ |
| 172 | |
| 173 | /* |
| 174 | * DM_TABLE_DEPS == "deps" |
| 175 | * Request list active table device dependiences. |
| 176 | * |
| 177 | * This command is also run to get dm-device |
| 178 | * dependiences for existing real block device. |
| 179 | * |
| 180 | * eg. vgcreate calls DM_TABLE_DEPS |
| 181 | * |
| 182 | * <array> |
| 183 | * <integer>...</integer> |
| 184 | * </array> |
| 185 | * |
| 186 | */ |
| 187 | |
| 188 | |
| 189 | #define DM_IOCTL_COMMAND "command" |
| 190 | #define DM_IOCTL_VERSION "version" |
| 191 | #define DM_IOCTL_OPEN "open_count" |
| 192 | #define DM_IOCTL_MINOR "minor" |
| 193 | #define DM_IOCTL_NAME "name" |
| 194 | #define DM_IOCTL_UUID "uuid" |
| 195 | #define DM_IOCTL_TARGET_COUNT "target_count" |
| 196 | #define DM_IOCTL_EVENT "event_nr" |
| 197 | #define DM_IOCTL_FLAGS "flags" |
| 198 | #define DM_IOCTL_CMD_DATA "cmd_data" |
| 199 | |
| 200 | #define DM_TARGETS_NAME "name" |
| 201 | #define DM_TARGETS_VERSION "ver" |
| 202 | |
| 203 | #define DM_DEV_NEWNAME "newname" |
| 204 | #define DM_DEV_NAME "name" |
| 205 | #define DM_DEV_DEV "dev" |
| 206 | |
| 207 | #define DM_TABLE_TYPE "type" |
| 208 | #define DM_TABLE_START "start" |
| 209 | #define DM_TABLE_STAT "status" |
| 210 | #define DM_TABLE_LENGTH "length" |
| 211 | #define DM_TABLE_PARAMS "params" |
| 212 | //#ifndef __LIB_DEVMAPPER__ |
| 213 | //#define DM_TABLE_DEPS "deps" |
| 214 | //#endif |
| 215 | |
| 216 | /* Status bits */ |
| 217 | /* IO mode of device */ |
| 218 | #define DM_READONLY_FLAG (1 << 0) /* In/Out *//* to kernel/from kernel */ |
| 219 | #define DM_SUSPEND_FLAG (1 << 1) /* In/Out */ |
| 220 | /* XXX. This flag is undocumented. */ |
| 221 | #define DM_EXISTS_FLAG (1 << 2) /* In/Out */ |
| 222 | /* Minor number is persistent */ |
| 223 | #define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */ |
| 224 | |
| 225 | /* |
| 226 | * Flag passed into ioctl STATUS command to get table information |
| 227 | * rather than current status. |
| 228 | */ |
| 229 | #define DM_STATUS_TABLE_FLAG (1 << 4) /* In */ |
| 230 | |
| 231 | /* |
| 232 | * Flags that indicate whether a table is present in either of |
| 233 | * the two table slots that a device has. |
| 234 | */ |
| 235 | #define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */ |
| 236 | #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */ |
| 237 | |
| 238 | /* |
| 239 | * Indicates that the buffer passed in wasn't big enough for the |
| 240 | * results. |
| 241 | */ |
| 242 | #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */ |
| 243 | |
| 244 | /* |
| 245 | * This flag is now ignored. |
| 246 | */ |
| 247 | #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */ |
| 248 | |
| 249 | /* |
| 250 | * Set this to avoid attempting to freeze any filesystem when suspending. |
| 251 | */ |
| 252 | #define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */ |
| 253 | |
| 254 | /* |
| 255 | * Set this to suspend without flushing queued ios. |
| 256 | */ |
| 257 | #define DM_NOFLUSH_FLAG (1 << 11) /* In */ |
| 258 | |
| 259 | /* |
| 260 | * If set, any table information returned will relate to the inactive |
| 261 | * table instead of the live one. Always check DM_INACTIVE_PRESENT_FLAG |
| 262 | * is set before using the data returned. |
| 263 | */ |
| 264 | #define DM_QUERY_INACTIVE_TABLE_FLAG (1 << 12) /* In */ |
| 265 | |
| 266 | #endif /* __NETBSD_DM_H__ */ |
| 267 | |