Add check_size_lte

Add a _lte val boolean so that -EOVERFLOW is returned if the item is
greater than the value vector.

Signed-off-by: Zach Brown <zab@versity.com>
Reviewed-by: Mark Fasheh <mfasheh@versity.com>
This commit is contained in:
Zach Brown
2016-11-14 14:20:37 -08:00
parent 243a36e405
commit 37bc86b558
2 changed files with 3 additions and 0 deletions

View File

@@ -151,6 +151,8 @@ static int copy_to_val(struct scoutfs_btree_val *val,
/* XXX corruption */
if (val->check_size_eq && val_len != scoutfs_btree_val_length(val))
return -EIO;
if (val->check_size_lte && val_len > scoutfs_btree_val_length(val))
return -EOVERFLOW;
for (i = 0, off = 0; val_len > 0 && i < ARRAY_SIZE(val->vec); i++) {
kv = &val->vec[i];

View File

@@ -6,6 +6,7 @@
struct scoutfs_btree_val {
struct kvec vec[3];
unsigned int check_size_eq:1;
unsigned int check_size_lte:1;
};
static inline void __scoutfs_btree_init_val(struct scoutfs_btree_val *val,