]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blame - misc/fsmap.h
ext2fs: nls: support UTF-8 11.0 with NFKD normalization
[thirdparty/e2fsprogs.git] / misc / fsmap.h
CommitLineData
82424fc6
DW
1/*
2 * Copyright (c) 2017 Oracle.
3 * All Rights Reserved.
4 *
5 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it would be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#ifndef FSMAP_H_
21#define FSMAP_H_
22
23/* FS_IOC_GETFSMAP ioctl definitions */
24#ifndef FS_IOC_GETFSMAP
25struct fsmap {
26 __u32 fmr_device; /* device id */
27 __u32 fmr_flags; /* mapping flags */
28 __u64 fmr_physical; /* device offset of segment */
29 __u64 fmr_owner; /* owner id */
30 __u64 fmr_offset; /* file offset of segment */
31 __u64 fmr_length; /* length of segment */
32 __u64 fmr_reserved[3]; /* must be zero */
33};
34
35struct fsmap_head {
36 __u32 fmh_iflags; /* control flags */
37 __u32 fmh_oflags; /* output flags */
38 __u32 fmh_count; /* # of entries in array incl. input */
39 __u32 fmh_entries; /* # of entries filled in (output). */
40 __u64 fmh_reserved[6]; /* must be zero */
41
42 struct fsmap fmh_keys[2]; /* low and high keys for the mapping search */
43 struct fsmap fmh_recs[]; /* returned records */
44};
45
46/* Size of an fsmap_head with room for nr records. */
47static inline size_t
48fsmap_sizeof(
49 unsigned int nr)
50{
51 return sizeof(struct fsmap_head) + nr * sizeof(struct fsmap);
52}
53
54/* Start the next fsmap query at the end of the current query results. */
55static inline void
56fsmap_advance(
57 struct fsmap_head *head)
58{
59 head->fmh_keys[0] = head->fmh_recs[head->fmh_entries - 1];
60}
61
62/* fmh_iflags values - set by FS_IOC_GETFSMAP caller in the header. */
63/* no flags defined yet */
64#define FMH_IF_VALID 0
65
66/* fmh_oflags values - returned in the header segment only. */
67#define FMH_OF_DEV_T 0x1 /* fmr_device values will be dev_t */
68
69/* fmr_flags values - returned for each non-header segment */
70#define FMR_OF_PREALLOC 0x1 /* segment = unwritten pre-allocation */
71#define FMR_OF_ATTR_FORK 0x2 /* segment = attribute fork */
72#define FMR_OF_EXTENT_MAP 0x4 /* segment = extent map */
73#define FMR_OF_SHARED 0x8 /* segment = shared with another file */
74#define FMR_OF_SPECIAL_OWNER 0x10 /* owner is a special value */
75#define FMR_OF_LAST 0x20 /* segment is the last in the FS */
76
77/* Each FS gets to define its own special owner codes. */
78#define FMR_OWNER(type, code) (((__u64)type << 32) | \
79 ((__u64)code & 0xFFFFFFFFULL))
80#define FMR_OWNER_TYPE(owner) ((__u32)((__u64)owner >> 32))
81#define FMR_OWNER_CODE(owner) ((__u32)(((__u64)owner & 0xFFFFFFFFULL)))
82#define FMR_OWN_FREE FMR_OWNER(0, 1) /* free space */
83#define FMR_OWN_UNKNOWN FMR_OWNER(0, 2) /* unknown owner */
84#define FMR_OWN_METADATA FMR_OWNER(0, 3) /* metadata */
85
86#define FS_IOC_GETFSMAP _IOWR('X', 59, struct fsmap_head)
87#endif /* FS_IOC_GETFSMAP */
88
89#endif