From 625223903e23b46de615e71e9860a17afcd87632 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Thu, 19 Oct 2017 13:41:35 +0800 Subject: [PATCH] btrfs-progs: mkfs: fix overwritten return value for mkfs For mkfs failure, especially --rootdir errors like EPERM/ENOSPC, the out branch will overwrite the return value, causing wrong status code. Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov Signed-off-by: David Sterba --- mkfs/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mkfs/main.c b/mkfs/main.c index 94f54d8..284dbd7 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -1426,6 +1426,7 @@ int main(int argc, char **argv) int zero_end = 1; int fd = -1; int ret; + int close_ret; int i; int mixed = 0; int nodesize_forced = 0; @@ -1941,9 +1942,9 @@ raid_groups: */ fs_info->finalize_on_close = 1; out: - ret = close_ctree(root); + close_ret = close_ctree(root); - if (!ret) { + if (!close_ret) { optind = saved_optind; dev_cnt = argc - optind; while (dev_cnt-- > 0) { -- 2.7.4