1 From 690a90a5b7786e40b5447ad7c5f19a7657d27405 Mon Sep 17 00:00:00 2001
2 From: Mingli Yu <Mingli.Yu@windriver.com>
3 Date: Fri, 14 Dec 2018 17:44:32 +0800
4 Subject: [PATCH] Makefile.am: fix undefined function for libnsm.a
6 The source file of libnsm.a uses some function
7 in ../support/misc/file.c, add ../support/misc/file.c
8 to libnsm_a_SOURCES to fix build error when run
9 "make -C tests statdb_dump":
10 | ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
11 | /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
12 | /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
13 | /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:175: undefined reference to `generic_make_pathname'
14 | ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
15 | /usr/src/debug/nfs-utils/2.3.3-r0/nfs-utils-2.3.3/support/nsm/file.c:280: undefined reference to `generic_setup_basedir'
16 | collect2: error: ld returned 1 exit status
18 As there is already one source file named file.c
19 as support/nsm/file.c in support/nsm/Makefile.am,
20 so rename ../support/misc/file.c to ../support/misc/misc.c.
22 Upstream-Status: Submitted[https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
24 Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
28 Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
30 support/misc/Makefile.am | 2 +-
31 support/misc/file.c | 115 ---------------------------------------------------------------------------------------------------------------
32 support/misc/misc.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 support/nsm/Makefile.am | 2 +-
34 4 files changed, 113 insertions(+), 117 deletions(-)
36 diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
37 index f9993e3..8b0e9db 100644
38 --- a/support/misc/Makefile.am
39 +++ b/support/misc/Makefile.am
41 ## Process this file with automake to produce Makefile.in
43 noinst_LIBRARIES = libmisc.a
44 -libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c \
45 +libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c \
46 nfsd_path.c workqueue.c xstat.c
48 MAINTAINERCLEANFILES = Makefile.in
49 diff --git a/support/misc/file.c b/support/misc/file.c
50 deleted file mode 100644
51 index 06f6bb2..0000000
52 --- a/support/misc/file.c
56 - * Copyright 2009 Oracle. All rights reserved.
57 - * Copyright 2017 Red Hat, Inc. All rights reserved.
59 - * This file is part of nfs-utils.
61 - * nfs-utils is free software; you can redistribute it and/or modify
62 - * it under the terms of the GNU General Public License as published by
63 - * the Free Software Foundation; either version 2 of the License, or
64 - * (at your option) any later version.
66 - * nfs-utils is distributed in the hope that it will be useful,
67 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
68 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69 - * GNU General Public License for more details.
71 - * You should have received a copy of the GNU General Public License
72 - * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>.
79 -#include <sys/stat.h>
94 - * Returns a dynamically allocated, '\0'-terminated buffer
95 - * containing an appropriate pathname, or NULL if an error
96 - * occurs. Caller must free the returned result with free(3).
98 -__attribute__((__malloc__))
100 -generic_make_pathname(const char *base, const char *leaf)
106 - size = strlen(base) + strlen(leaf) + 2;
107 - if (size > PATH_MAX)
110 - path = malloc(size);
114 - len = snprintf(path, size, "%s/%s", base, leaf);
115 - if ((len < 0) || ((size_t)len >= size)) {
125 - * generic_setup_basedir - set up basedir
126 - * @progname: C string containing name of program, for error messages
127 - * @parentdir: C string containing pathname to on-disk state, or NULL
128 - * @base: character buffer to contain the basedir that is set up
129 - * @baselen: size of @base in bytes
131 - * This runs before logging is set up, so error messages are directed
134 - * Returns true and sets up our basedir, if @parentdir was valid
135 - * and usable; otherwise false is returned.
138 -generic_setup_basedir(const char *progname, const char *parentdir, char *base,
139 - const size_t baselen)
141 - static char buf[PATH_MAX];
145 - /* First: test length of name and whether it exists */
146 - if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
147 - (void)fprintf(stderr, "%s: Directory name too long: %s",
148 - progname, parentdir);
151 - if (lstat(parentdir, &st) == -1) {
152 - (void)fprintf(stderr, "%s: Failed to stat %s: %s",
153 - progname, parentdir, strerror(errno));
157 - /* Ensure we have a clean directory pathname */
158 - strncpy(buf, parentdir, sizeof(buf)-1);
159 - path = dirname(buf);
160 - if (*path == '.') {
161 - (void)fprintf(stderr, "%s: Unusable directory %s",
162 - progname, parentdir);
166 - xlog(D_CALL, "Using %s as the state directory", parentdir);
167 - strcpy(base, parentdir);
170 diff --git a/support/misc/misc.c b/support/misc/misc.c
172 index 0000000..e7c3819
174 +++ b/support/misc/misc.c
177 + * Copyright 2009 Oracle. All rights reserved.
178 + * Copyright 2017 Red Hat, Inc. All rights reserved.
180 + * This file is part of nfs-utils.
182 + * nfs-utils is free software; you can redistribute it and/or modify
183 + * it under the terms of the GNU General Public License as published by
184 + * the Free Software Foundation; either version 2 of the License, or
185 + * (at your option) any later version.
187 + * nfs-utils is distributed in the hope that it will be useful,
188 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
189 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
190 + * GNU General Public License for more details.
192 + * You should have received a copy of the GNU General Public License
193 + * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>.
196 +#include <sys/stat.h>
204 +#include <stdbool.h>
211 + * Returns a dynamically allocated, '\0'-terminated buffer
212 + * containing an appropriate pathname, or NULL if an error
213 + * occurs. Caller must free the returned result with free(3).
215 +__attribute__((__malloc__))
217 +generic_make_pathname(const char *base, const char *leaf)
223 + size = strlen(base) + strlen(leaf) + 2;
224 + if (size > PATH_MAX)
227 + path = malloc(size);
231 + len = snprintf(path, size, "%s/%s", base, leaf);
232 + if ((len < 0) || ((size_t)len >= size)) {
242 + * generic_setup_basedir - set up basedir
243 + * @progname: C string containing name of program, for error messages
244 + * @parentdir: C string containing pathname to on-disk state, or NULL
245 + * @base: character buffer to contain the basedir that is set up
246 + * @baselen: size of @base in bytes
248 + * This runs before logging is set up, so error messages are directed
251 + * Returns true and sets up our basedir, if @parentdir was valid
252 + * and usable; otherwise false is returned.
255 +generic_setup_basedir(const char *progname, const char *parentdir, char *base,
256 + const size_t baselen)
258 + static char buf[PATH_MAX];
262 + /* First: test length of name and whether it exists */
263 + if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
264 + (void)fprintf(stderr, "%s: Directory name too long: %s",
265 + progname, parentdir);
268 + if (lstat(parentdir, &st) == -1) {
269 + (void)fprintf(stderr, "%s: Failed to stat %s: %s",
270 + progname, parentdir, strerror(errno));
274 + /* Ensure we have a clean directory pathname */
275 + strncpy(buf, parentdir, sizeof(buf)-1);
276 + path = dirname(buf);
277 + if (*path == '.') {
278 + (void)fprintf(stderr, "%s: Unusable directory %s",
279 + progname, parentdir);
283 + xlog(D_CALL, "Using %s as the state directory", parentdir);
284 + strcpy(base, parentdir);
287 diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
288 index 8f5874e..68f1a46 100644
289 --- a/support/nsm/Makefile.am
290 +++ b/support/nsm/Makefile.am
291 @@ -10,7 +10,7 @@ GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
292 EXTRA_DIST = sm_inter.x
294 noinst_LIBRARIES = libnsm.a
295 -libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
296 +libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
298 BUILT_SOURCES = $(GENFILES)