Message ID | 1376455051-12436-1-git-send-email-anand.jain@oracle.com (mailing list archive) |
---|---|
State | Under Review, archived |
Headers | show |
diff --git a/mkfs.c b/mkfs.c index 8183879..73f5425 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1548,8 +1548,6 @@ int main(int ac, char **av) * occur by the following processing. * (btrfs_register_one_device() fails if O_EXCL is on) */ - if (fd > 0) - close(fd); fd = open(file, O_RDWR); if (fd < 0) { fprintf(stderr, "unable to open %s: %s\n", file, @@ -1561,6 +1559,7 @@ int main(int ac, char **av) if (ret) { fprintf(stderr, "skipping duplicate device %s in FS\n", file); + close(fd); continue; } ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
btrfs_add_to_fsid() saves the fd in the device list. close_ctree() will retrive the device list to handle the close(). So the device fd shouldn't closed here. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- mkfs.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)