]> code.ossystems Code Review - openembedded-core.git/blob
fcb0e99b3329c2ce0883d0f5eecfe2fb4d4840bb
[openembedded-core.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      | 111 ---------------------------------------------------------------------------------------------------------------
32  support/misc/misc.c      | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33  support/nsm/Makefile.am  |   2 +-
34  4 files changed, 113 insertions(+), 113 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 e7c3819..0000000
52 --- a/support/misc/file.c
53 +++ /dev/null
54 @@ -1,111 +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 -#include <sys/stat.h>
76 -
77 -#include <string.h>
78 -#include <libgen.h>
79 -#include <stdio.h>
80 -#include <errno.h>
81 -#include <dirent.h>
82 -#include <stdlib.h>
83 -#include <stdbool.h>
84 -#include <limits.h>
85 -
86 -#include "xlog.h"
87 -#include "misc.h"
88 -
89 -/*
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).
93 - */
94 -__attribute__((__malloc__))
95 -char *
96 -generic_make_pathname(const char *base, const char *leaf)
97 -{
98 -       size_t size;
99 -       char *path;
100 -       int len;
101 -
102 -       size = strlen(base) + strlen(leaf) + 2;
103 -       if (size > PATH_MAX)
104 -               return NULL;
105 -
106 -       path = malloc(size);
107 -       if (path == NULL)
108 -               return NULL;
109 -
110 -       len = snprintf(path, size, "%s/%s", base, leaf);
111 -       if ((len < 0) || ((size_t)len >= size)) {
112 -               free(path);
113 -               return NULL;
114 -       }
115 -
116 -       return path;
117 -}
118 -
119 -
120 -/**
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
126 - *
127 - * This runs before logging is set up, so error messages are directed
128 - * to stderr.
129 - *
130 - * Returns true and sets up our basedir, if @parentdir was valid
131 - * and usable; otherwise false is returned.
132 - */
133 -_Bool
134 -generic_setup_basedir(const char *progname, const char *parentdir, char *base,
135 -                     const size_t baselen)
136 -{
137 -       static char buf[PATH_MAX];
138 -       struct stat st;
139 -       char *path;
140 -
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);
145 -               return false;
146 -       }
147 -       if (lstat(parentdir, &st) == -1) {
148 -               (void)fprintf(stderr, "%s: Failed to stat %s: %s",
149 -                               progname, parentdir, strerror(errno));
150 -               return false;
151 -       }
152 -
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);
159 -               return false;
160 -       }
161 -
162 -       xlog(D_CALL, "Using %s as the state directory", parentdir);
163 -       strcpy(base, parentdir);
164 -       return true;
165 -}
166 diff --git a/support/misc/misc.c b/support/misc/misc.c
167 new file mode 100644
168 index 0000000..e7c3819
169 --- /dev/null
170 +++ b/support/misc/misc.c
171 @@ -0,0 +1,111 @@
172 +/*
173 + * Copyright 2009 Oracle.  All rights reserved.
174 + * Copyright 2017 Red Hat, Inc.  All rights reserved.
175 + *
176 + * This file is part of nfs-utils.
177 + *
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.
182 + *
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.
187 + *
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/>.
190 + */
191 +
192 +#include <sys/stat.h>
193 +
194 +#include <string.h>
195 +#include <libgen.h>
196 +#include <stdio.h>
197 +#include <errno.h>
198 +#include <dirent.h>
199 +#include <stdlib.h>
200 +#include <stdbool.h>
201 +#include <limits.h>
202 +
203 +#include "xlog.h"
204 +#include "misc.h"
205 +
206 +/*
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).
210 + */
211 +__attribute__((__malloc__))
212 +char *
213 +generic_make_pathname(const char *base, const char *leaf)
214 +{
215 +       size_t size;
216 +       char *path;
217 +       int len;
218 +
219 +       size = strlen(base) + strlen(leaf) + 2;
220 +       if (size > PATH_MAX)
221 +               return NULL;
222 +
223 +       path = malloc(size);
224 +       if (path == NULL)
225 +               return NULL;
226 +
227 +       len = snprintf(path, size, "%s/%s", base, leaf);
228 +       if ((len < 0) || ((size_t)len >= size)) {
229 +               free(path);
230 +               return NULL;
231 +       }
232 +
233 +       return path;
234 +}
235 +
236 +
237 +/**
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
243 + *
244 + * This runs before logging is set up, so error messages are directed
245 + * to stderr.
246 + *
247 + * Returns true and sets up our basedir, if @parentdir was valid
248 + * and usable; otherwise false is returned.
249 + */
250 +_Bool
251 +generic_setup_basedir(const char *progname, const char *parentdir, char *base,
252 +                     const size_t baselen)
253 +{
254 +       static char buf[PATH_MAX];
255 +       struct stat st;
256 +       char *path;
257 +
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);
262 +               return false;
263 +       }
264 +       if (lstat(parentdir, &st) == -1) {
265 +               (void)fprintf(stderr, "%s: Failed to stat %s: %s",
266 +                               progname, parentdir, strerror(errno));
267 +               return false;
268 +       }
269 +
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);
276 +               return false;
277 +       }
278 +
279 +       xlog(D_CALL, "Using %s as the state directory", parentdir);
280 +       strcpy(base, parentdir);
281 +       return true;
282 +}
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
289  
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
293  
294  BUILT_SOURCES = $(GENFILES)
295