mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
lib/create: explicitly close fd and report close(2) errors
Signed-off-by: Susant Sahani <ssahani@redhat.com>
This commit is contained in:
@@ -104,9 +104,7 @@ guestfs_impl_disk_create (guestfs_h *g, const char *filename,
|
||||
static int
|
||||
disk_create_raw_block (guestfs_h *g, const char *filename)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open (filename, O_WRONLY|O_NOCTTY|O_CLOEXEC, 0666);
|
||||
int fd = open(filename, O_WRONLY|O_NOCTTY|O_CLOEXEC, 0666);
|
||||
if (fd == -1) {
|
||||
perrorf (g, _("cannot open block device: %s"), filename);
|
||||
return -1;
|
||||
@@ -125,7 +123,10 @@ disk_create_raw_block (guestfs_h *g, const char *filename)
|
||||
}
|
||||
#endif
|
||||
|
||||
close (fd);
|
||||
if (close (fd) == -1) {
|
||||
perrorf (g, _("%s: close"), filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user