blob: f623a2b110d77118ab96806211c36c5c01930810 [file] [log] [blame]
Jiyong Park86c9b082021-06-04 19:03:48 +09001/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use bitflags::bitflags;
18
19// UAPI for device mapper can be found at include/uapi/linux/dm-ioctl.h
20
21pub const DM_IOCTL: u8 = 0xfd;
22
23#[repr(u16)]
24#[allow(non_camel_case_types)]
25#[allow(dead_code)]
26pub enum Cmd {
27 DM_VERSION = 0,
28 DM_REMOVE_ALL,
29 DM_LIST_DEVICES,
30 DM_DEV_CREATE,
31 DM_DEV_REMOVE,
32 DM_DEV_RENAME,
33 DM_DEV_SUSPEND,
34 DM_DEV_STATUS,
35 DM_DEV_WAIT,
36 DM_TABLE_LOAD,
37 DM_TABLE_CLEAR,
38 DM_TABLE_DEPS,
39 DM_TABLE_STATUS,
40 DM_LIST_VERSIONS,
41 DM_TARGET_MSG,
42 DM_DEV_SET_GEOMETRY,
43}
44
45#[repr(C)]
46pub struct DmIoctl {
47 pub version: [u32; 3],
48 pub data_size: u32,
49 pub data_start: u32,
50 pub target_count: u32,
51 pub open_count: i32,
52 pub flags: Flag,
53 pub event_nr: u32,
54 pub padding: u32,
55 pub dev: u64,
56 pub name: [u8; DM_NAME_LEN],
57 pub uuid: [u8; DM_UUID_LEN],
58 pub data: [u8; 7],
59}
60
61pub const DM_VERSION_MAJOR: u32 = 4;
62pub const DM_VERSION_MINOR: u32 = 0;
63pub const DM_VERSION_PATCHLEVEL: u32 = 0;
64
65pub const DM_NAME_LEN: usize = 128;
66pub const DM_UUID_LEN: usize = 129;
67pub const DM_MAX_TYPE_NAME: usize = 16;
68
69bitflags! {
70 pub struct Flag: u32 {
71 const DM_READONLY_FLAG = 1 << 0;
72 const DM_SUSPEND_FLAG = 1 << 1;
73 const DM_PERSISTENT_DEV_FLAG = 1 << 3;
74 const DM_STATUS_TABLE_FLAG = 1 << 4;
75 const DM_ACTIVE_PRESENT_FLAG = 1 << 5;
76 const DM_INACTIVE_PRESENT_FLAG = 1 << 6;
77 const DM_BUFFER_FULL_FLAG = 1 << 8;
78 const DM_SKIP_BDGET_FLAG = 1 << 9;
79 const DM_SKIP_LOCKFS_FLAG = 1 << 10;
80 const DM_NOFLUSH_FLAG = 1 << 11;
81 const DM_QUERY_INACTIVE_TABLE_FLAG = 1 << 12;
82 const DM_UEVENT_GENERATED_FLAG = 1 << 13;
83 const DM_UUID_FLAG = 1 << 14;
84 const DM_SECURE_DATA_FLAG = 1 << 15;
85 const DM_DATA_OUT_FLAG = 1 << 16;
86 const DM_DEFERRED_REMOVE = 1 << 17;
87 const DM_INTERNAL_SUSPEND_FLAG = 1 << 18;
88 }
89}