From: Simon Glass <simon.glass@canonical.com> Create linux/fiemap.h with FIEMAP extent flags, fiemap_extent_info structure, and fiemap operation stubs. Update ext4_uboot.h to use the new header instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 24 +++------------------- include/linux/fiemap.h | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 include/linux/fiemap.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 937c819a3f0..185951ac4c1 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -141,11 +141,8 @@ typedef struct { unsigned int val; } kprojid_t; /* Capabilities - use linux/capability.h */ #include <linux/capability.h> -/* FIEMAP extent flags */ -#define FIEMAP_EXTENT_LAST 0x00000001 -#define FIEMAP_EXTENT_UNKNOWN 0x00000002 -#define FIEMAP_EXTENT_DELALLOC 0x00000004 -#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 +/* FIEMAP types - use linux/fiemap.h */ +#include <linux/fiemap.h> #define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 /* FALLOC_FL_* flags are in linux/fs.h */ @@ -174,18 +171,6 @@ typedef struct { unsigned int val; } kprojid_t; /* iomap types and structs are in linux/iomap.h */ -/* fiemap types */ -#define FIEMAP_FLAG_SYNC 0x00000001 -#define FIEMAP_FLAG_XATTR 0x00000002 -#define FIEMAP_FLAG_CACHE 0x00000004 - -struct fiemap_extent_info { - unsigned int fi_flags; - unsigned int fi_extents_mapped; - unsigned int fi_extents_max; - void *fi_extents_start; -}; - /* fscrypt_str, qstr are now in ext4_fscrypt.h */ /* percpu rw semaphore is in linux/percpu.h */ @@ -850,10 +835,7 @@ static inline int in_range(unsigned long val, unsigned long start, /* Quota stub */ #define dquot_reclaim_block(i, n) do { } while (0) -/* fiemap stubs */ -#define fiemap_prep(i, fi, s, l, f) ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(f); 0; }) -#define fiemap_fill_next_extent(fi, l, p, sz, f) ({ (void)(fi); (void)(l); (void)(p); (void)(sz); (void)(f); 0; }) -#define iomap_fiemap(i, fi, s, l, o) ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(o); 0; }) +/* fiemap stubs are now in linux/fiemap.h */ /* Memory retry wait */ #define memalloc_retry_wait(g) do { } while (0) diff --git a/include/linux/fiemap.h b/include/linux/fiemap.h new file mode 100644 index 00000000000..f02080832be --- /dev/null +++ b/include/linux/fiemap.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Fiemap definitions for U-Boot + * + * Based on Linux fiemap.h - extent mapping interface. + */ +#ifndef _LINUX_FIEMAP_H +#define _LINUX_FIEMAP_H + +#include <linux/types.h> + +/* FIEMAP extent flags */ +#define FIEMAP_EXTENT_LAST 0x00000001 +#define FIEMAP_EXTENT_UNKNOWN 0x00000002 +#define FIEMAP_EXTENT_DELALLOC 0x00000004 +#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 + +/* FIEMAP flags */ +#define FIEMAP_FLAG_SYNC 0x00000001 +#define FIEMAP_FLAG_XATTR 0x00000002 +#define FIEMAP_FLAG_CACHE 0x00000004 + +/** + * struct fiemap_extent_info - fiemap request to a filesystem + * @fi_flags: flags as passed from user + * @fi_extents_mapped: number of mapped extents + * @fi_extents_max: size of fiemap_extent array + * @fi_extents_start: start of fiemap_extent array + */ +struct fiemap_extent_info { + unsigned int fi_flags; + unsigned int fi_extents_mapped; + unsigned int fi_extents_max; + void *fi_extents_start; +}; + +/* Fiemap stubs - fiemap not supported in U-Boot */ +#define fiemap_prep(i, fi, s, l, f) \ + ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(f); 0; }) +#define fiemap_fill_next_extent(fi, l, p, sz, f) \ + ({ (void)(fi); (void)(l); (void)(p); (void)(sz); (void)(f); 0; }) +#define iomap_fiemap(i, fi, s, l, o) \ + ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(o); 0; }) + +#endif /* _LINUX_FIEMAP_H */ -- 2.43.0