1 |
|
2 |
http://git.linux-nfs.org/?p=steved%2Fnfs-utils.git;a=commitdiff_plain;h=7a802337bfc92d0b30fe94dbd0fa231990a26161 |
3 |
https://bugzilla.redhat.com/show_bug.cgi?id=697975 |
4 |
|
5 |
--- support/nfs/nfs_mntent.c 2008-07-27 21:01:45.000000000 +0000 |
6 |
+++ support/nfs/nfs_mntent.c.oden 2011-12-12 17:04:43.000000000 +0000 |
7 |
@@ -12,6 +12,7 @@ |
8 |
#include <string.h> /* for index */ |
9 |
#include <ctype.h> /* for isdigit */ |
10 |
#include <sys/stat.h> /* for umask */ |
11 |
+#include <unistd.h> /* for ftruncate */ |
12 |
|
13 |
#include "nfs_mntent.h" |
14 |
#include "nls.h" |
15 |
@@ -127,9 +128,11 @@ int |
16 |
nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { |
17 |
char *m1, *m2, *m3, *m4; |
18 |
int res; |
19 |
+ off_t length; |
20 |
|
21 |
if (fseek (mfp->mntent_fp, 0, SEEK_END)) |
22 |
return 1; /* failure */ |
23 |
+ length = ftell(mfp->mntent_fp); |
24 |
|
25 |
m1 = mangle(mnt->mnt_fsname); |
26 |
m2 = mangle(mnt->mnt_dir); |
27 |
@@ -143,6 +146,12 @@ nfs_addmntent (mntFILE *mfp, struct mnte |
28 |
free(m2); |
29 |
free(m3); |
30 |
free(m4); |
31 |
+ if (res >= 0) { |
32 |
+ res = fflush(mfp->mntent_fp); |
33 |
+ if (res < 0) |
34 |
+ /* Avoid leaving a corrupt mtab file */ |
35 |
+ ftruncate(fileno(mfp->mntent_fp), length); |
36 |
+ } |
37 |
return (res < 0) ? 1 : 0; |
38 |
} |
39 |
|