Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame^] | 1 | From 2fbc62e2a13fc22b6ae4910e295a2c10fb790486 Mon Sep 17 00:00:00 2001 |
| 2 | From: Zoltan Karcagi <zkr7432@gmail.com> |
| 3 | Date: Mon, 12 Aug 2019 13:27:16 -0400 |
| 4 | Subject: [PATCH] Fix include order between config.h and stat.h |
| 5 | |
| 6 | At least on Arch linux ARM, the definition of struct stat in stat.h depends |
| 7 | on __USE_FILE_OFFSET64. This symbol comes from config.h when defined, |
| 8 | therefore config.h must always be included before stat.h. Fix all |
| 9 | occurrences where the order is wrong by moving config.h to the top. |
| 10 | |
| 11 | This fixes the client side error "Stale file handle" when mounting from |
| 12 | a server running Arch Linux ARM. |
| 13 | |
| 14 | Signed-off-by: Zoltan Karcagi <zkr7432@gmail.com> |
| 15 | Signed-off-by: Steve Dickson <steved@redhat.com> |
| 16 | |
| 17 | Upstream-Status: Backport |
| 18 | [http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commit;h=2fbc62e2a13fc22b6ae4910e295a2c10fb790486] |
| 19 | |
| 20 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| 21 | --- |
| 22 | support/misc/nfsd_path.c | 5 ++++- |
| 23 | support/misc/xstat.c | 5 ++++- |
| 24 | support/nfs/conffile.c | 8 +++++++- |
| 25 | utils/blkmapd/device-discovery.c | 8 ++++---- |
| 26 | utils/idmapd/idmapd.c | 8 ++++---- |
| 27 | 5 files changed, 23 insertions(+), 11 deletions(-) |
| 28 | |
| 29 | diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c |
| 30 | index 84e4802..f078a66 100644 |
| 31 | --- a/support/misc/nfsd_path.c |
| 32 | +++ b/support/misc/nfsd_path.c |
| 33 | @@ -1,3 +1,7 @@ |
| 34 | +#ifdef HAVE_CONFIG_H |
| 35 | +#include <config.h> |
| 36 | +#endif |
| 37 | + |
| 38 | #include <errno.h> |
| 39 | #include <sys/types.h> |
| 40 | #include <sys/stat.h> |
| 41 | @@ -5,7 +9,6 @@ |
| 42 | #include <stdlib.h> |
| 43 | #include <unistd.h> |
| 44 | |
| 45 | -#include "config.h" |
| 46 | #include "conffile.h" |
| 47 | #include "xmalloc.h" |
| 48 | #include "xlog.h" |
| 49 | diff --git a/support/misc/xstat.c b/support/misc/xstat.c |
| 50 | index fa04788..4c997ee 100644 |
| 51 | --- a/support/misc/xstat.c |
| 52 | +++ b/support/misc/xstat.c |
| 53 | @@ -1,3 +1,7 @@ |
| 54 | +#ifdef HAVE_CONFIG_H |
| 55 | +#include <config.h> |
| 56 | +#endif |
| 57 | + |
| 58 | #include <errno.h> |
| 59 | #include <sys/types.h> |
| 60 | #include <fcntl.h> |
| 61 | @@ -5,7 +9,6 @@ |
| 62 | #include <sys/sysmacros.h> |
| 63 | #include <unistd.h> |
| 64 | |
| 65 | -#include "config.h" |
| 66 | #include "xstat.h" |
| 67 | |
| 68 | #ifdef HAVE_FSTATAT |
| 69 | diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c |
| 70 | index b6400be..6ba8a35 100644 |
| 71 | --- a/support/nfs/conffile.c |
| 72 | +++ b/support/nfs/conffile.c |
| 73 | @@ -500,7 +500,7 @@ conf_readfile(const char *path) |
| 74 | |
| 75 | if ((stat (path, &sb) == 0) || (errno != ENOENT)) { |
| 76 | char *new_conf_addr = NULL; |
| 77 | - size_t sz = sb.st_size; |
| 78 | + off_t sz; |
| 79 | int fd = open (path, O_RDONLY, 0); |
| 80 | |
| 81 | if (fd == -1) { |
| 82 | @@ -517,6 +517,11 @@ conf_readfile(const char *path) |
| 83 | |
| 84 | /* only after we have the lock, check the file size ready to read it */ |
| 85 | sz = lseek(fd, 0, SEEK_END); |
| 86 | + if (sz < 0) { |
| 87 | + xlog_warn("conf_readfile: unable to determine file size: %s", |
| 88 | + strerror(errno)); |
| 89 | + goto fail; |
| 90 | + } |
| 91 | lseek(fd, 0, SEEK_SET); |
| 92 | |
| 93 | new_conf_addr = malloc(sz+1); |
| 94 | @@ -2162,6 +2167,7 @@ conf_write(const char *filename, const char *section, const char *arg, |
| 95 | ret = 0; |
| 96 | |
| 97 | cleanup: |
| 98 | + flush_outqueue(&inqueue, NULL); |
| 99 | flush_outqueue(&outqueue, NULL); |
| 100 | |
| 101 | if (buff) |
| 102 | diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c |
| 103 | index e811703..f5f9b10 100644 |
| 104 | --- a/utils/blkmapd/device-discovery.c |
| 105 | +++ b/utils/blkmapd/device-discovery.c |
| 106 | @@ -26,6 +26,10 @@ |
| 107 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 108 | */ |
| 109 | |
| 110 | +#ifdef HAVE_CONFIG_H |
| 111 | +#include "config.h" |
| 112 | +#endif /* HAVE_CONFIG_H */ |
| 113 | + |
| 114 | #include <sys/sysmacros.h> |
| 115 | #include <sys/types.h> |
| 116 | #include <sys/stat.h> |
| 117 | @@ -51,10 +55,6 @@ |
| 118 | #include <errno.h> |
| 119 | #include <libdevmapper.h> |
| 120 | |
| 121 | -#ifdef HAVE_CONFIG_H |
| 122 | -#include "config.h" |
| 123 | -#endif /* HAVE_CONFIG_H */ |
| 124 | - |
| 125 | #include "device-discovery.h" |
| 126 | #include "xcommon.h" |
| 127 | #include "nfslib.h" |
| 128 | diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c |
| 129 | index 62e37b8..267acea 100644 |
| 130 | --- a/utils/idmapd/idmapd.c |
| 131 | +++ b/utils/idmapd/idmapd.c |
| 132 | @@ -34,6 +34,10 @@ |
| 133 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 134 | */ |
| 135 | |
| 136 | +#ifdef HAVE_CONFIG_H |
| 137 | +#include "config.h" |
| 138 | +#endif /* HAVE_CONFIG_H */ |
| 139 | + |
| 140 | #include <sys/types.h> |
| 141 | #include <sys/time.h> |
| 142 | #include <sys/inotify.h> |
| 143 | @@ -62,10 +66,6 @@ |
| 144 | #include <libgen.h> |
| 145 | #include <nfsidmap.h> |
| 146 | |
| 147 | -#ifdef HAVE_CONFIG_H |
| 148 | -#include "config.h" |
| 149 | -#endif /* HAVE_CONFIG_H */ |
| 150 | - |
| 151 | #include "xlog.h" |
| 152 | #include "conffile.h" |
| 153 | #include "queue.h" |
| 154 | -- |
| 155 | 2.7.4 |
| 156 | |