* [PATCH 0/2] BTRFS_IOC_INO_LOOKUP ioctl fixes
@ 2013-08-14 2:00 Filipe David Borba Manana
2013-08-14 2:00 ` [PATCH 1/2] Btrfs: add missing error code to BTRFS_IOC_INO_LOOKUP handler Filipe David Borba Manana
2013-08-14 2:00 ` [PATCH 2/2] Btrfs: don't miss inode ref items in BTRFS_IOC_INO_LOOKUP Filipe David Borba Manana
0 siblings, 2 replies; 3+ messages in thread
From: Filipe David Borba Manana @ 2013-08-14 2:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: Filipe David Borba Manana
This set of patches fixes 2 issues with the BTRFS_IOC_INO_LOOKUP ioctl:
1) missing error code return when path is too long;
2) ocassional ENOENT error even when the desired inode ref items exist.
Filipe David Borba Manana (2):
Btrfs: add missing error code to BTRFS_IOC_INO_LOOKUP handler
Btrfs: don't miss inode ref items in BTRFS_IOC_INO_LOOKUP
fs/btrfs/ioctl.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] Btrfs: add missing error code to BTRFS_IOC_INO_LOOKUP handler
2013-08-14 2:00 [PATCH 0/2] BTRFS_IOC_INO_LOOKUP ioctl fixes Filipe David Borba Manana
@ 2013-08-14 2:00 ` Filipe David Borba Manana
2013-08-14 2:00 ` [PATCH 2/2] Btrfs: don't miss inode ref items in BTRFS_IOC_INO_LOOKUP Filipe David Borba Manana
1 sibling, 0 replies; 3+ messages in thread
From: Filipe David Borba Manana @ 2013-08-14 2:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: Filipe David Borba Manana
If the path doesn't fit in the input buffer, return ENAMETOOLONG
instead of returning with a success code (0) and a partially
filled and right justified buffer.
Also removed useless buffer pointer check outside the while loop.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
fs/btrfs/ioctl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 2312c0f..3f2a8c1 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2015,8 +2015,10 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
len = btrfs_inode_ref_name_len(l, iref);
ptr -= len + 1;
total_len += len + 1;
- if (ptr < name)
+ if (ptr < name) {
+ ret = -ENAMETOOLONG;
goto out;
+ }
*(ptr + len) = '/';
read_extent_buffer(l, ptr,(unsigned long)(iref + 1), len);
@@ -2029,8 +2031,6 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
key.offset = (u64)-1;
dirid = key.objectid;
}
- if (ptr < name)
- goto out;
memmove(name, ptr, total_len);
name[total_len]='\0';
ret = 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] Btrfs: don't miss inode ref items in BTRFS_IOC_INO_LOOKUP
2013-08-14 2:00 [PATCH 0/2] BTRFS_IOC_INO_LOOKUP ioctl fixes Filipe David Borba Manana
2013-08-14 2:00 ` [PATCH 1/2] Btrfs: add missing error code to BTRFS_IOC_INO_LOOKUP handler Filipe David Borba Manana
@ 2013-08-14 2:00 ` Filipe David Borba Manana
1 sibling, 0 replies; 3+ messages in thread
From: Filipe David Borba Manana @ 2013-08-14 2:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: Filipe David Borba Manana
If the inode ref key was not found and the current leaf slot
was 0 (first item in the leaf) the code would always return
-ENOENT. This was not correct because the desired inode ref
item might be the last item in the previous leaf.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
fs/btrfs/ioctl.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3f2a8c1..e8f295c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1998,19 +1998,21 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
goto out;
+ else if (ret > 0) {
+ ret = btrfs_previous_item(root, path, dirid,
+ BTRFS_INODE_REF_KEY);
+ if (ret < 0)
+ goto out;
+ else if (ret > 0) {
+ ret = -ENOENT;
+ goto out;
+ }
+ }
l = path->nodes[0];
slot = path->slots[0];
- if (ret > 0 && slot > 0)
- slot--;
btrfs_item_key_to_cpu(l, &key, slot);
- if (ret > 0 && (key.objectid != dirid ||
- key.type != BTRFS_INODE_REF_KEY)) {
- ret = -ENOENT;
- goto out;
- }
-
iref = btrfs_item_ptr(l, slot, struct btrfs_inode_ref);
len = btrfs_inode_ref_name_len(l, iref);
ptr -= len + 1;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-14 2:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-14 2:00 [PATCH 0/2] BTRFS_IOC_INO_LOOKUP ioctl fixes Filipe David Borba Manana
2013-08-14 2:00 ` [PATCH 1/2] Btrfs: add missing error code to BTRFS_IOC_INO_LOOKUP handler Filipe David Borba Manana
2013-08-14 2:00 ` [PATCH 2/2] Btrfs: don't miss inode ref items in BTRFS_IOC_INO_LOOKUP Filipe David Borba Manana
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).