Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
0004  * Copyright (C) 2004 - 2009 Red Hat, Inc. All rights reserved.
0005  *
0006  * This file is released under the LGPL.
0007  */
0008 
0009 #ifndef _LINUX_DM_IOCTL_V4_H
0010 #define _LINUX_DM_IOCTL_V4_H
0011 
0012 #include <linux/types.h>
0013 
0014 #define DM_DIR "mapper"     /* Slashes not supported */
0015 #define DM_CONTROL_NODE "control"
0016 #define DM_MAX_TYPE_NAME 16
0017 #define DM_NAME_LEN 128
0018 #define DM_UUID_LEN 129
0019 
0020 /*
0021  * A traditional ioctl interface for the device mapper.
0022  *
0023  * Each device can have two tables associated with it, an
0024  * 'active' table which is the one currently used by io passing
0025  * through the device, and an 'inactive' one which is a table
0026  * that is being prepared as a replacement for the 'active' one.
0027  *
0028  * DM_VERSION:
0029  * Just get the version information for the ioctl interface.
0030  *
0031  * DM_REMOVE_ALL:
0032  * Remove all dm devices, destroy all tables.  Only really used
0033  * for debug.
0034  *
0035  * DM_LIST_DEVICES:
0036  * Get a list of all the dm device names.
0037  *
0038  * DM_DEV_CREATE:
0039  * Create a new device, neither the 'active' or 'inactive' table
0040  * slots will be filled.  The device will be in suspended state
0041  * after creation, however any io to the device will get errored
0042  * since it will be out-of-bounds.
0043  *
0044  * DM_DEV_REMOVE:
0045  * Remove a device, destroy any tables.
0046  *
0047  * DM_DEV_RENAME:
0048  * Rename a device or set its uuid if none was previously supplied.
0049  *
0050  * DM_SUSPEND:
0051  * This performs both suspend and resume, depending which flag is
0052  * passed in.
0053  * Suspend: This command will not return until all pending io to
0054  * the device has completed.  Further io will be deferred until
0055  * the device is resumed.
0056  * Resume: It is no longer an error to issue this command on an
0057  * unsuspended device.  If a table is present in the 'inactive'
0058  * slot, it will be moved to the active slot, then the old table
0059  * from the active slot will be _destroyed_.  Finally the device
0060  * is resumed.
0061  *
0062  * DM_DEV_STATUS:
0063  * Retrieves the status for the table in the 'active' slot.
0064  *
0065  * DM_DEV_WAIT:
0066  * Wait for a significant event to occur to the device.  This
0067  * could either be caused by an event triggered by one of the
0068  * targets of the table in the 'active' slot, or a table change.
0069  *
0070  * DM_TABLE_LOAD:
0071  * Load a table into the 'inactive' slot for the device.  The
0072  * device does _not_ need to be suspended prior to this command.
0073  *
0074  * DM_TABLE_CLEAR:
0075  * Destroy any table in the 'inactive' slot (ie. abort).
0076  *
0077  * DM_TABLE_DEPS:
0078  * Return a set of device dependencies for the 'active' table.
0079  *
0080  * DM_TABLE_STATUS:
0081  * Return the targets status for the 'active' table.
0082  *
0083  * DM_TARGET_MSG:
0084  * Pass a message string to the target at a specific offset of a device.
0085  *
0086  * DM_DEV_SET_GEOMETRY:
0087  * Set the geometry of a device by passing in a string in this format:
0088  *
0089  * "cylinders heads sectors_per_track start_sector"
0090  *
0091  * Beware that CHS geometry is nearly obsolete and only provided
0092  * for compatibility with dm devices that can be booted by a PC
0093  * BIOS.  See struct hd_geometry for range limits.  Also note that
0094  * the geometry is erased if the device size changes.
0095  */
0096 
0097 /*
0098  * All ioctl arguments consist of a single chunk of memory, with
0099  * this structure at the start.  If a uuid is specified any
0100  * lookup (eg. for a DM_INFO) will be done on that, *not* the
0101  * name.
0102  */
0103 struct dm_ioctl {
0104     /*
0105      * The version number is made up of three parts:
0106      * major - no backward or forward compatibility,
0107      * minor - only backwards compatible,
0108      * patch - both backwards and forwards compatible.
0109      *
0110      * All clients of the ioctl interface should fill in the
0111      * version number of the interface that they were
0112      * compiled with.
0113      *
0114      * All recognised ioctl commands (ie. those that don't
0115      * return -ENOTTY) fill out this field, even if the
0116      * command failed.
0117      */
0118     __u32 version[3];   /* in/out */
0119     __u32 data_size;    /* total size of data passed in
0120                  * including this struct */
0121 
0122     __u32 data_start;   /* offset to start of data
0123                  * relative to start of this struct */
0124 
0125     __u32 target_count; /* in/out */
0126     __s32 open_count;   /* out */
0127     __u32 flags;        /* in/out */
0128 
0129     /*
0130      * event_nr holds either the event number (input and output) or the
0131      * udev cookie value (input only).
0132      * The DM_DEV_WAIT ioctl takes an event number as input.
0133      * The DM_SUSPEND, DM_DEV_REMOVE and DM_DEV_RENAME ioctls
0134      * use the field as a cookie to return in the DM_COOKIE
0135      * variable with the uevents they issue.
0136      * For output, the ioctls return the event number, not the cookie.
0137      */
0138     __u32 event_nr;         /* in/out */
0139     __u32 padding;
0140 
0141     __u64 dev;      /* in/out */
0142 
0143     char name[DM_NAME_LEN]; /* device name */
0144     char uuid[DM_UUID_LEN]; /* unique identifier for
0145                  * the block device */
0146     char data[7];       /* padding or data */
0147 };
0148 
0149 /*
0150  * Used to specify tables.  These structures appear after the
0151  * dm_ioctl.
0152  */
0153 struct dm_target_spec {
0154     __u64 sector_start;
0155     __u64 length;
0156     __s32 status;       /* used when reading from kernel only */
0157 
0158     /*
0159      * Location of the next dm_target_spec.
0160      * - When specifying targets on a DM_TABLE_LOAD command, this value is
0161      *   the number of bytes from the start of the "current" dm_target_spec
0162      *   to the start of the "next" dm_target_spec.
0163      * - When retrieving targets on a DM_TABLE_STATUS command, this value
0164      *   is the number of bytes from the start of the first dm_target_spec
0165      *   (that follows the dm_ioctl struct) to the start of the "next"
0166      *   dm_target_spec.
0167      */
0168     __u32 next;
0169 
0170     char target_type[DM_MAX_TYPE_NAME];
0171 
0172     /*
0173      * Parameter string starts immediately after this object.
0174      * Be careful to add padding after string to ensure correct
0175      * alignment of subsequent dm_target_spec.
0176      */
0177 };
0178 
0179 /*
0180  * Used to retrieve the target dependencies.
0181  */
0182 struct dm_target_deps {
0183     __u32 count;    /* Array size */
0184     __u32 padding;  /* unused */
0185     __u64 dev[];    /* out */
0186 };
0187 
0188 /*
0189  * Used to get a list of all dm devices.
0190  */
0191 struct dm_name_list {
0192     __u64 dev;
0193     __u32 next;     /* offset to the next record from
0194                    the _start_ of this */
0195     char name[];
0196 
0197     /*
0198      * The following members can be accessed by taking a pointer that
0199      * points immediately after the terminating zero character in "name"
0200      * and aligning this pointer to next 8-byte boundary.
0201      * Uuid is present if the flag DM_NAME_LIST_FLAG_HAS_UUID is set.
0202      *
0203      * __u32 event_nr;
0204      * __u32 flags;
0205      * char uuid[0];
0206      */
0207 };
0208 
0209 #define DM_NAME_LIST_FLAG_HAS_UUID      1
0210 #define DM_NAME_LIST_FLAG_DOESNT_HAVE_UUID  2
0211 
0212 /*
0213  * Used to retrieve the target versions
0214  */
0215 struct dm_target_versions {
0216         __u32 next;
0217         __u32 version[3];
0218 
0219         char name[];
0220 };
0221 
0222 /*
0223  * Used to pass message to a target
0224  */
0225 struct dm_target_msg {
0226     __u64 sector;   /* Device sector */
0227 
0228     char message[];
0229 };
0230 
0231 /*
0232  * If you change this make sure you make the corresponding change
0233  * to dm-ioctl.c:lookup_ioctl()
0234  */
0235 enum {
0236     /* Top level cmds */
0237     DM_VERSION_CMD = 0,
0238     DM_REMOVE_ALL_CMD,
0239     DM_LIST_DEVICES_CMD,
0240 
0241     /* device level cmds */
0242     DM_DEV_CREATE_CMD,
0243     DM_DEV_REMOVE_CMD,
0244     DM_DEV_RENAME_CMD,
0245     DM_DEV_SUSPEND_CMD,
0246     DM_DEV_STATUS_CMD,
0247     DM_DEV_WAIT_CMD,
0248 
0249     /* Table level cmds */
0250     DM_TABLE_LOAD_CMD,
0251     DM_TABLE_CLEAR_CMD,
0252     DM_TABLE_DEPS_CMD,
0253     DM_TABLE_STATUS_CMD,
0254 
0255     /* Added later */
0256     DM_LIST_VERSIONS_CMD,
0257     DM_TARGET_MSG_CMD,
0258     DM_DEV_SET_GEOMETRY_CMD,
0259     DM_DEV_ARM_POLL_CMD,
0260     DM_GET_TARGET_VERSION_CMD,
0261 };
0262 
0263 #define DM_IOCTL 0xfd
0264 
0265 #define DM_VERSION       _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
0266 #define DM_REMOVE_ALL    _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
0267 #define DM_LIST_DEVICES  _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
0268 
0269 #define DM_DEV_CREATE    _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
0270 #define DM_DEV_REMOVE    _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
0271 #define DM_DEV_RENAME    _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
0272 #define DM_DEV_SUSPEND   _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
0273 #define DM_DEV_STATUS    _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
0274 #define DM_DEV_WAIT      _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
0275 #define DM_DEV_ARM_POLL  _IOWR(DM_IOCTL, DM_DEV_ARM_POLL_CMD, struct dm_ioctl)
0276 
0277 #define DM_TABLE_LOAD    _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
0278 #define DM_TABLE_CLEAR   _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
0279 #define DM_TABLE_DEPS    _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
0280 #define DM_TABLE_STATUS  _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
0281 
0282 #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
0283 #define DM_GET_TARGET_VERSION _IOWR(DM_IOCTL, DM_GET_TARGET_VERSION_CMD, struct dm_ioctl)
0284 
0285 #define DM_TARGET_MSG    _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
0286 #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
0287 
0288 #define DM_VERSION_MAJOR    4
0289 #define DM_VERSION_MINOR    47
0290 #define DM_VERSION_PATCHLEVEL   0
0291 #define DM_VERSION_EXTRA    "-ioctl (2022-07-28)"
0292 
0293 /* Status bits */
0294 #define DM_READONLY_FLAG    (1 << 0) /* In/Out */
0295 #define DM_SUSPEND_FLAG     (1 << 1) /* In/Out */
0296 #define DM_PERSISTENT_DEV_FLAG  (1 << 3) /* In */
0297 
0298 /*
0299  * Flag passed into ioctl STATUS command to get table information
0300  * rather than current status.
0301  */
0302 #define DM_STATUS_TABLE_FLAG    (1 << 4) /* In */
0303 
0304 /*
0305  * Flags that indicate whether a table is present in either of
0306  * the two table slots that a device has.
0307  */
0308 #define DM_ACTIVE_PRESENT_FLAG   (1 << 5) /* Out */
0309 #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
0310 
0311 /*
0312  * Indicates that the buffer passed in wasn't big enough for the
0313  * results.
0314  */
0315 #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
0316 
0317 /*
0318  * This flag is now ignored.
0319  */
0320 #define DM_SKIP_BDGET_FLAG  (1 << 9) /* In */
0321 
0322 /*
0323  * Set this to avoid attempting to freeze any filesystem when suspending.
0324  */
0325 #define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */
0326 
0327 /*
0328  * Set this to suspend without flushing queued ios.
0329  * Also disables flushing uncommitted changes in the thin target before
0330  * generating statistics for DM_TABLE_STATUS and DM_DEV_WAIT.
0331  */
0332 #define DM_NOFLUSH_FLAG     (1 << 11) /* In */
0333 
0334 /*
0335  * If set, any table information returned will relate to the inactive
0336  * table instead of the live one.  Always check DM_INACTIVE_PRESENT_FLAG
0337  * is set before using the data returned.
0338  */
0339 #define DM_QUERY_INACTIVE_TABLE_FLAG    (1 << 12) /* In */
0340 
0341 /*
0342  * If set, a uevent was generated for which the caller may need to wait.
0343  */
0344 #define DM_UEVENT_GENERATED_FLAG    (1 << 13) /* Out */
0345 
0346 /*
0347  * If set, rename changes the uuid not the name.  Only permitted
0348  * if no uuid was previously supplied: an existing uuid cannot be changed.
0349  */
0350 #define DM_UUID_FLAG            (1 << 14) /* In */
0351 
0352 /*
0353  * If set, all buffers are wiped after use. Use when sending
0354  * or requesting sensitive data such as an encryption key.
0355  */
0356 #define DM_SECURE_DATA_FLAG     (1 << 15) /* In */
0357 
0358 /*
0359  * If set, a message generated output data.
0360  */
0361 #define DM_DATA_OUT_FLAG        (1 << 16) /* Out */
0362 
0363 /*
0364  * If set with DM_DEV_REMOVE or DM_REMOVE_ALL this indicates that if
0365  * the device cannot be removed immediately because it is still in use
0366  * it should instead be scheduled for removal when it gets closed.
0367  *
0368  * On return from DM_DEV_REMOVE, DM_DEV_STATUS or other ioctls, this
0369  * flag indicates that the device is scheduled to be removed when it
0370  * gets closed.
0371  */
0372 #define DM_DEFERRED_REMOVE      (1 << 17) /* In/Out */
0373 
0374 /*
0375  * If set, the device is suspended internally.
0376  */
0377 #define DM_INTERNAL_SUSPEND_FLAG    (1 << 18) /* Out */
0378 
0379 /*
0380  * If set, returns in the in buffer passed by UM, the raw table information
0381  * that would be measured by IMA subsystem on device state change.
0382  */
0383 #define DM_IMA_MEASUREMENT_FLAG (1 << 19) /* In */
0384 
0385 #endif              /* _LINUX_DM_IOCTL_H */