diff options
| author | Filipe Manana <fdmanana@suse.com> | 2026-06-15 17:33:03 +0100 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-07-22 15:24:15 +0200 |
| commit | 8a39c3e60894489aa128168eec6b5f2c22f9ca2f (patch) | |
| tree | c0e84692faa54dd8dc193dea66cd57f17c9e8c30 /fs/btrfs | |
| parent | 56e65ce8219fefb5ea87e7cb7bb0d011b9aeac2e (diff) | |
| download | linux-next-8a39c3e60894489aa128168eec6b5f2c22f9ca2f.tar.gz linux-next-8a39c3e60894489aa128168eec6b5f2c22f9ca2f.zip | |
btrfs: send: fix is_current_inode_path() to avoid path resets for common prefixes
In case the current inode's path is a prefix of the given path, the helper
is_current_inode_path() will return true, which causes the single caller
to reset the current inode's path. While this is not a functional issue,
it makes the caller recompute the current inode's path later. It could
also become a problem in the future in case get new callers for
is_current_inode_path() in more sensitive contexts.
Example: the current inode path is "/foo/bar" and the path we compare
against is "/foo/bar_xyz".
Fix this by returning true only if we have exact matches.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Daniel Vacek <neelx@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
| -rw-r--r-- | fs/btrfs/send.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index d37c18f41545..1023ab3b5840 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -625,9 +625,8 @@ static void fs_path_unreverse(struct fs_path *p) static inline bool is_current_inode_path(const struct send_ctx *sctx, const struct fs_path *path) { - const struct fs_path *cur = &sctx->cur_inode_path; - - return (strncmp(path->start, cur->start, fs_path_len(cur)) == 0); + /* Paths are always nul terminated. */ + return (strcmp(path->start, sctx->cur_inode_path.start) == 0); } static struct btrfs_path *alloc_path_for_send(void) |
