diff options
| author | Filipe Manana <fdmanana@suse.com> | 2026-06-15 17:33:03 +0100 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-08-07 19:16:28 +0200 |
| commit | bd3dddec1b78bf823b1966aff3ed3f9bb0ebe39c (patch) | |
| tree | 9baa455d62ab8921728f342b77b3a256bbcc3411 | |
| parent | a4cea1272c2068cc109f561f2f00176d92244da7 (diff) | |
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>
| -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) |
