1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved.
4f08c3bdfSopenharmony_ci * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
5f08c3bdfSopenharmony_ci */
6f08c3bdfSopenharmony_ci#ifndef LAPI_LOOP_H__
7f08c3bdfSopenharmony_ci#define LAPI_LOOP_H__
8f08c3bdfSopenharmony_ci
9f08c3bdfSopenharmony_ci#include "config.h"
10f08c3bdfSopenharmony_ci#include <linux/types.h>
11f08c3bdfSopenharmony_ci#include <linux/loop.h>
12f08c3bdfSopenharmony_ci
13f08c3bdfSopenharmony_ci#ifndef LO_FLAGS_PARTSCAN
14f08c3bdfSopenharmony_ci# define LO_FLAGS_PARTSCAN 8
15f08c3bdfSopenharmony_ci#endif
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci#ifndef LO_FLAGS_DIRECT_IO
18f08c3bdfSopenharmony_ci# define LO_FLAGS_DIRECT_IO 16
19f08c3bdfSopenharmony_ci#endif
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_ci#ifndef LOOP_SET_CAPACITY
22f08c3bdfSopenharmony_ci# define LOOP_SET_CAPACITY 0x4C07
23f08c3bdfSopenharmony_ci#endif
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci#ifndef LOOP_SET_DIRECT_IO
26f08c3bdfSopenharmony_ci# define LOOP_SET_DIRECT_IO 0x4C08
27f08c3bdfSopenharmony_ci#endif
28f08c3bdfSopenharmony_ci
29f08c3bdfSopenharmony_ci#ifndef LOOP_SET_BLOCK_SIZE
30f08c3bdfSopenharmony_ci# define LOOP_SET_BLOCK_SIZE 0x4C09
31f08c3bdfSopenharmony_ci#endif
32f08c3bdfSopenharmony_ci
33f08c3bdfSopenharmony_ci#ifndef LOOP_CONFIGURE
34f08c3bdfSopenharmony_ci# define LOOP_CONFIGURE 0x4C0A
35f08c3bdfSopenharmony_ci#endif
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_ci#ifndef HAVE_STRUCT_LOOP_CONFIG
38f08c3bdfSopenharmony_ci/*
39f08c3bdfSopenharmony_ci * struct loop_config - Complete configuration for a loop device.
40f08c3bdfSopenharmony_ci * @fd: fd of the file to be used as a backing file for the loop device.
41f08c3bdfSopenharmony_ci * @block_size: block size to use; ignored if 0.
42f08c3bdfSopenharmony_ci * @info: struct loop_info64 to configure the loop device with.
43f08c3bdfSopenharmony_ci *
44f08c3bdfSopenharmony_ci * This structure is used with the LOOP_CONFIGURE ioctl, and can be used to
45f08c3bdfSopenharmony_ci * atomically setup and configure all loop device parameters at once.
46f08c3bdfSopenharmony_ci */
47f08c3bdfSopenharmony_cistruct loop_config {
48f08c3bdfSopenharmony_ci	__u32			fd;
49f08c3bdfSopenharmony_ci	__u32                   block_size;
50f08c3bdfSopenharmony_ci	struct loop_info64	info;
51f08c3bdfSopenharmony_ci	__u64			__reserved[8];
52f08c3bdfSopenharmony_ci};
53f08c3bdfSopenharmony_ci#endif
54f08c3bdfSopenharmony_ci
55f08c3bdfSopenharmony_ci#endif /* LAPI_LOOP_H__ */
56