Skip to contentSkip to conversation

btrfs-progs: restore: fix mistake on overwrite_ok() if relative path is given

PATCH Applied Ting-Chang 2 participants 2 messages Apr 18, 2018 – May 31, 2018 Btrfs file system

lore
Share & tools
lore

Ting-Chang

author
#0 lore raw

PATCH 1/1 btrfs-progs: restore: fix mistake on overwrite_ok() if relative path is given

From: Ting-Chang Hou <[email protected]>

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.

---
 cmds-restore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds-restore.c +1 -1
index ade35f0..dc042e2 100644
@@ -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)
Signature · 1 line
2.7.4
Applied
#1 lore raw
Quoted 8 lines · Ting-Chang

From: Ting-Chang Hou <[email protected]>

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.

Applied, thanks.