* [PATCH] btrfs-progs: restore: fix mistake on overwrite_ok() if relative path is given
@ 2018-04-18 7:12 Ting-Chang
2018-05-31 11:56 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Ting-Chang @ 2018-04-18 7:12 UTC (permalink / raw)
To: linux-btrfs; +Cc: Ting-Chang Hou
From: Ting-Chang Hou <tchou@synology.com>
fstatat will return -1 with errno EBADF if path_name is relative path.
This caused an error of the return value of overwrite_ok().
When restoring the subvolume to destination with relative path,
it will overwrite the existing file rather than skip it.
Signed-off-by: tchou <tchou@synology.com>
---
cmds-restore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmds-restore.c b/cmds-restore.c
index ade35f0..dc042e2 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -825,7 +825,7 @@ static int overwrite_ok(const char * path)
int ret;
/* don't be fooled by symlinks */
- ret = fstatat(-1, path_name, &st, AT_SYMLINK_NOFOLLOW);
+ ret = fstatat(AT_FDCWD, path_name, &st, AT_SYMLINK_NOFOLLOW);
if (!ret) {
if (overwrite)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs-progs: restore: fix mistake on overwrite_ok() if relative path is given
2018-04-18 7:12 [PATCH] btrfs-progs: restore: fix mistake on overwrite_ok() if relative path is given Ting-Chang
@ 2018-05-31 11:56 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2018-05-31 11:56 UTC (permalink / raw)
To: Ting-Chang; +Cc: linux-btrfs
On Wed, Apr 18, 2018 at 03:12:15PM +0800, Ting-Chang wrote:
> From: Ting-Chang Hou <tchou@synology.com>
>
> fstatat will return -1 with errno EBADF if path_name is relative path.
> This caused an error of the return value of overwrite_ok().
> When restoring the subvolume to destination with relative path,
> it will overwrite the existing file rather than skip it.
>
> Signed-off-by: tchou <tchou@synology.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-31 11:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-18 7:12 [PATCH] btrfs-progs: restore: fix mistake on overwrite_ok() if relative path is given Ting-Chang
2018-05-31 11:56 ` David Sterba
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).