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

[dm-devel] [PATCH] dmsetup: detect write failure



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 redhat com>

	* 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)


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