Home | History | Annotate | Line # | Download | only in dm
netbsd-dm.h revision 1.3.8.3
      1 /*        $NetBSD: netbsd-dm.h,v 1.3.8.3 2009/06/20 07:20:21 yamt 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 <prop/proplib.h>
     36 
     37 #define DM_CMD_LEN 16
     38 
     39 #define DM_IOCTL 0xfd
     40 
     41 #define DM_IOCTL_CMD 0
     42 
     43 #define NETBSD_DM_IOCTL       _IOWR(DM_IOCTL, DM_IOCTL_CMD, struct plistref)
     44 
     45 
     46 /*
     47  * DM-ioctl dictionary.
     48  *
     49  * This contains general information about dm device.
     50  *
     51  * <dict>
     52  *     <key>command</key>
     53  *     <string>...</string>
     54  *
     55  *     <key>event_nr</key>
     56  *     <integer>...</integer>
     57  *
     58  *     <key>name</key>
     59  *     <string>...</string>
     60  *
     61  *     <key>uuid</key>
     62  *     <string>...</string>
     63  *
     64  *     <key>dev</key>
     65  *     <integer></integer>
     66  *
     67  *     <key>flags</key>
     68  *     <integer></integer>
     69  *
     70  *     <key>version</key>
     71  *      <array>
     72  *       <integer>...</integer>
     73  *       <integer>...</integer>
     74  *       <integer>...</integer>
     75  *      </array>
     76  *
     77  *      <key>cmd_data</key>
     78  *       <array>
     79  *        <!-- See below for command
     80  *             specific dictionaries -->
     81  *       </array>
     82  * </dict>
     83  *
     84  * Available commands from _cmd_data_v4.
     85  *
     86  * create, reload, remove, remove_all, suspend,
     87  * resume, info, deps, rename, version, status,
     88  * table, waitevent, names, clear, mknodes,
     89  * targets, message, setgeometry
     90  *
     91  */
     92 
     93 /*
     94  * DM_LIST_VERSIONS == "targets" command dictionary entry.
     95  * Lists all available targets with their version.
     96  *
     97  * <array>
     98  *   <dict>
     99  *    <key>name<key>
    100  *    <string>...</string>
    101  *
    102  *    <key>version</key>
    103  *      <array>
    104  *       <integer>...</integer>
    105  *       <integer>...</integer>
    106  *       <integer>...</integer>
    107  *      </array>
    108  *   </dict>
    109  * </array>
    110  *
    111  */
    112 
    113 /*
    114  * DM_DEV_LIST == "names"
    115  * Request list of device-mapper created devices from kernel.
    116  *
    117  * <array>
    118  *   <dict>
    119  *    <key>name<key>
    120  *    <string>...</string>
    121  *
    122  *    <key>dev</key>
    123  *    <integer>...</integer>
    124  *   </dict>
    125  * </array>
    126  *
    127  * dev is uint64_t
    128  *
    129  */
    130 
    131  /*
    132   * DM_DEV_RENAME == "rename"
    133   * Rename device to string.
    134   *
    135   * <array>
    136   *    <string>...</string>
    137   * </array>
    138   *
    139   */
    140 
    141  /*
    142   * DM_DEV_STATUS == "info, mknodes"
    143   * Will change fields DM_IOCTL_OPEN, DM_IOCTL_DEV in received dictionary,
    144   * with dm device values with name or uuid from list.
    145   *
    146   */
    147 
    148  /*
    149   * DM_TABLE_STATUS == "status,table"
    150   * Request list of device-mapper created devices from kernel.
    151   *
    152   * <array>
    153   *   <dict>
    154   *    <key>type<key>
    155   *    <string>...</string>
    156   *
    157   *    <key>start</key>
    158   *    <integer>...</integer>
    159   *
    160   *    <key>length</key>
    161   *    <integer>...</integer>
    162   *
    163   *    <key>params</key>
    164   *    <string>...</string>
    165   *   </dict>
    166   * </array>
    167   *
    168   * params is string which contains {device} {parameters}
    169   *
    170   */
    171 
    172  /*
    173   * DM_TABLE_DEPS == "deps"
    174   * Request list active table device dependiences.
    175   *
    176   * This command is also run to get dm-device
    177   * dependiences for existing real block device.
    178   *
    179   * eg. vgcreate calls DM_TABLE_DEPS
    180   *
    181   * <array>
    182   *   <integer>...</integer>
    183   * </array>
    184   *
    185   */
    186 
    187 
    188 #define DM_IOCTL_COMMAND      "command"
    189 #define DM_IOCTL_VERSION      "version"
    190 #define DM_IOCTL_OPEN         "open_count"
    191 #define DM_IOCTL_MINOR        "minor"
    192 #define DM_IOCTL_NAME         "name"
    193 #define DM_IOCTL_UUID         "uuid"
    194 #define DM_IOCTL_TARGET_COUNT "target_count"
    195 #define DM_IOCTL_EVENT        "event_nr"
    196 #define DM_IOCTL_FLAGS        "flags"
    197 #define DM_IOCTL_CMD_DATA     "cmd_data"
    198 
    199 #define DM_TARGETS_NAME       "name"
    200 #define DM_TARGETS_VERSION    "ver"
    201 
    202 #define DM_DEV_NEWNAME        "newname"
    203 #define DM_DEV_NAME           "name"
    204 #define DM_DEV_DEV            "dev"
    205 
    206 #define DM_TABLE_TYPE         "type"
    207 #define DM_TABLE_START        "start"
    208 #define DM_TABLE_STAT         "status"
    209 #define DM_TABLE_LENGTH       "length"
    210 #define DM_TABLE_PARAMS       "params"
    211 
    212 #define DM_TARGET_LINEAR_DEVICE "device"
    213 #define DM_TARGET_LINEAR_OFFSET "offset"
    214 
    215 #define DM_TARGET_STRIPE_DEVARRAY  "device_array"
    216 #define DM_TARGET_STRIPE_DEVICE    "device"
    217 #define DM_TARGET_STRIPE_OFFSET    "offset"
    218 #define DM_TARGET_STRIPE_STRIPES   "stripes"
    219 #define DM_TARGET_STRIPE_CHUNKSIZE "chunk_size"
    220 
    221 
    222 //#ifndef __LIB_DEVMAPPER__
    223 //#define DM_TABLE_DEPS         "deps"
    224 //#endif
    225 
    226 /* Status bits */
    227 /* IO mode of device */
    228 #define DM_READONLY_FLAG	(1 << 0) /* In/Out *//* to kernel/from kernel */
    229 #define DM_SUSPEND_FLAG		(1 << 1) /* In/Out */
    230 /* XXX. This flag is undocumented. */
    231 #define DM_EXISTS_FLAG          (1 << 2) /* In/Out */
    232 /* Minor number is persistent */
    233 #define DM_PERSISTENT_DEV_FLAG	(1 << 3) /* In */
    234 
    235 /*
    236  * Flag passed into ioctl STATUS command to get table information
    237  * rather than current status.
    238  */
    239 #define DM_STATUS_TABLE_FLAG	(1 << 4) /* In */
    240 
    241 /*
    242  * Flags that indicate whether a table is present in either of
    243  * the two table slots that a device has.
    244  */
    245 #define DM_ACTIVE_PRESENT_FLAG   (1 << 5) /* Out */
    246 #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
    247 
    248 /*
    249  * Indicates that the buffer passed in wasn't big enough for the
    250  * results.
    251  */
    252 #define DM_BUFFER_FULL_FLAG	(1 << 8) /* Out */
    253 
    254 /*
    255  * This flag is now ignored.
    256  */
    257 #define DM_SKIP_BDGET_FLAG	(1 << 9) /* In */
    258 
    259 /*
    260  * Set this to avoid attempting to freeze any filesystem when suspending.
    261  */
    262 #define DM_SKIP_LOCKFS_FLAG	(1 << 10) /* In */
    263 
    264 /*
    265  * Set this to suspend without flushing queued ios.
    266  */
    267 #define DM_NOFLUSH_FLAG		(1 << 11) /* In */
    268 
    269 #ifdef __LIB_DEVMAPPER__
    270 
    271 #  define MAJOR(x) major((x))
    272 #  define MINOR(x) minor((x))
    273 #  define MKDEV(x,y) makedev((x),(y))
    274 
    275 /* Name of device-mapper driver in kernel */
    276 #define DM_NAME "dm"
    277 
    278 /* Types for nbsd_get_dm_major */
    279 #define DM_CHAR_MAJOR 1
    280 #define DM_BLOCK_MAJOR 2
    281 
    282 /* libdm_netbsd.c */
    283 int nbsd_get_dm_major(uint32_t *, int); /* Get dm device major numbers */
    284 
    285 int nbsd_dmi_add_cmd(const char *, prop_dictionary_t);
    286 int nbsd_dmi_add_version(const int [3], prop_dictionary_t);
    287 int nbsd_dm_add_uint(const char *, uint64_t, prop_dictionary_t);
    288 int nbsd_dm_add_str(const char *, char *, prop_dictionary_t );
    289 
    290 prop_dictionary_t nbsd_dm_parse_param(const char *, char *);
    291 
    292 struct dm_ioctl* nbsd_dm_dict_to_dmi(prop_dictionary_t, const int);
    293 
    294 #endif /* __LIB_DEVMAPPER__ */
    295 
    296 #endif /* __NETBSD_DM_H__ */
    297