1ff56536eSAlex Hornung Device-mapper to libdevmapper protocol 2ff56536eSAlex Hornung 3ff56536eSAlex Hornung 4ff56536eSAlex Hornung 5ff56536eSAlex Hornung 1) Device mapper device in a POV of LVM it is an Logical Volume. 6ff56536eSAlex Hornung Logical Volume is virtual block device is made from logical blocks. 7ff56536eSAlex Hornung These blocks are mapped to real device blocks with algorithm called 8ff56536eSAlex Hornung target. 9ff56536eSAlex Hornung 10ff56536eSAlex Hornung Functions available to dm device: 11ff56536eSAlex Hornung create, remove, list, status of device. 12ff56536eSAlex Hornung 13ff56536eSAlex Hornung 2) device mapper target is function which defines how are Logical blocks 14ff56536eSAlex Hornung mapped to physical. There are many targets linear, stripe, mirror etc. 15ff56536eSAlex Hornung 16ff56536eSAlex Hornung Functions available to dm device: 17ff56536eSAlex Hornung list available targets. They can be added with module in linux. 18ff56536eSAlex Hornung 19ff56536eSAlex Hornung 3) dm table. 20ff56536eSAlex Hornung Every device-mapper device consits from one or more tables. Table specify 21ff56536eSAlex Hornung Start, length of logical blocks and target which is used to map them to 22ff56536eSAlex Hornung physical blocks. 23ff56536eSAlex Hornung 24ff56536eSAlex Hornung {start} {length} {target} | {device} {target parameters} 25ff56536eSAlex Hornung 26ff56536eSAlex Hornung after | are target specific parameters listed. 27ff56536eSAlex Hornung 28ff56536eSAlex Hornung Functions available to dm device: 29ff56536eSAlex Hornung load, unload, table_status. 30ff56536eSAlex Hornung 31ff56536eSAlex Hornung 32ff56536eSAlex Hornung List of available ioct calls 33ff56536eSAlex Hornung 34ff56536eSAlex Hornung DM_VERSION 35ff56536eSAlex Hornung DM_REMOVE_ALL 36ff56536eSAlex Hornung DM_LIST_DEVICES 37ff56536eSAlex Hornung DM_DEV_CREATE 38ff56536eSAlex Hornung DM_DEV_REMOVE 39ff56536eSAlex Hornung DM_DEV_RENAME 40ff56536eSAlex Hornung DM_DEV_SUSPEND 41ff56536eSAlex Hornung DM_DEV_STATUS 42ff56536eSAlex Hornung DM_DEV_WAIT 43ff56536eSAlex Hornung DM_TABLE_LOAD 44ff56536eSAlex Hornung DM_TABLE_CLEAR 45ff56536eSAlex Hornung DM_TABLE_DEPS 46ff56536eSAlex Hornung DM_TABLE_STATUS 47ff56536eSAlex Hornung DM_LIST_VERSIONS 48ff56536eSAlex Hornung DM_TARGET_MSG 49ff56536eSAlex Hornung DM_DEV_SET_GEOMETRY 50ff56536eSAlex Hornung 51ff56536eSAlex Hornung 1) DM_VERSION 52ff56536eSAlex Hornung 53ff56536eSAlex Hornung in: struct dm-ioctl 54ff56536eSAlex Hornung 55ff56536eSAlex Hornung out: struct dm-ioctl 56ff56536eSAlex Hornung 57ff56536eSAlex Hornung Fuction: 58ff56536eSAlex Hornung sends libdevmapper ioctl protocol version to kernel and ask for kernel version. 59ff56536eSAlex Hornung If major and minor numbers are good we can continue. 60ff56536eSAlex Hornung 61ff56536eSAlex Hornung 2) DM_REMOVE_ALL 62ff56536eSAlex Hornung 63ff56536eSAlex Hornung in: none 64ff56536eSAlex Hornung 65ff56536eSAlex Hornung out: none 66ff56536eSAlex Hornung 67ff56536eSAlex Hornung Function: 68ff56536eSAlex Hornung This ioctl will remove all DM devices/tables from DM driver. 69ff56536eSAlex Hornung 70ff56536eSAlex Hornung 3) DM_LIST_DEVICES 71ff56536eSAlex Hornung 72ff56536eSAlex Hornung in: none 73ff56536eSAlex Hornung 74ff56536eSAlex Hornung out: List of structures describing all devices created in driver. 75ff56536eSAlex Hornung 76ff56536eSAlex Hornung Function: 77ff56536eSAlex Hornung List all devices created in driver. (linux use struct dm_name_list) 78ff56536eSAlex Hornung 79ff56536eSAlex Hornung Implementation: 80ff56536eSAlex Hornung Kernel driver will place list of struct dm_name_list behind 81ff56536eSAlex Hornung struct dm_ioctl in userspace. Kernel driver will list through 82ff56536eSAlex Hornung the all devices and copyout info about them. 83ff56536eSAlex Hornung 84ff56536eSAlex Hornung 4) DM_DEV_CREATE 85ff56536eSAlex Hornung 86ff56536eSAlex Hornung in: struct dm-ioctl(name/uuid) 87ff56536eSAlex Hornung 88ff56536eSAlex Hornung out: none 89ff56536eSAlex Hornung 90ff56536eSAlex Hornung Function: 91ff56536eSAlex Hornung Create device in dm driver, with specified name/uuid(uuid is prefered). 92ff56536eSAlex Hornung (linux use struct dm_name_list) 93ff56536eSAlex Hornung 94ff56536eSAlex Hornung 5) DM_DEV_REMOVE 95ff56536eSAlex Hornung 96ff56536eSAlex Hornung in: struct dm-ioctl(name/uuid) 97ff56536eSAlex Hornung 98ff56536eSAlex Hornung out: none 99ff56536eSAlex Hornung 100ff56536eSAlex Hornung Function: 101ff56536eSAlex Hornung Remove device from dm driver list, also remove device tables. 102ff56536eSAlex Hornung 103ff56536eSAlex Hornung 6) DM_DEV_RENAME 104ff56536eSAlex Hornung 105ff56536eSAlex Hornung in: struct dm-ioctl(name/uuid) and string found after dm-ioctl struct in buffer 106ff56536eSAlex Hornung 107ff56536eSAlex Hornung out: none 108ff56536eSAlex Hornung 109ff56536eSAlex Hornung Function: 110ff56536eSAlex Hornung Rename device from name to string. 111ff56536eSAlex Hornung 112ff56536eSAlex Hornung Implementation: 113ff56536eSAlex Hornung Kernel driver will find device with name from struct dm_ioctl-name/uuid. 114ff56536eSAlex Hornung Change name of selected device to string foun behind struc dm_ioctl header 115ff56536eSAlex Hornung in userspace buffer. 116ff56536eSAlex Hornung 117ff56536eSAlex Hornung 7) DM_DEV_SUSPEND 118ff56536eSAlex Hornung 119ff56536eSAlex Hornung in: dm-ioctl(name/uuid) 120ff56536eSAlex Hornung 121ff56536eSAlex Hornung out: none 122ff56536eSAlex Hornung 123ff56536eSAlex Hornung Function: 124ff56536eSAlex Hornung Suspend all io's on device, after this ioctl. Already started io's will be done. 125ff56536eSAlex Hornung Newer can't be started. 126ff56536eSAlex Hornung 127ff56536eSAlex Hornung 8) DM_DEV_STATUS 128ff56536eSAlex Hornung 129ff56536eSAlex Hornung in: dm-ioctl(name/uuid) 130ff56536eSAlex Hornung 131ff56536eSAlex Hornung out: dm-ioctl (minor,open_count,target_count) 132ff56536eSAlex Hornung 133ff56536eSAlex Hornung Function: 134ff56536eSAlex Hornung Return status info about selected device 135ff56536eSAlex Hornung 136ff56536eSAlex Hornung Implementation: 137ff56536eSAlex Hornung Kernel driver will find device with name from struct dm_ioctl-name/uuid. 138ff56536eSAlex Hornung Change values minor,open_count,target_count in dm_ioctl struct for 139ff56536eSAlex Hornung selected device. 140ff56536eSAlex Hornung 141ff56536eSAlex Hornung 9) DM_DEV_WAIT 142ff56536eSAlex Hornung 143ff56536eSAlex Hornung in: dm-ioctl(name/uuid) 144ff56536eSAlex Hornung 145ff56536eSAlex Hornung out: none 146ff56536eSAlex Hornung 147ff56536eSAlex Hornung Function: 148ff56536eSAlex Hornung Wait for device event to happen. 149ff56536eSAlex Hornung 150ff56536eSAlex Hornung 10) DM_TABLE_LOAD 151ff56536eSAlex Hornung 152ff56536eSAlex Hornung in: dm-ioctl(name/uuid),table specification 153ff56536eSAlex Hornung 154ff56536eSAlex Hornung out: none 155ff56536eSAlex Hornung 156ff56536eSAlex Hornung Function: 157ff56536eSAlex Hornung Load table to selected device. Table is loaded to unused slot and than switched. 158ff56536eSAlex Hornung (linux use struct dm_target_spec) 159ff56536eSAlex Hornung 160ff56536eSAlex Hornung Implementation: 161ff56536eSAlex Hornung Kernel driver will find device with name from struct dm_ioctl-name/uuid. 162ff56536eSAlex Hornung Table is added to the inactive slot. Every device can have more than one 1633cd1dc08STomohiro Kusumi table loaded. Tables are stored in TAILQ. This ioctl also open physical 164ff56536eSAlex Hornung device spedcified in table and add it to dm_device specific pdev list. 165ff56536eSAlex Hornung 166ff56536eSAlex Hornung 11) DM_TABLE_CLEAR 167ff56536eSAlex Hornung 168ff56536eSAlex Hornung in: dm-ioctl(name/uuid) 169ff56536eSAlex Hornung 170ff56536eSAlex Hornung out: none 171ff56536eSAlex Hornung 172ff56536eSAlex Hornung Function: 173ff56536eSAlex Hornung Remove table from unused slot. 174ff56536eSAlex Hornung 175ff56536eSAlex Hornung 12) DM_TABLE_DEPS 176ff56536eSAlex Hornung 177ff56536eSAlex Hornung in: dm-ioctl(name/uuid) 178ff56536eSAlex Hornung 179ff56536eSAlex Hornung out: list of dependiences devices 180ff56536eSAlex Hornung 181ff56536eSAlex Hornung Function: 182ff56536eSAlex Hornung Return set of device dependiences e.g. mirror device for mirror target etc.. 183ff56536eSAlex Hornung 184ff56536eSAlex Hornung 13) DM_TABLE_STATUS 185ff56536eSAlex Hornung 186ff56536eSAlex Hornung in: dm-ioctl(name/uuid) 187ff56536eSAlex Hornung 188ff56536eSAlex Hornung out: list of used tables from selected devices (linux use struct dm_target_spec) 189ff56536eSAlex Hornung 190ff56536eSAlex Hornung Function: 191ff56536eSAlex Hornung List all tables in active slot in device with name name/uuid. 192ff56536eSAlex Hornung 193ff56536eSAlex Hornung Implementation: 194ff56536eSAlex Hornung Kernel driver will find device with name from struct dm_ioctl-name/uuid. 195ff56536eSAlex Hornung DM driver will copyout dm_target_spec structures behidn struct dm_ioctl. 196ff56536eSAlex Hornung 197ff56536eSAlex Hornung 14) DM_LIST_VERSIONS 198ff56536eSAlex Hornung 199ff56536eSAlex Hornung in: none 200ff56536eSAlex Hornung 201ff56536eSAlex Hornung out: list of all targets in device-mapper driver (linux use struct dm_target_versions) 202ff56536eSAlex Hornung 203ff56536eSAlex Hornung Function: 204ff56536eSAlex Hornung List all available targets to libdevmapper. 205ff56536eSAlex Hornung 206ff56536eSAlex Hornung Implementation: 207ff56536eSAlex Hornung Kernel driver will copy out known target versions. 208ff56536eSAlex Hornung 209ff56536eSAlex Hornung 15) DM_TARGET_MSG 210ff56536eSAlex Hornung 211ff56536eSAlex Hornung in: message to driver (linux use struct dm_target_msg) 212ff56536eSAlex Hornung 213ff56536eSAlex Hornung out: none 214ff56536eSAlex Hornung 215ff56536eSAlex Hornung Function: 216ff56536eSAlex Hornung Send message to kernel driver target. 217ff56536eSAlex Hornung 218ff56536eSAlex Hornung 219ff56536eSAlex Hornung 16) DM_DEV_SET_GEOMETRY 220ff56536eSAlex Hornung 221ff56536eSAlex Hornung Function: 222ff56536eSAlex Hornung Set geometry of device-mapper driver. 223ff56536eSAlex Hornung 224ff56536eSAlex Hornung 225ff56536eSAlex Hornung NetBSD device-mapper driver implementation 226ff56536eSAlex Hornung 227ff56536eSAlex Hornung device-mapper devices -> devs dm_dev.c 228ff56536eSAlex Hornung 229ff56536eSAlex Hornung This entity is created with DM_DEV_CREATE ioctl, and stores info 230ff56536eSAlex Hornung about every device in device mapper driver. It has two slots for 231ff56536eSAlex Hornung active and inactive table, list of active physical devices added 232ff56536eSAlex Hornung to this device and list of upcalled devices (for targets which use 233ff56536eSAlex Hornung more than one physical device e.g. mirror, snapshot etc..). 234ff56536eSAlex Hornung 235ff56536eSAlex Hornung device-mapper physical devices -> pdevs dm_pdev.c 236ff56536eSAlex Hornung 237ff56536eSAlex Hornung This structure contains opened device VNODES. Because I physical 238ff56536eSAlex Hornung device can be found in more than one table loaded to different 239ff56536eSAlex Hornung dm devices. When device is destroyed I decrement all reference 240ff56536eSAlex Hornung counters for all added pdevs (I remove pdevs with ref_cnt == 0). 241ff56536eSAlex Hornung 242ff56536eSAlex Hornung device-mapper tables -> table dm_table.c, dm_ioctl.c 243ff56536eSAlex Hornung 244ff56536eSAlex Hornung Table describe how is dm device made. What blocks are mapped with 245ff56536eSAlex Hornung what target. In our implementation every table contains pointer to 246ff56536eSAlex Hornung target specific config data. These config_data are allocated in 247*b7c11cdaSTomohiro Kusumi DM_TABLE_LOAD function with dm_target_init routine. Every table 248ff56536eSAlex Hornung contains pointer to used target. 249ff56536eSAlex Hornung 250ff56536eSAlex Hornung device-mapper targets -> target dm_target.c 251ff56536eSAlex Hornung 252ff56536eSAlex Hornung Target describes mapping of logical blocks to physical. It has 253ff56536eSAlex Hornung function pointers to function which does init, strategy, destroy, 254ff56536eSAlex Hornung upcall functions. 255ff56536eSAlex Hornung 256ff56536eSAlex Hornung P.S I want to thank reinod@ for great help and guidance :). 257ff56536eSAlex Hornung 258ff56536eSAlex Hornung 259ff56536eSAlex Hornung 260ff56536eSAlex Hornung Desing of new device-mapper ioctl interface 261ff56536eSAlex Hornung 262ff56536eSAlex Hornung Basic architecture of device-mapper -> libdevmapper ioctl interface is this. 263ff56536eSAlex Hornung Libdevmapper allocate buffer with size of data_size. At the start of this buffer 264ff56536eSAlex Hornung dm-ioctl structure is placed. any aditional information from/to kernel are placed 265ff56536eSAlex Hornung behind end (start of data part is pointed with data_start var.) of dm-ioctl struct. 266ff56536eSAlex Hornung 267ff56536eSAlex Hornung Kernel driver then after ioctl call have to copyin data from userspace to kernel. 268ff56536eSAlex Hornung When kernel driver want to send data back to user space library it must copyout 269ff56536eSAlex Hornung data from kernel. 270ff56536eSAlex Hornung 271ff56536eSAlex Hornung1) In Linux device-mapper ioctl interface implementation there are these ioctls. 272ff56536eSAlex Hornung 273ff56536eSAlex Hornung DM_VERSION * 274ff56536eSAlex Hornung DM_REMOVE_ALL 275ff56536eSAlex Hornung DM_LIST_DEVICES * 276ff56536eSAlex Hornung DM_DEV_CREATE * 277ff56536eSAlex Hornung DM_DEV_REMOVE * 278ff56536eSAlex Hornung DM_DEV_RENAME * 279ff56536eSAlex Hornung DM_DEV_SUSPEND 280ff56536eSAlex Hornung DM_DEV_STATUS * 281ff56536eSAlex Hornung DM_DEV_WAIT 282ff56536eSAlex Hornung DM_TABLE_LOAD * 283ff56536eSAlex Hornung DM_TABLE_CLEAR * 284ff56536eSAlex Hornung DM_TABLE_DEPS 285ff56536eSAlex Hornung DM_TABLE_STATUS * 286ff56536eSAlex Hornung DM_LIST_VERSIONS * 287ff56536eSAlex Hornung DM_TARGET_MSG 288ff56536eSAlex Hornung DM_DEV_SET_GEOMETRY 289ff56536eSAlex Hornung 290ff56536eSAlex Hornung* means implemented in current version of NetBSD device-mapper. 291ff56536eSAlex Hornung 292ff56536eSAlex Hornung 1a) struct dm_ioctl based ioctl calls 293ff56536eSAlex Hornung These ioctl calls communicate only with basic dm_ioctl structure. 294ff56536eSAlex Hornung 295ff56536eSAlex Hornung DM_VERSION 296ff56536eSAlex Hornung DM_DEV_STATUS 297ff56536eSAlex Hornung DM_DEV_CREATE 298ff56536eSAlex Hornung 299ff56536eSAlex Hornung Protocol structure: 300ff56536eSAlex Hornung 301ff56536eSAlex Hornung struct dm_ioctl { 302ff56536eSAlex Hornung uint32_t version[3]; /* device-mapper kernel/userspace version */ 303ff56536eSAlex Hornung uint32_t data_size; /* total size of data passed in 304ff56536eSAlex Hornung * including this struct */ 305ff56536eSAlex Hornung 306ff56536eSAlex Hornung uint32_t data_start; /* offset to start of data 307ff56536eSAlex Hornung * relative to start of this struct */ 308ff56536eSAlex Hornung 309ff56536eSAlex Hornung uint32_t target_count; /* in/out */ /* This should be set when DM_TABLE_STATUS is called */ 310ff56536eSAlex Hornung int32_t open_count; /* device open count */ 311ff56536eSAlex Hornung uint32_t flags; /* information flags */ 312ff56536eSAlex Hornung uint32_t event_nr; /* event counters not implemented */ 313ff56536eSAlex Hornung uint32_t padding; 314ff56536eSAlex Hornung 315ff56536eSAlex Hornung uint64_t dev; /* dev_t */ 316ff56536eSAlex Hornung 317ff56536eSAlex Hornung char name[DM_NAME_LEN]; /* device name */ 318ff56536eSAlex Hornung char uuid[DM_UUID_LEN]; /* unique identifier for 319ff56536eSAlex Hornung * the block device */ 320ff56536eSAlex Hornung 321ff56536eSAlex Hornung void *user_space_addr; /*this is needed for netbsd 322ff56536eSAlex Hornung because they differently 323ff56536eSAlex Hornung implement ioctl syscall*/ 324ff56536eSAlex Hornung }; 325ff56536eSAlex Hornung 326ff56536eSAlex Hornung As SOC task I want to replace this structure with proplib dict. Proplib dict 327ff56536eSAlex Hornung basic structure should be: 328ff56536eSAlex Hornung 329ff56536eSAlex Hornung Note: I don't need data_star, data_size and use_space_addr. They are needed 330ff56536eSAlex Hornung for current implementation. 331ff56536eSAlex Hornung 332ff56536eSAlex Hornung <dict> 333ff56536eSAlex Hornung <key>version</key> 334ff56536eSAlex Hornung <string>...</string> 335ff56536eSAlex Hornung 336ff56536eSAlex Hornung <key>target_count</key> 337ff56536eSAlex Hornung <integer></integer> 338ff56536eSAlex Hornung 339ff56536eSAlex Hornung <key>open_count</key> 340ff56536eSAlex Hornung <integer></integer> 341ff56536eSAlex Hornung 342ff56536eSAlex Hornung <key>flags</key> 343ff56536eSAlex Hornung <integer></integer> 344ff56536eSAlex Hornung 345ff56536eSAlex Hornung <key>event_nr</key> 346ff56536eSAlex Hornung <integer></integer> 347ff56536eSAlex Hornung 348ff56536eSAlex Hornung <key>dev</key> 349ff56536eSAlex Hornung <integer></integer> 350ff56536eSAlex Hornung 351ff56536eSAlex Hornung <key>name</key> 352ff56536eSAlex Hornung <string>...</string> 353ff56536eSAlex Hornung 354ff56536eSAlex Hornung <key>uuid</key> 355ff56536eSAlex Hornung <string>...</string> 356ff56536eSAlex Hornung 357ff56536eSAlex Hornung 358ff56536eSAlex Hornung <dict> 359ff56536eSAlex Hornung <!-- ioctl specific data --> 360ff56536eSAlex Hornung </dict> 361ff56536eSAlex Hornung </dict> 362ff56536eSAlex Hornung 363ff56536eSAlex Hornung 1b) DM_LIST_VERSIONS ioctl 364ff56536eSAlex Hornung 365ff56536eSAlex Hornung This ioctl is used to get list of supported targets from kernel. Target 366ff56536eSAlex Hornung define mapping of Logical blocks to physical blocks on real device. 367ff56536eSAlex Hornung There are linear, zero, error, mirror, snapshot, multipath etc... targets. 368ff56536eSAlex Hornung 369ff56536eSAlex Hornung For every target kernel driver should copyout this structure to userspace. 370ff56536eSAlex Hornung 371ff56536eSAlex Hornung Protocol structure: 372ff56536eSAlex Hornung 373ff56536eSAlex Hornung struct dm_target_versions { 374ff56536eSAlex Hornung uint32_t next; 375ff56536eSAlex Hornung uint32_t version[3]; 376ff56536eSAlex Hornung 377ff56536eSAlex Hornung char name[0]; 378ff56536eSAlex Hornung }; 379ff56536eSAlex Hornung 380ff56536eSAlex Hornung Because I need more then on dm_target_version I will need one major proplib 381ff56536eSAlex Hornung dictionary to store children dictionaries with target data. 382ff56536eSAlex Hornung 383ff56536eSAlex Hornung <dict> 384ff56536eSAlex Hornung <dict ID="id"> 385ff56536eSAlex Hornung <key>version</key> 386ff56536eSAlex Hornung <string>...</string> 387ff56536eSAlex Hornung 388ff56536eSAlex Hornung <key>name</key> 389ff56536eSAlex Hornung <string>...</string> 390ff56536eSAlex Hornung </dict> 391ff56536eSAlex Hornung </dict> 392ff56536eSAlex Hornung 393ff56536eSAlex Hornung 2a) DM_LIST_DEVICES 394ff56536eSAlex Hornung 395ff56536eSAlex Hornung This ioctl is used to list all devices defined in kernel driver. 396ff56536eSAlex Hornung 397ff56536eSAlex Hornung Protocol structure: 398ff56536eSAlex Hornung 399ff56536eSAlex Hornung struct dm_name_list { 400ff56536eSAlex Hornung uint64_t dev; 401ff56536eSAlex Hornung uint32_t next; /* offset to the next record from 402ff56536eSAlex Hornung the _start_ of this */ 403ff56536eSAlex Hornung char name[0]; 404ff56536eSAlex Hornung }; 405ff56536eSAlex Hornung 406ff56536eSAlex Hornung Again because I can have more than one device in kernel driver I need one parent 407ff56536eSAlex Hornung dictionary and more children dictionaries. 408ff56536eSAlex Hornung 409ff56536eSAlex Hornung <dict> 410ff56536eSAlex Hornung <dict ID="id"> 411ff56536eSAlex Hornung <key>dev</key> 412ff56536eSAlex Hornung <integer>...</integer> 413ff56536eSAlex Hornung 414ff56536eSAlex Hornung <key>name</key> 415ff56536eSAlex Hornung <string>...</string> 416ff56536eSAlex Hornung </dict> 417ff56536eSAlex Hornung </dict> 418ff56536eSAlex Hornung 419ff56536eSAlex Hornung 2b) DM_DEV_RENAME 420ff56536eSAlex Hornung This ioctl is called when libdevmapper want to rename device-mapper device. 421ff56536eSAlex Hornung Libdevmapper library appends null terminated string to dm_ioctl struct in 422ff56536eSAlex Hornung userspace.. 423ff56536eSAlex Hornung 424ff56536eSAlex Hornung <dict> 425ff56536eSAlex Hornung <key>name</key> 426ff56536eSAlex Hornung <string>...</string> 427ff56536eSAlex Hornung </dict> 428ff56536eSAlex Hornung 429ff56536eSAlex Hornung 2c) DM_DEV_CREATE, DM_DEV_REMOVE, DM_DEV_STATUS 430ff56536eSAlex Hornung Modify only dm_ioctl structure so I don't need to specify new structures. 431ff56536eSAlex Hornung 432ff56536eSAlex Hornung 433ff56536eSAlex Hornung 3a) DM_TABLE_LOAD, DM_TABLE_STATUS 434ff56536eSAlex Hornung DM_TABLE_LOAD ioctl loads table to device. DM_TABLE_STATUS send info about 435ff56536eSAlex Hornung every table for selected device to userspace. Table is different for every 436ff56536eSAlex Hornung target basic table structure is this 437ff56536eSAlex Hornung 438ff56536eSAlex Hornung {start} {length} {target} {additional information} 439ff56536eSAlex Hornung 440ff56536eSAlex Hornung e.g. 441ff56536eSAlex Hornung 0 100 zero 442ff56536eSAlex Hornung 443ff56536eSAlex Hornung 0 100 linear /dev/wdba 384 444ff56536eSAlex Hornung 445ff56536eSAlex Hornung Protocol structure: 446ff56536eSAlex Hornung 447ff56536eSAlex Hornung struct dm_target_spec { 448ff56536eSAlex Hornung uint64_t sector_start; 449ff56536eSAlex Hornung uint64_t length; 450ff56536eSAlex Hornung int32_t status; /* used when reading from kernel only */ 451ff56536eSAlex Hornung 452ff56536eSAlex Hornung uint32_t next; 453ff56536eSAlex Hornung 454ff56536eSAlex Hornung char target_type[DM_MAX_TYPE_NAME]; 455ff56536eSAlex Hornung 456ff56536eSAlex Hornung /* 457ff56536eSAlex Hornung * Parameter string starts immediately after this object. 458ff56536eSAlex Hornung * Be careful to add padding after string to ensure correct 459ff56536eSAlex Hornung * alignment of subsequent dm_target_spec. 460ff56536eSAlex Hornung */ 461ff56536eSAlex Hornung }; 462ff56536eSAlex Hornung 463ff56536eSAlex Hornung <dict> 464ff56536eSAlex Hornung <key>sector_start</key> 465ff56536eSAlex Hornung <integer>...</integer> 466ff56536eSAlex Hornung 467ff56536eSAlex Hornung <key>length</key> 468ff56536eSAlex Hornung <integer>...</integer> 469ff56536eSAlex Hornung 470ff56536eSAlex Hornung <key>target_type</key> 471ff56536eSAlex Hornung <string>...</string> 472ff56536eSAlex Hornung 473ff56536eSAlex Hornung <key>aditional info</key> 474ff56536eSAlex Hornung <string>...</string> 475ff56536eSAlex Hornung </dict> 476