]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
7603eb680dcd369d148ee282b16d1d61224050db
[thirdparty/openembedded/openembedded-core-contrib.git] /
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
5
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
17
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.
21
22 Upstream-Status: Submitted [https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
23
24 Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
25
26 Rebase it.
27
28 Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
29 ---
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(-)
35
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
40 @@ -1,7 +1,7 @@
41 ## Process this file with automake to produce Makefile.in
42
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
47
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
53 +++ /dev/null
54 @@ -1,115 +0,0 @@
55 -/*
56 - * Copyright 2009 Oracle. All rights reserved.
57 - * Copyright 2017 Red Hat, Inc. All rights reserved.
58 - *
59 - * This file is part of nfs-utils.
60 - *
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.
65 - *
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.
70 - *
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/>.
73 - */
74 -
75 -#ifdef HAVE_CONFIG_H
76 -#include <config.h>
77 -#endif
78 -
79 -#include <sys/stat.h>
80 -
81 -#include <string.h>
82 -#include <libgen.h>
83 -#include <stdio.h>
84 -#include <errno.h>
85 -#include <dirent.h>
86 -#include <stdlib.h>
87 -#include <stdbool.h>
88 -#include <limits.h>
89 -
90 -#include "xlog.h"
91 -#include "misc.h"
92 -
93 -/*
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).
97 - */
98 -__attribute__((__malloc__))
99 -char *
100 -generic_make_pathname(const char *base, const char *leaf)
101 -{
102 - size_t size;
103 - char *path;
104 - int len;
105 -
106 - size = strlen(base) + strlen(leaf) + 2;
107 - if (size > PATH_MAX)
108 - return NULL;
109 -
110 - path = malloc(size);
111 - if (path == NULL)
112 - return NULL;
113 -
114 - len = snprintf(path, size, "%s/%s", base, leaf);
115 - if ((len < 0) || ((size_t)len >= size)) {
116 - free(path);
117 - return NULL;
118 - }
119 -
120 - return path;
121 -}
122 -
123 -
124 -/**
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
130 - *
131 - * This runs before logging is set up, so error messages are directed
132 - * to stderr.
133 - *
134 - * Returns true and sets up our basedir, if @parentdir was valid
135 - * and usable; otherwise false is returned.
136 - */
137 -_Bool
138 -generic_setup_basedir(const char *progname, const char *parentdir, char *base,
139 - const size_t baselen)
140 -{
141 - static char buf[PATH_MAX];
142 - struct stat st;
143 - char *path;
144 -
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);
149 - return false;
150 - }
151 - if (lstat(parentdir, &st) == -1) {
152 - (void)fprintf(stderr, "%s: Failed to stat %s: %s",
153 - progname, parentdir, strerror(errno));
154 - return false;
155 - }
156 -
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);
163 - return false;
164 - }
165 -
166 - xlog(D_CALL, "Using %s as the state directory", parentdir);
167 - strcpy(base, parentdir);
168 - return true;
169 -}
170 diff --git a/support/misc/misc.c b/support/misc/misc.c
171 new file mode 100644
172 index 0000000..e7c3819
173 --- /dev/null
174 +++ b/support/misc/misc.c
175 @@ -0,0 +1,111 @@
176 +/*
177 + * Copyright 2009 Oracle. All rights reserved.
178 + * Copyright 2017 Red Hat, Inc. All rights reserved.
179 + *
180 + * This file is part of nfs-utils.
181 + *
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.
186 + *
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.
191 + *
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/>.
194 + */
195 +
196 +#include <sys/stat.h>
197 +
198 +#include <string.h>
199 +#include <libgen.h>
200 +#include <stdio.h>
201 +#include <errno.h>
202 +#include <dirent.h>
203 +#include <stdlib.h>
204 +#include <stdbool.h>
205 +#include <limits.h>
206 +
207 +#include "xlog.h"
208 +#include "misc.h"
209 +
210 +/*
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).
214 + */
215 +__attribute__((__malloc__))
216 +char *
217 +generic_make_pathname(const char *base, const char *leaf)
218 +{
219 + size_t size;
220 + char *path;
221 + int len;
222 +
223 + size = strlen(base) + strlen(leaf) + 2;
224 + if (size > PATH_MAX)
225 + return NULL;
226 +
227 + path = malloc(size);
228 + if (path == NULL)
229 + return NULL;
230 +
231 + len = snprintf(path, size, "%s/%s", base, leaf);
232 + if ((len < 0) || ((size_t)len >= size)) {
233 + free(path);
234 + return NULL;
235 + }
236 +
237 + return path;
238 +}
239 +
240 +
241 +/**
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
247 + *
248 + * This runs before logging is set up, so error messages are directed
249 + * to stderr.
250 + *
251 + * Returns true and sets up our basedir, if @parentdir was valid
252 + * and usable; otherwise false is returned.
253 + */
254 +_Bool
255 +generic_setup_basedir(const char *progname, const char *parentdir, char *base,
256 + const size_t baselen)
257 +{
258 + static char buf[PATH_MAX];
259 + struct stat st;
260 + char *path;
261 +
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);
266 + return false;
267 + }
268 + if (lstat(parentdir, &st) == -1) {
269 + (void)fprintf(stderr, "%s: Failed to stat %s: %s",
270 + progname, parentdir, strerror(errno));
271 + return false;
272 + }
273 +
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);
280 + return false;
281 + }
282 +
283 + xlog(D_CALL, "Using %s as the state directory", parentdir);
284 + strcpy(base, parentdir);
285 + return true;
286 +}
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
293
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
297
298 BUILT_SOURCES = $(GENFILES)
299