[PATCH 8/8] fix mutipath -W on empty wwids file

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

 



When multipath tries to open the wwids file and finds it empty or
missing, it writes the header to the file.  When it tried to wipe
the wwids from an empty or missing file, it didn't seek back to the
start of the file after truncating it.  This caused the the wwids
file to have a patch of zeroed bytes at the start. This patch fixes
this by always seeking back to the start of the file before rewriting
the header.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 libmultipath/wwids.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c
index 91b07a7..eca1799 100644
--- a/libmultipath/wwids.c
+++ b/libmultipath/wwids.c
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <limits.h>
 #include <stdio.h>
+#include <sys/types.h>
 
 #include "checkers.h"
 #include "vector.h"
@@ -100,6 +101,11 @@ replace_wwids(vector mp)
 		condlog(0, "cannot truncate wwids file : %s", strerror(errno));
 		goto out_file;
 	}
+	if (lseek(fd, 0, SEEK_SET) < 0) {
+		condlog(0, "cannot seek to the start of the file : %s",
+			strerror(errno));
+		goto out_file;
+	}
 	len = strlen(WWIDS_FILE_HEADER);
 	if (write_all(fd, WWIDS_FILE_HEADER, len) != len) {
 		condlog(0, "Can't write wwid file header : %s",
-- 
1.8.2

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