|
Kmods SIG |
d83023 |
From 9d008240e684ea13b35b107589f354a266aca850 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
d83023 |
From: Peter Georg <peter.georg@physik.uni-regensburg.de>
|
|
Kmods SIG |
d83023 |
Date: Wed, 22 Sep 2021 22:32:42 +0200
|
|
Kmods SIG |
d83023 |
Subject: [PATCH 9005/9005] Compat: Add fiemap_prep function
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
---
|
|
Kmods SIG |
d83023 |
src/compat.h | 43 +++++++++++++++++++++++++++++++++++++++++++
|
|
Kmods SIG |
d83023 |
src/file.c | 2 ++
|
|
Kmods SIG |
d83023 |
2 files changed, 45 insertions(+)
|
|
Kmods SIG |
d83023 |
create mode 100644 src/compat.h
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
diff --git a/src/compat.h b/src/compat.h
|
|
Kmods SIG |
d83023 |
new file mode 100644
|
|
Kmods SIG |
d83023 |
index 0000000..9862d76
|
|
Kmods SIG |
d83023 |
--- /dev/null
|
|
Kmods SIG |
d83023 |
+++ b/src/compat.h
|
|
Kmods SIG |
d83023 |
@@ -0,0 +1,43 @@
|
|
Kmods SIG |
d83023 |
+ /**
|
|
Kmods SIG |
d83023 |
+ * fiemap_prep - check validity of requested flags for fiemap
|
|
Kmods SIG |
d83023 |
+ * @inode: Inode to operate on
|
|
Kmods SIG |
d83023 |
+ * @fieinfo: Fiemap context passed into ->fiemap
|
|
Kmods SIG |
d83023 |
+ * @start: Start of the mapped range
|
|
Kmods SIG |
d83023 |
+ * @len: Length of the mapped range, can be truncated by this function.
|
|
Kmods SIG |
d83023 |
+ * @supported_flags: Set of fiemap flags that the file system understands
|
|
Kmods SIG |
d83023 |
+ *
|
|
Kmods SIG |
d83023 |
+ * This function must be called from each ->fiemap instance to validate the
|
|
Kmods SIG |
d83023 |
+ * fiemap request against the file system parameters.
|
|
Kmods SIG |
d83023 |
+ *
|
|
Kmods SIG |
d83023 |
+ * Returns 0 on success, or a negative error on failure.
|
|
Kmods SIG |
d83023 |
+ */
|
|
Kmods SIG |
d83023 |
+static int fiemap_prep(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
|
Kmods SIG |
d83023 |
+ u64 start, u64 *len, u32 supported_flags)
|
|
Kmods SIG |
d83023 |
+{
|
|
Kmods SIG |
d83023 |
+ u64 maxbytes = inode->i_sb->s_maxbytes;
|
|
Kmods SIG |
d83023 |
+ u32 incompat_flags;
|
|
Kmods SIG |
d83023 |
+ int ret = 0;
|
|
Kmods SIG |
d83023 |
+
|
|
Kmods SIG |
d83023 |
+ if (*len == 0)
|
|
Kmods SIG |
d83023 |
+ return -EINVAL;
|
|
Kmods SIG |
d83023 |
+ if (start > maxbytes)
|
|
Kmods SIG |
d83023 |
+ return -EFBIG;
|
|
Kmods SIG |
d83023 |
+
|
|
Kmods SIG |
d83023 |
+ /*
|
|
Kmods SIG |
d83023 |
+ * Shrink request scope to what the fs can actually handle.
|
|
Kmods SIG |
d83023 |
+ */
|
|
Kmods SIG |
d83023 |
+ if (*len > maxbytes || (maxbytes - *len) < start)
|
|
Kmods SIG |
d83023 |
+ *len = maxbytes - start;
|
|
Kmods SIG |
d83023 |
+
|
|
Kmods SIG |
d83023 |
+ supported_flags |= FIEMAP_FLAG_SYNC;
|
|
Kmods SIG |
d83023 |
+ supported_flags &= FIEMAP_FLAGS_COMPAT;
|
|
Kmods SIG |
d83023 |
+ incompat_flags = fieinfo->fi_flags & ~supported_flags;
|
|
Kmods SIG |
d83023 |
+ if (incompat_flags) {
|
|
Kmods SIG |
d83023 |
+ fieinfo->fi_flags = incompat_flags;
|
|
Kmods SIG |
d83023 |
+ return -EBADR;
|
|
Kmods SIG |
d83023 |
+ }
|
|
Kmods SIG |
d83023 |
+
|
|
Kmods SIG |
d83023 |
+ if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC)
|
|
Kmods SIG |
d83023 |
+ ret = filemap_write_and_wait(inode->i_mapping);
|
|
Kmods SIG |
d83023 |
+ return ret;
|
|
Kmods SIG |
d83023 |
+}
|
|
Kmods SIG |
d83023 |
diff --git a/src/file.c b/src/file.c
|
|
Kmods SIG |
d83023 |
index d89afcd..d72800c 100644
|
|
Kmods SIG |
d83023 |
--- a/src/file.c
|
|
Kmods SIG |
d83023 |
+++ b/src/file.c
|
|
Kmods SIG |
d83023 |
@@ -17,6 +17,8 @@
|
|
Kmods SIG |
d83023 |
#include "ntfs.h"
|
|
Kmods SIG |
d83023 |
#include "ntfs_fs.h"
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
+#include "compat.h"
|
|
Kmods SIG |
d83023 |
+
|
|
Kmods SIG |
d83023 |
static int ntfs_ioctl_fitrim(struct ntfs_sb_info *sbi, unsigned long arg)
|
|
Kmods SIG |
d83023 |
{
|
|
Kmods SIG |
d83023 |
struct fstrim_range __user *user_range;
|
|
Kmods SIG |
d83023 |
--
|
|
Kmods SIG |
d83023 |
2.31.1
|
|
Kmods SIG |
d83023 |
|