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 | 111 ---------------------------------------------------------------------------------------------------------------
32 support/misc/misc.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 support/nsm/Makefile.am | 2 +-
34 4 files changed, 113 insertions(+), 113 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 e7c3819..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/>.
75 -#include <sys/stat.h>
90 - * Returns a dynamically allocated, '\0'-terminated buffer
91 - * containing an appropriate pathname, or NULL if an error
92 - * occurs. Caller must free the returned result with free(3).
94 -__attribute__((__malloc__))
96 -generic_make_pathname(const char *base, const char *leaf)
102 - size = strlen(base) + strlen(leaf) + 2;
103 - if (size > PATH_MAX)
106 - path = malloc(size);
110 - len = snprintf(path, size, "%s/%s", base, leaf);
111 - if ((len < 0) || ((size_t)len >= size)) {
121 - * generic_setup_basedir - set up basedir
122 - * @progname: C string containing name of program, for error messages
123 - * @parentdir: C string containing pathname to on-disk state, or NULL
124 - * @base: character buffer to contain the basedir that is set up
125 - * @baselen: size of @base in bytes
127 - * This runs before logging is set up, so error messages are directed
130 - * Returns true and sets up our basedir, if @parentdir was valid
131 - * and usable; otherwise false is returned.
134 -generic_setup_basedir(const char *progname, const char *parentdir, char *base,
135 - const size_t baselen)
137 - static char buf[PATH_MAX];
141 - /* First: test length of name and whether it exists */
142 - if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
143 - (void)fprintf(stderr, "%s: Directory name too long: %s",
144 - progname, parentdir);
147 - if (lstat(parentdir, &st) == -1) {
148 - (void)fprintf(stderr, "%s: Failed to stat %s: %s",
149 - progname, parentdir, strerror(errno));
153 - /* Ensure we have a clean directory pathname */
154 - strncpy(buf, parentdir, sizeof(buf)-1);
155 - path = dirname(buf);
156 - if (*path == '.') {
157 - (void)fprintf(stderr, "%s: Unusable directory %s",
158 - progname, parentdir);
162 - xlog(D_CALL, "Using %s as the state directory", parentdir);
163 - strcpy(base, parentdir);
166 diff --git a/support/misc/misc.c b/support/misc/misc.c
168 index 0000000..e7c3819
170 +++ b/support/misc/misc.c
173 + * Copyright 2009 Oracle. All rights reserved.
174 + * Copyright 2017 Red Hat, Inc. All rights reserved.
176 + * This file is part of nfs-utils.
178 + * nfs-utils is free software; you can redistribute it and/or modify
179 + * it under the terms of the GNU General Public License as published by
180 + * the Free Software Foundation; either version 2 of the License, or
181 + * (at your option) any later version.
183 + * nfs-utils is distributed in the hope that it will be useful,
184 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
185 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
186 + * GNU General Public License for more details.
188 + * You should have received a copy of the GNU General Public License
189 + * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>.
192 +#include <sys/stat.h>
200 +#include <stdbool.h>
207 + * Returns a dynamically allocated, '\0'-terminated buffer
208 + * containing an appropriate pathname, or NULL if an error
209 + * occurs. Caller must free the returned result with free(3).
211 +__attribute__((__malloc__))
213 +generic_make_pathname(const char *base, const char *leaf)
219 + size = strlen(base) + strlen(leaf) + 2;
220 + if (size > PATH_MAX)
223 + path = malloc(size);
227 + len = snprintf(path, size, "%s/%s", base, leaf);
228 + if ((len < 0) || ((size_t)len >= size)) {
238 + * generic_setup_basedir - set up basedir
239 + * @progname: C string containing name of program, for error messages
240 + * @parentdir: C string containing pathname to on-disk state, or NULL
241 + * @base: character buffer to contain the basedir that is set up
242 + * @baselen: size of @base in bytes
244 + * This runs before logging is set up, so error messages are directed
247 + * Returns true and sets up our basedir, if @parentdir was valid
248 + * and usable; otherwise false is returned.
251 +generic_setup_basedir(const char *progname, const char *parentdir, char *base,
252 + const size_t baselen)
254 + static char buf[PATH_MAX];
258 + /* First: test length of name and whether it exists */
259 + if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
260 + (void)fprintf(stderr, "%s: Directory name too long: %s",
261 + progname, parentdir);
264 + if (lstat(parentdir, &st) == -1) {
265 + (void)fprintf(stderr, "%s: Failed to stat %s: %s",
266 + progname, parentdir, strerror(errno));
270 + /* Ensure we have a clean directory pathname */
271 + strncpy(buf, parentdir, sizeof(buf)-1);
272 + path = dirname(buf);
273 + if (*path == '.') {
274 + (void)fprintf(stderr, "%s: Unusable directory %s",
275 + progname, parentdir);
279 + xlog(D_CALL, "Using %s as the state directory", parentdir);
280 + strcpy(base, parentdir);
283 diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
284 index 8f5874e..68f1a46 100644
285 --- a/support/nsm/Makefile.am
286 +++ b/support/nsm/Makefile.am
287 @@ -10,7 +10,7 @@ GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
288 EXTRA_DIST = sm_inter.x
290 noinst_LIBRARIES = libnsm.a
291 -libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
292 +libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
294 BUILT_SOURCES = $(GENFILES)