![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 0002 /* 0003 * FS_IOC_GETFSMAP ioctl infrastructure. 0004 * 0005 * Copyright (C) 2017 Oracle. All Rights Reserved. 0006 * 0007 * Author: Darrick J. Wong <darrick.wong@oracle.com> 0008 */ 0009 #ifndef _LINUX_FSMAP_H 0010 #define _LINUX_FSMAP_H 0011 0012 #include <linux/types.h> 0013 0014 /* 0015 * Structure for FS_IOC_GETFSMAP. 0016 * 0017 * The memory layout for this call are the scalar values defined in 0018 * struct fsmap_head, followed by two struct fsmap that describe 0019 * the lower and upper bound of mappings to return, followed by an 0020 * array of struct fsmap mappings. 0021 * 0022 * fmh_iflags control the output of the call, whereas fmh_oflags report 0023 * on the overall record output. fmh_count should be set to the 0024 * length of the fmh_recs array, and fmh_entries will be set to the 0025 * number of entries filled out during each call. If fmh_count is 0026 * zero, the number of reverse mappings will be returned in 0027 * fmh_entries, though no mappings will be returned. fmh_reserved 0028 * must be set to zero. 0029 * 0030 * The two elements in the fmh_keys array are used to constrain the 0031 * output. The first element in the array should represent the 0032 * lowest disk mapping ("low key") that the user wants to learn 0033 * about. If this value is all zeroes, the filesystem will return 0034 * the first entry it knows about. For a subsequent call, the 0035 * contents of fsmap_head.fmh_recs[fsmap_head.fmh_count - 1] should be 0036 * copied into fmh_keys[0] to have the kernel start where it left off. 0037 * 0038 * The second element in the fmh_keys array should represent the 0039 * highest disk mapping ("high key") that the user wants to learn 0040 * about. If this value is all ones, the filesystem will not stop 0041 * until it runs out of mapping to return or runs out of space in 0042 * fmh_recs. 0043 * 0044 * fmr_device can be either a 32-bit cookie representing a device, or 0045 * a 32-bit dev_t if the FMH_OF_DEV_T flag is set. fmr_physical, 0046 * fmr_offset, and fmr_length are expressed in units of bytes. 0047 * fmr_owner is either an inode number, or a special value if 0048 * FMR_OF_SPECIAL_OWNER is set in fmr_flags. 0049 */ 0050 struct fsmap { 0051 __u32 fmr_device; /* device id */ 0052 __u32 fmr_flags; /* mapping flags */ 0053 __u64 fmr_physical; /* device offset of segment */ 0054 __u64 fmr_owner; /* owner id */ 0055 __u64 fmr_offset; /* file offset of segment */ 0056 __u64 fmr_length; /* length of segment */ 0057 __u64 fmr_reserved[3]; /* must be zero */ 0058 }; 0059 0060 struct fsmap_head { 0061 __u32 fmh_iflags; /* control flags */ 0062 __u32 fmh_oflags; /* output flags */ 0063 __u32 fmh_count; /* # of entries in array incl. input */ 0064 __u32 fmh_entries; /* # of entries filled in (output). */ 0065 __u64 fmh_reserved[6]; /* must be zero */ 0066 0067 struct fsmap fmh_keys[2]; /* low and high keys for the mapping search */ 0068 struct fsmap fmh_recs[]; /* returned records */ 0069 }; 0070 0071 /* Size of an fsmap_head with room for nr records. */ 0072 static inline __kernel_size_t 0073 fsmap_sizeof( 0074 unsigned int nr) 0075 { 0076 return sizeof(struct fsmap_head) + nr * sizeof(struct fsmap); 0077 } 0078 0079 /* Start the next fsmap query at the end of the current query results. */ 0080 static inline void 0081 fsmap_advance( 0082 struct fsmap_head *head) 0083 { 0084 head->fmh_keys[0] = head->fmh_recs[head->fmh_entries - 1]; 0085 } 0086 0087 /* fmh_iflags values - set by FS_IOC_GETFSMAP caller in the header. */ 0088 /* no flags defined yet */ 0089 #define FMH_IF_VALID 0 0090 0091 /* fmh_oflags values - returned in the header segment only. */ 0092 #define FMH_OF_DEV_T 0x1 /* fmr_device values will be dev_t */ 0093 0094 /* fmr_flags values - returned for each non-header segment */ 0095 #define FMR_OF_PREALLOC 0x1 /* segment = unwritten pre-allocation */ 0096 #define FMR_OF_ATTR_FORK 0x2 /* segment = attribute fork */ 0097 #define FMR_OF_EXTENT_MAP 0x4 /* segment = extent map */ 0098 #define FMR_OF_SHARED 0x8 /* segment = shared with another file */ 0099 #define FMR_OF_SPECIAL_OWNER 0x10 /* owner is a special value */ 0100 #define FMR_OF_LAST 0x20 /* segment is the last in the dataset */ 0101 0102 /* Each FS gets to define its own special owner codes. */ 0103 #define FMR_OWNER(type, code) (((__u64)type << 32) | \ 0104 ((__u64)code & 0xFFFFFFFFULL)) 0105 #define FMR_OWNER_TYPE(owner) ((__u32)((__u64)owner >> 32)) 0106 #define FMR_OWNER_CODE(owner) ((__u32)(((__u64)owner & 0xFFFFFFFFULL))) 0107 #define FMR_OWN_FREE FMR_OWNER(0, 1) /* free space */ 0108 #define FMR_OWN_UNKNOWN FMR_OWNER(0, 2) /* unknown owner */ 0109 #define FMR_OWN_METADATA FMR_OWNER(0, 3) /* metadata */ 0110 0111 #define FS_IOC_GETFSMAP _IOWR('X', 59, struct fsmap_head) 0112 0113 #endif /* _LINUX_FSMAP_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |