[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190109012701.26441-8-mark@harmstone.com>
Date: Wed, 9 Jan 2019 01:26:50 +0000
From: Mark Harmstone <mark@...mstone.com>
To: unlisted-recipients:; (no To-header on input)
Cc: mark@...mstone.com, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 08/19] btrfs: change extract in prop_handler to write into string
Signed-off-by: Mark Harmstone <mark@...mstone.com>
---
fs/btrfs/props.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index dc6140013ae8..e57a4edc88c4 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -19,7 +19,7 @@ struct prop_handler {
const char *xattr_name;
int (*validate)(const char *value, size_t len);
int (*apply)(struct inode *inode, const char *value, size_t len);
- const char *(*extract)(struct inode *inode);
+ int (*extract)(struct inode *inode, char *value);
int inheritable;
};
@@ -27,7 +27,7 @@ static int prop_compression_validate(const char *value, size_t len);
static int prop_compression_apply(struct inode *inode,
const char *value,
size_t len);
-static const char *prop_compression_extract(struct inode *inode);
+static int prop_compression_extract(struct inode *inode, char *value);
static struct prop_handler prop_handlers[] = {
{
@@ -298,14 +298,14 @@ static int inherit_props(struct btrfs_trans_handle *trans,
for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) {
const struct prop_handler *h = &prop_handlers[i];
- const char *value;
+ char value[64];
u64 num_bytes;
if (!h->inheritable)
continue;
- value = h->extract(parent);
- if (!value)
+ ret = h->extract(parent, value);
+ if (ret)
continue;
num_bytes = btrfs_calc_trans_metadata_size(fs_info, 1);
@@ -410,18 +410,29 @@ static int prop_compression_apply(struct inode *inode,
return 0;
}
-static const char *prop_compression_extract(struct inode *inode)
+static int prop_compression_extract(struct inode *inode, char *value)
{
switch (BTRFS_I(inode)->prop_compress) {
case BTRFS_COMPRESS_ZLIB:
case BTRFS_COMPRESS_LZO:
case BTRFS_COMPRESS_ZSTD:
- return btrfs_compress_type2str(BTRFS_I(inode)->prop_compress);
+ {
+ const char *v;
+
+ v = btrfs_compress_type2str(BTRFS_I(inode)->prop_compress);
+
+ if (!v)
+ return -EINVAL;
+
+ strcpy(value, v);
+
+ return 0;
+ }
default:
break;
}
- return NULL;
+ return -EINVAL;
}
--
2.19.2
Powered by blists - more mailing lists