[PATCH 1/1] mount.nfs: mtab corruption when RLIMIT_FSIZE causes a partial write

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

 



This patch is a following on to commit 7a802337. Using the
tool in https://bugzilla.redhat.com/show_bug.cgi?id=695916
caused the fflush() and fclose() to fail in turn causing
corruption in the mtab.

The failures were in the internals of both calls. Switch those
calls with the actual system calls eliminated the failures.

Signed-off-by: Steve Dickson <steved@xxxxxxxxxx>
---
 support/nfs/nfs_mntent.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/support/nfs/nfs_mntent.c b/support/nfs/nfs_mntent.c
index a2118a2..b80f270 100644
--- a/support/nfs/nfs_mntent.c
+++ b/support/nfs/nfs_mntent.c
@@ -117,7 +117,7 @@ void
 nfs_endmntent (mntFILE *mfp) {
 	if (mfp) {
 		if (mfp->mntent_fp)
-			fclose(mfp->mntent_fp);
+			close(fileno(mfp->mntent_fp));
 		if (mfp->mntent_file)
 			free(mfp->mntent_file);
 		free(mfp);
@@ -147,7 +147,7 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) {
 	free(m3);
 	free(m4);
 	if (res >= 0) {
-		res = fflush(mfp->mntent_fp);
+		res = fsync(fileno(mfp->mntent_fp));
 		if (res < 0)
 			/* Avoid leaving a corrupt mtab file */
 			ftruncate(fileno(mfp->mntent_fp), length);
-- 
1.7.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux