[PATCH] dmsetup: detect write failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since "fd" may be open on a writable file handle, it's
important to test for close failure.  Otherwise, the code
could fail to detect a write error.

2007-03-11  Jim Meyering  <meyering@xxxxxxxxxx>

	* dmsetup/dmsetup.c (_loop_table): Detect close failure.

Index: dmsetup/dmsetup.c
===================================================================
RCS file: /cvs/dm/device-mapper/dmsetup/dmsetup.c,v
retrieving revision 1.87
diff -u -p -r1.87 dmsetup.c
--- dmsetup/dmsetup.c	14 Feb 2007 15:12:16 -0000	1.87
+++ dmsetup/dmsetup.c	12 Mar 2007 14:16:47 -0000
@@ -1920,7 +1920,10 @@ static int _loop_table(char *table, size
 	blksize = fsbuf.f_frsize;
 #endif

-	close(fd);
+	if (close(fd)) {
+		fd = -1;
+		goto error;
+	}

 	if (dm_snprintf(table, tlen, "%llu %llu loop %s %llu\n", 0ULL,
 			(long long unsigned)sectors, file, off) < 0)

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux