Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
0002 /*
0003  * Copyright 1993 by Theodore Ts'o.
0004  */
0005 #ifndef _UAPI_LINUX_LOOP_H
0006 #define _UAPI_LINUX_LOOP_H
0007 
0008 
0009 #define LO_NAME_SIZE    64
0010 #define LO_KEY_SIZE 32
0011 
0012 
0013 /*
0014  * Loop flags
0015  */
0016 enum {
0017     LO_FLAGS_READ_ONLY  = 1,
0018     LO_FLAGS_AUTOCLEAR  = 4,
0019     LO_FLAGS_PARTSCAN   = 8,
0020     LO_FLAGS_DIRECT_IO  = 16,
0021 };
0022 
0023 /* LO_FLAGS that can be set using LOOP_SET_STATUS(64) */
0024 #define LOOP_SET_STATUS_SETTABLE_FLAGS (LO_FLAGS_AUTOCLEAR | LO_FLAGS_PARTSCAN)
0025 
0026 /* LO_FLAGS that can be cleared using LOOP_SET_STATUS(64) */
0027 #define LOOP_SET_STATUS_CLEARABLE_FLAGS (LO_FLAGS_AUTOCLEAR)
0028 
0029 /* LO_FLAGS that can be set using LOOP_CONFIGURE */
0030 #define LOOP_CONFIGURE_SETTABLE_FLAGS (LO_FLAGS_READ_ONLY | LO_FLAGS_AUTOCLEAR \
0031                        | LO_FLAGS_PARTSCAN | LO_FLAGS_DIRECT_IO)
0032 
0033 #include <asm/posix_types.h>    /* for __kernel_old_dev_t */
0034 #include <linux/types.h>    /* for __u64 */
0035 
0036 /* Backwards compatibility version */
0037 struct loop_info {
0038     int        lo_number;       /* ioctl r/o */
0039     __kernel_old_dev_t lo_device;       /* ioctl r/o */
0040     unsigned long      lo_inode;        /* ioctl r/o */
0041     __kernel_old_dev_t lo_rdevice;      /* ioctl r/o */
0042     int        lo_offset;
0043     int        lo_encrypt_type;     /* obsolete, ignored */
0044     int        lo_encrypt_key_size;     /* ioctl w/o */
0045     int        lo_flags;
0046     char           lo_name[LO_NAME_SIZE];
0047     unsigned char      lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
0048     unsigned long      lo_init[2];
0049     char           reserved[4];
0050 };
0051 
0052 struct loop_info64 {
0053     __u64          lo_device;           /* ioctl r/o */
0054     __u64          lo_inode;            /* ioctl r/o */
0055     __u64          lo_rdevice;          /* ioctl r/o */
0056     __u64          lo_offset;
0057     __u64          lo_sizelimit;/* bytes, 0 == max available */
0058     __u32          lo_number;           /* ioctl r/o */
0059     __u32          lo_encrypt_type;     /* obsolete, ignored */
0060     __u32          lo_encrypt_key_size;     /* ioctl w/o */
0061     __u32          lo_flags;
0062     __u8           lo_file_name[LO_NAME_SIZE];
0063     __u8           lo_crypt_name[LO_NAME_SIZE];
0064     __u8           lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
0065     __u64          lo_init[2];
0066 };
0067 
0068 /**
0069  * struct loop_config - Complete configuration for a loop device.
0070  * @fd: fd of the file to be used as a backing file for the loop device.
0071  * @block_size: block size to use; ignored if 0.
0072  * @info: struct loop_info64 to configure the loop device with.
0073  *
0074  * This structure is used with the LOOP_CONFIGURE ioctl, and can be used to
0075  * atomically setup and configure all loop device parameters at once.
0076  */
0077 struct loop_config {
0078     __u32           fd;
0079     __u32                   block_size;
0080     struct loop_info64  info;
0081     __u64           __reserved[8];
0082 };
0083 
0084 /*
0085  * Loop filter types
0086  */
0087 
0088 #define LO_CRYPT_NONE       0
0089 #define LO_CRYPT_XOR        1
0090 #define LO_CRYPT_DES        2
0091 #define LO_CRYPT_FISH2      3    /* Twofish encryption */
0092 #define LO_CRYPT_BLOW       4
0093 #define LO_CRYPT_CAST128    5
0094 #define LO_CRYPT_IDEA       6
0095 #define LO_CRYPT_DUMMY      9
0096 #define LO_CRYPT_SKIPJACK   10
0097 #define LO_CRYPT_CRYPTOAPI  18
0098 #define MAX_LO_CRYPT        20
0099 
0100 /*
0101  * IOCTL commands --- we will commandeer 0x4C ('L')
0102  */
0103 
0104 #define LOOP_SET_FD     0x4C00
0105 #define LOOP_CLR_FD     0x4C01
0106 #define LOOP_SET_STATUS     0x4C02
0107 #define LOOP_GET_STATUS     0x4C03
0108 #define LOOP_SET_STATUS64   0x4C04
0109 #define LOOP_GET_STATUS64   0x4C05
0110 #define LOOP_CHANGE_FD      0x4C06
0111 #define LOOP_SET_CAPACITY   0x4C07
0112 #define LOOP_SET_DIRECT_IO  0x4C08
0113 #define LOOP_SET_BLOCK_SIZE 0x4C09
0114 #define LOOP_CONFIGURE      0x4C0A
0115 
0116 /* /dev/loop-control interface */
0117 #define LOOP_CTL_ADD        0x4C80
0118 #define LOOP_CTL_REMOVE     0x4C81
0119 #define LOOP_CTL_GET_FREE   0x4C82
0120 #endif /* _UAPI_LINUX_LOOP_H */