mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-02 02:41:36 +00:00
btrfs-progs: don't clobber errno in close_file_or_dir
Preserve the errno value for the caller in case closing happens in the middle of eg. an ioctl and reporing the failure. The errors that could happen in close/closedir do not bother us. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d7f906c23a
commit
24103f42ad
10
utils.c
10
utils.c
@ -1549,10 +1549,16 @@ int open_file_or_dir(const char *fname, DIR **dirstream)
|
||||
|
||||
void close_file_or_dir(int fd, DIR *dirstream)
|
||||
{
|
||||
if (dirstream)
|
||||
int old_errno;
|
||||
|
||||
old_errno = errno;
|
||||
if (dirstream) {
|
||||
closedir(dirstream);
|
||||
else if (fd >= 0)
|
||||
} else if (fd >= 0) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
errno = old_errno;
|
||||
}
|
||||
|
||||
int get_device_info(int fd, u64 devid,
|
||||
|
Loading…
Reference in New Issue
Block a user