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>
26 support/misc/Makefile.am | 2 +-
27 support/misc/file.c | 111 -----------------------------------------------
28 support/misc/misc.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++
29 support/nsm/Makefile.am | 2 +-
30 4 files changed, 113 insertions(+), 113 deletions(-)
31 delete mode 100644 support/misc/file.c
32 create mode 100644 support/misc/misc.c
34 diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
35 index 8936b0d..d4c1f76 100644
36 --- a/support/misc/Makefile.am
37 +++ b/support/misc/Makefile.am
39 ## Process this file with automake to produce Makefile.in
41 noinst_LIBRARIES = libmisc.a
42 -libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c
43 +libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c
45 MAINTAINERCLEANFILES = Makefile.in
46 diff --git a/support/misc/file.c b/support/misc/file.c
47 deleted file mode 100644
48 index e7c3819..0000000
49 --- a/support/misc/file.c
53 - * Copyright 2009 Oracle. All rights reserved.
54 - * Copyright 2017 Red Hat, Inc. All rights reserved.
56 - * This file is part of nfs-utils.
58 - * nfs-utils is free software; you can redistribute it and/or modify
59 - * it under the terms of the GNU General Public License as published by
60 - * the Free Software Foundation; either version 2 of the License, or
61 - * (at your option) any later version.
63 - * nfs-utils is distributed in the hope that it will be useful,
64 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
65 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66 - * GNU General Public License for more details.
68 - * You should have received a copy of the GNU General Public License
69 - * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>.
72 -#include <sys/stat.h>
87 - * Returns a dynamically allocated, '\0'-terminated buffer
88 - * containing an appropriate pathname, or NULL if an error
89 - * occurs. Caller must free the returned result with free(3).
91 -__attribute__((__malloc__))
93 -generic_make_pathname(const char *base, const char *leaf)
99 - size = strlen(base) + strlen(leaf) + 2;
100 - if (size > PATH_MAX)
103 - path = malloc(size);
107 - len = snprintf(path, size, "%s/%s", base, leaf);
108 - if ((len < 0) || ((size_t)len >= size)) {
118 - * generic_setup_basedir - set up basedir
119 - * @progname: C string containing name of program, for error messages
120 - * @parentdir: C string containing pathname to on-disk state, or NULL
121 - * @base: character buffer to contain the basedir that is set up
122 - * @baselen: size of @base in bytes
124 - * This runs before logging is set up, so error messages are directed
127 - * Returns true and sets up our basedir, if @parentdir was valid
128 - * and usable; otherwise false is returned.
131 -generic_setup_basedir(const char *progname, const char *parentdir, char *base,
132 - const size_t baselen)
134 - static char buf[PATH_MAX];
138 - /* First: test length of name and whether it exists */
139 - if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
140 - (void)fprintf(stderr, "%s: Directory name too long: %s",
141 - progname, parentdir);
144 - if (lstat(parentdir, &st) == -1) {
145 - (void)fprintf(stderr, "%s: Failed to stat %s: %s",
146 - progname, parentdir, strerror(errno));
150 - /* Ensure we have a clean directory pathname */
151 - strncpy(buf, parentdir, sizeof(buf)-1);
152 - path = dirname(buf);
153 - if (*path == '.') {
154 - (void)fprintf(stderr, "%s: Unusable directory %s",
155 - progname, parentdir);
159 - xlog(D_CALL, "Using %s as the state directory", parentdir);
160 - strcpy(base, parentdir);
163 diff --git a/support/misc/misc.c b/support/misc/misc.c
165 index 0000000..e7c3819
167 +++ b/support/misc/misc.c
170 + * Copyright 2009 Oracle. All rights reserved.
171 + * Copyright 2017 Red Hat, Inc. All rights reserved.
173 + * This file is part of nfs-utils.
175 + * nfs-utils is free software; you can redistribute it and/or modify
176 + * it under the terms of the GNU General Public License as published by
177 + * the Free Software Foundation; either version 2 of the License, or
178 + * (at your option) any later version.
180 + * nfs-utils is distributed in the hope that it will be useful,
181 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
182 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183 + * GNU General Public License for more details.
185 + * You should have received a copy of the GNU General Public License
186 + * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>.
189 +#include <sys/stat.h>
197 +#include <stdbool.h>
204 + * Returns a dynamically allocated, '\0'-terminated buffer
205 + * containing an appropriate pathname, or NULL if an error
206 + * occurs. Caller must free the returned result with free(3).
208 +__attribute__((__malloc__))
210 +generic_make_pathname(const char *base, const char *leaf)
216 + size = strlen(base) + strlen(leaf) + 2;
217 + if (size > PATH_MAX)
220 + path = malloc(size);
224 + len = snprintf(path, size, "%s/%s", base, leaf);
225 + if ((len < 0) || ((size_t)len >= size)) {
235 + * generic_setup_basedir - set up basedir
236 + * @progname: C string containing name of program, for error messages
237 + * @parentdir: C string containing pathname to on-disk state, or NULL
238 + * @base: character buffer to contain the basedir that is set up
239 + * @baselen: size of @base in bytes
241 + * This runs before logging is set up, so error messages are directed
244 + * Returns true and sets up our basedir, if @parentdir was valid
245 + * and usable; otherwise false is returned.
248 +generic_setup_basedir(const char *progname, const char *parentdir, char *base,
249 + const size_t baselen)
251 + static char buf[PATH_MAX];
255 + /* First: test length of name and whether it exists */
256 + if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
257 + (void)fprintf(stderr, "%s: Directory name too long: %s",
258 + progname, parentdir);
261 + if (lstat(parentdir, &st) == -1) {
262 + (void)fprintf(stderr, "%s: Failed to stat %s: %s",
263 + progname, parentdir, strerror(errno));
267 + /* Ensure we have a clean directory pathname */
268 + strncpy(buf, parentdir, sizeof(buf)-1);
269 + path = dirname(buf);
270 + if (*path == '.') {
271 + (void)fprintf(stderr, "%s: Unusable directory %s",
272 + progname, parentdir);
276 + xlog(D_CALL, "Using %s as the state directory", parentdir);
277 + strcpy(base, parentdir);
280 diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
281 index 8f5874e..68f1a46 100644
282 --- a/support/nsm/Makefile.am
283 +++ b/support/nsm/Makefile.am
284 @@ -10,7 +10,7 @@ GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
285 EXTRA_DIST = sm_inter.x
287 noinst_LIBRARIES = libnsm.a
288 -libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
289 +libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
291 BUILT_SOURCES = $(GENFILES)