1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3*c23d47abSChristoph Hellwig * Copyright 1993 by Theodore Ts'o. 4607ca46eSDavid Howells */ 5607ca46eSDavid Howells #ifndef _UAPI_LINUX_LOOP_H 6607ca46eSDavid Howells #define _UAPI_LINUX_LOOP_H 7607ca46eSDavid Howells 8607ca46eSDavid Howells 9607ca46eSDavid Howells #define LO_NAME_SIZE 64 10607ca46eSDavid Howells #define LO_KEY_SIZE 32 11607ca46eSDavid Howells 12607ca46eSDavid Howells 13607ca46eSDavid Howells /* 14607ca46eSDavid Howells * Loop flags 15607ca46eSDavid Howells */ 16607ca46eSDavid Howells enum { 17607ca46eSDavid Howells LO_FLAGS_READ_ONLY = 1, 18607ca46eSDavid Howells LO_FLAGS_AUTOCLEAR = 4, 19607ca46eSDavid Howells LO_FLAGS_PARTSCAN = 8, 202e5ab5f3SMing Lei LO_FLAGS_DIRECT_IO = 16, 21607ca46eSDavid Howells }; 22607ca46eSDavid Howells 23faf1d254SMartijn Coenen /* LO_FLAGS that can be set using LOOP_SET_STATUS(64) */ 24faf1d254SMartijn Coenen #define LOOP_SET_STATUS_SETTABLE_FLAGS (LO_FLAGS_AUTOCLEAR | LO_FLAGS_PARTSCAN) 25faf1d254SMartijn Coenen 26faf1d254SMartijn Coenen /* LO_FLAGS that can be cleared using LOOP_SET_STATUS(64) */ 27faf1d254SMartijn Coenen #define LOOP_SET_STATUS_CLEARABLE_FLAGS (LO_FLAGS_AUTOCLEAR) 28faf1d254SMartijn Coenen 293448914eSMartijn Coenen /* LO_FLAGS that can be set using LOOP_CONFIGURE */ 303448914eSMartijn Coenen #define LOOP_CONFIGURE_SETTABLE_FLAGS (LO_FLAGS_READ_ONLY | LO_FLAGS_AUTOCLEAR \ 313448914eSMartijn Coenen | LO_FLAGS_PARTSCAN | LO_FLAGS_DIRECT_IO) 323448914eSMartijn Coenen 33607ca46eSDavid Howells #include <asm/posix_types.h> /* for __kernel_old_dev_t */ 34607ca46eSDavid Howells #include <linux/types.h> /* for __u64 */ 35607ca46eSDavid Howells 36607ca46eSDavid Howells /* Backwards compatibility version */ 37607ca46eSDavid Howells struct loop_info { 38607ca46eSDavid Howells int lo_number; /* ioctl r/o */ 39607ca46eSDavid Howells __kernel_old_dev_t lo_device; /* ioctl r/o */ 40607ca46eSDavid Howells unsigned long lo_inode; /* ioctl r/o */ 41607ca46eSDavid Howells __kernel_old_dev_t lo_rdevice; /* ioctl r/o */ 42607ca46eSDavid Howells int lo_offset; 43f941c51eSCarlos Llamas int lo_encrypt_type; /* obsolete, ignored */ 44607ca46eSDavid Howells int lo_encrypt_key_size; /* ioctl w/o */ 45faf1d254SMartijn Coenen int lo_flags; 46607ca46eSDavid Howells char lo_name[LO_NAME_SIZE]; 47607ca46eSDavid Howells unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ 48607ca46eSDavid Howells unsigned long lo_init[2]; 49607ca46eSDavid Howells char reserved[4]; 50607ca46eSDavid Howells }; 51607ca46eSDavid Howells 52607ca46eSDavid Howells struct loop_info64 { 53607ca46eSDavid Howells __u64 lo_device; /* ioctl r/o */ 54607ca46eSDavid Howells __u64 lo_inode; /* ioctl r/o */ 55607ca46eSDavid Howells __u64 lo_rdevice; /* ioctl r/o */ 56607ca46eSDavid Howells __u64 lo_offset; 57607ca46eSDavid Howells __u64 lo_sizelimit;/* bytes, 0 == max available */ 58607ca46eSDavid Howells __u32 lo_number; /* ioctl r/o */ 59f941c51eSCarlos Llamas __u32 lo_encrypt_type; /* obsolete, ignored */ 60607ca46eSDavid Howells __u32 lo_encrypt_key_size; /* ioctl w/o */ 61faf1d254SMartijn Coenen __u32 lo_flags; 62607ca46eSDavid Howells __u8 lo_file_name[LO_NAME_SIZE]; 63607ca46eSDavid Howells __u8 lo_crypt_name[LO_NAME_SIZE]; 64607ca46eSDavid Howells __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ 65607ca46eSDavid Howells __u64 lo_init[2]; 66607ca46eSDavid Howells }; 67607ca46eSDavid Howells 683448914eSMartijn Coenen /** 693448914eSMartijn Coenen * struct loop_config - Complete configuration for a loop device. 703448914eSMartijn Coenen * @fd: fd of the file to be used as a backing file for the loop device. 713448914eSMartijn Coenen * @block_size: block size to use; ignored if 0. 723448914eSMartijn Coenen * @info: struct loop_info64 to configure the loop device with. 733448914eSMartijn Coenen * 743448914eSMartijn Coenen * This structure is used with the LOOP_CONFIGURE ioctl, and can be used to 753448914eSMartijn Coenen * atomically setup and configure all loop device parameters at once. 763448914eSMartijn Coenen */ 773448914eSMartijn Coenen struct loop_config { 783448914eSMartijn Coenen __u32 fd; 793448914eSMartijn Coenen __u32 block_size; 803448914eSMartijn Coenen struct loop_info64 info; 813448914eSMartijn Coenen __u64 __reserved[8]; 823448914eSMartijn Coenen }; 833448914eSMartijn Coenen 84607ca46eSDavid Howells /* 85607ca46eSDavid Howells * Loop filter types 86607ca46eSDavid Howells */ 87607ca46eSDavid Howells 88607ca46eSDavid Howells #define LO_CRYPT_NONE 0 89607ca46eSDavid Howells #define LO_CRYPT_XOR 1 90607ca46eSDavid Howells #define LO_CRYPT_DES 2 91607ca46eSDavid Howells #define LO_CRYPT_FISH2 3 /* Twofish encryption */ 92607ca46eSDavid Howells #define LO_CRYPT_BLOW 4 93607ca46eSDavid Howells #define LO_CRYPT_CAST128 5 94607ca46eSDavid Howells #define LO_CRYPT_IDEA 6 95607ca46eSDavid Howells #define LO_CRYPT_DUMMY 9 96607ca46eSDavid Howells #define LO_CRYPT_SKIPJACK 10 97607ca46eSDavid Howells #define LO_CRYPT_CRYPTOAPI 18 98607ca46eSDavid Howells #define MAX_LO_CRYPT 20 99607ca46eSDavid Howells 100607ca46eSDavid Howells /* 101607ca46eSDavid Howells * IOCTL commands --- we will commandeer 0x4C ('L') 102607ca46eSDavid Howells */ 103607ca46eSDavid Howells 104607ca46eSDavid Howells #define LOOP_SET_FD 0x4C00 105607ca46eSDavid Howells #define LOOP_CLR_FD 0x4C01 106607ca46eSDavid Howells #define LOOP_SET_STATUS 0x4C02 107607ca46eSDavid Howells #define LOOP_GET_STATUS 0x4C03 108607ca46eSDavid Howells #define LOOP_SET_STATUS64 0x4C04 109607ca46eSDavid Howells #define LOOP_GET_STATUS64 0x4C05 110607ca46eSDavid Howells #define LOOP_CHANGE_FD 0x4C06 111607ca46eSDavid Howells #define LOOP_SET_CAPACITY 0x4C07 112ab1cb278SMing Lei #define LOOP_SET_DIRECT_IO 0x4C08 11389e4fdecSOmar Sandoval #define LOOP_SET_BLOCK_SIZE 0x4C09 1143448914eSMartijn Coenen #define LOOP_CONFIGURE 0x4C0A 115607ca46eSDavid Howells 116607ca46eSDavid Howells /* /dev/loop-control interface */ 117607ca46eSDavid Howells #define LOOP_CTL_ADD 0x4C80 118607ca46eSDavid Howells #define LOOP_CTL_REMOVE 0x4C81 119607ca46eSDavid Howells #define LOOP_CTL_GET_FREE 0x4C82 120607ca46eSDavid Howells #endif /* _UAPI_LINUX_LOOP_H */ 121