Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,299 @@
From 690a90a5b7786e40b5447ad7c5f19a7657d27405 Mon Sep 17 00:00:00 2001
From: Mingli Yu <Mingli.Yu@windriver.com>
Date: Fri, 14 Dec 2018 17:44:32 +0800
Subject: [PATCH] Makefile.am: fix undefined function for libnsm.a
The source file of libnsm.a uses some function
in ../support/misc/file.c, add ../support/misc/file.c
to libnsm_a_SOURCES to fix build error when run
"make -C tests statdb_dump":
| ../support/nsm/libnsm.a(file.o): In function `nsm_make_pathname':
| /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'
| /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'
| /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'
| ../support/nsm/libnsm.a(file.o): In function `nsm_setup_pathnames':
| /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'
| collect2: error: ld returned 1 exit status
As there is already one source file named file.c
as support/nsm/file.c in support/nsm/Makefile.am,
so rename ../support/misc/file.c to ../support/misc/misc.c.
Upstream-Status: Submitted [https://marc.info/?l=linux-nfs&m=154502780423058&w=2]
Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
Rebase it.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
support/misc/Makefile.am | 2 +-
support/misc/file.c | 115 ---------------------------------------------------------------------------------------------------------------
support/misc/misc.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
support/nsm/Makefile.am | 2 +-
4 files changed, 113 insertions(+), 117 deletions(-)
diff --git a/support/misc/Makefile.am b/support/misc/Makefile.am
index f9993e3..8b0e9db 100644
--- a/support/misc/Makefile.am
+++ b/support/misc/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = libmisc.a
-libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c file.c \
+libmisc_a_SOURCES = tcpwrapper.c from_local.c mountpoint.c misc.c \
nfsd_path.c workqueue.c xstat.c
MAINTAINERCLEANFILES = Makefile.in
diff --git a/support/misc/file.c b/support/misc/file.c
deleted file mode 100644
index 06f6bb2..0000000
--- a/support/misc/file.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2009 Oracle. All rights reserved.
- * Copyright 2017 Red Hat, Inc. All rights reserved.
- *
- * This file is part of nfs-utils.
- *
- * nfs-utils is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * nfs-utils is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys/stat.h>
-
-#include <string.h>
-#include <libgen.h>
-#include <stdio.h>
-#include <errno.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <limits.h>
-
-#include "xlog.h"
-#include "misc.h"
-
-/*
- * Returns a dynamically allocated, '\0'-terminated buffer
- * containing an appropriate pathname, or NULL if an error
- * occurs. Caller must free the returned result with free(3).
- */
-__attribute__((__malloc__))
-char *
-generic_make_pathname(const char *base, const char *leaf)
-{
- size_t size;
- char *path;
- int len;
-
- size = strlen(base) + strlen(leaf) + 2;
- if (size > PATH_MAX)
- return NULL;
-
- path = malloc(size);
- if (path == NULL)
- return NULL;
-
- len = snprintf(path, size, "%s/%s", base, leaf);
- if ((len < 0) || ((size_t)len >= size)) {
- free(path);
- return NULL;
- }
-
- return path;
-}
-
-
-/**
- * generic_setup_basedir - set up basedir
- * @progname: C string containing name of program, for error messages
- * @parentdir: C string containing pathname to on-disk state, or NULL
- * @base: character buffer to contain the basedir that is set up
- * @baselen: size of @base in bytes
- *
- * This runs before logging is set up, so error messages are directed
- * to stderr.
- *
- * Returns true and sets up our basedir, if @parentdir was valid
- * and usable; otherwise false is returned.
- */
-_Bool
-generic_setup_basedir(const char *progname, const char *parentdir, char *base,
- const size_t baselen)
-{
- static char buf[PATH_MAX];
- struct stat st;
- char *path;
-
- /* First: test length of name and whether it exists */
- if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
- (void)fprintf(stderr, "%s: Directory name too long: %s",
- progname, parentdir);
- return false;
- }
- if (lstat(parentdir, &st) == -1) {
- (void)fprintf(stderr, "%s: Failed to stat %s: %s",
- progname, parentdir, strerror(errno));
- return false;
- }
-
- /* Ensure we have a clean directory pathname */
- strncpy(buf, parentdir, sizeof(buf)-1);
- path = dirname(buf);
- if (*path == '.') {
- (void)fprintf(stderr, "%s: Unusable directory %s",
- progname, parentdir);
- return false;
- }
-
- xlog(D_CALL, "Using %s as the state directory", parentdir);
- strcpy(base, parentdir);
- return true;
-}
diff --git a/support/misc/misc.c b/support/misc/misc.c
new file mode 100644
index 0000000..e7c3819
--- /dev/null
+++ b/support/misc/misc.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2009 Oracle. All rights reserved.
+ * Copyright 2017 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of nfs-utils.
+ *
+ * nfs-utils is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * nfs-utils is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with nfs-utils. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/stat.h>
+
+#include <string.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <errno.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <limits.h>
+
+#include "xlog.h"
+#include "misc.h"
+
+/*
+ * Returns a dynamically allocated, '\0'-terminated buffer
+ * containing an appropriate pathname, or NULL if an error
+ * occurs. Caller must free the returned result with free(3).
+ */
+__attribute__((__malloc__))
+char *
+generic_make_pathname(const char *base, const char *leaf)
+{
+ size_t size;
+ char *path;
+ int len;
+
+ size = strlen(base) + strlen(leaf) + 2;
+ if (size > PATH_MAX)
+ return NULL;
+
+ path = malloc(size);
+ if (path == NULL)
+ return NULL;
+
+ len = snprintf(path, size, "%s/%s", base, leaf);
+ if ((len < 0) || ((size_t)len >= size)) {
+ free(path);
+ return NULL;
+ }
+
+ return path;
+}
+
+
+/**
+ * generic_setup_basedir - set up basedir
+ * @progname: C string containing name of program, for error messages
+ * @parentdir: C string containing pathname to on-disk state, or NULL
+ * @base: character buffer to contain the basedir that is set up
+ * @baselen: size of @base in bytes
+ *
+ * This runs before logging is set up, so error messages are directed
+ * to stderr.
+ *
+ * Returns true and sets up our basedir, if @parentdir was valid
+ * and usable; otherwise false is returned.
+ */
+_Bool
+generic_setup_basedir(const char *progname, const char *parentdir, char *base,
+ const size_t baselen)
+{
+ static char buf[PATH_MAX];
+ struct stat st;
+ char *path;
+
+ /* First: test length of name and whether it exists */
+ if ((strlen(parentdir) >= baselen) || (strlen(parentdir) >= PATH_MAX)) {
+ (void)fprintf(stderr, "%s: Directory name too long: %s",
+ progname, parentdir);
+ return false;
+ }
+ if (lstat(parentdir, &st) == -1) {
+ (void)fprintf(stderr, "%s: Failed to stat %s: %s",
+ progname, parentdir, strerror(errno));
+ return false;
+ }
+
+ /* Ensure we have a clean directory pathname */
+ strncpy(buf, parentdir, sizeof(buf)-1);
+ path = dirname(buf);
+ if (*path == '.') {
+ (void)fprintf(stderr, "%s: Unusable directory %s",
+ progname, parentdir);
+ return false;
+ }
+
+ xlog(D_CALL, "Using %s as the state directory", parentdir);
+ strcpy(base, parentdir);
+ return true;
+}
diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
index 8f5874e..68f1a46 100644
--- a/support/nsm/Makefile.am
+++ b/support/nsm/Makefile.am
@@ -10,7 +10,7 @@ GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
EXTRA_DIST = sm_inter.x
noinst_LIBRARIES = libnsm.a
-libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
+libnsm_a_SOURCES = $(GENFILES) ../misc/misc.c file.c rpc.c
BUILT_SOURCES = $(GENFILES)
@@ -0,0 +1,171 @@
From e89652b853ca7de671093ae44305fa3435e13d3d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 15 Dec 2022 13:29:43 -0800
Subject: [PATCH] Replace statfs64 with statfs
autoconf AC_SYS_LARGEFILE is used by configure to add needed defines
when needed for enabling 64bit off_t, therefore replacing statfs64 with
statfs should be functionally same. Additionally this helps compiling
with latest musl where 64bit LFS functions like statfs64 and friends are
now moved under _LARGEFILE64_SOURCE feature test macro, this works on
glibc systems because _GNU_SOURCE macros also enables
_LARGEFILE64_SOURCE indirectly. This is not case with musl and this
latest issue is exposed.
Upstream-Status: Submitted [https://lore.kernel.org/linux-nfs/20221215213605.4061853-1-raj.khem@gmail.com/T/#u]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
support/export/cache.c | 14 +++++++-------
support/include/nfsd_path.h | 6 +++---
support/misc/nfsd_path.c | 24 ++++++++++++------------
utils/exportfs/exportfs.c | 4 ++--
4 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/support/export/cache.c b/support/export/cache.c
index a5823e9..2497d4f 100644
--- a/support/export/cache.c
+++ b/support/export/cache.c
@@ -346,27 +346,27 @@ static int uuid_by_path(char *path, int type, size_t uuidlen, char *uuid)
/* Possible sources of uuid are
* - blkid uuid
- * - statfs64 uuid
+ * - statfs uuid
*
- * On some filesystems (e.g. vfat) the statfs64 uuid is simply an
+ * On some filesystems (e.g. vfat) the statfs uuid is simply an
* encoding of the device that the filesystem is mounted from, so
* it we be very bad to use that (as device numbers change). blkid
* must be preferred.
- * On other filesystems (e.g. btrfs) the statfs64 uuid contains
+ * On other filesystems (e.g. btrfs) the statfs uuid contains
* important info that the blkid uuid cannot contain: This happens
* when multiple subvolumes are exported (they have the same
- * blkid uuid but different statfs64 uuids).
+ * blkid uuid but different statfs uuids).
* We rely on get_uuid_blkdev *knowing* which is which and not returning
- * a uuid for filesystems where the statfs64 uuid is better.
+ * a uuid for filesystems where the statfs uuid is better.
*
*/
- struct statfs64 st;
+ struct statfs st;
char fsid_val[17];
const char *blkid_val = NULL;
const char *val;
int rc;
- rc = nfsd_path_statfs64(path, &st);
+ rc = nfsd_path_statfs(path, &st);
if (type == 0 && rc == 0) {
const unsigned long *bad;
diff --git a/support/include/nfsd_path.h b/support/include/nfsd_path.h
index 3b73aad..aa1e1dd 100644
--- a/support/include/nfsd_path.h
+++ b/support/include/nfsd_path.h
@@ -7,7 +7,7 @@
#include <sys/stat.h>
struct file_handle;
-struct statfs64;
+struct statfs;
void nfsd_path_init(void);
@@ -18,8 +18,8 @@ char * nfsd_path_prepend_dir(const char *dir, const char *pathname);
int nfsd_path_stat(const char *pathname, struct stat *statbuf);
int nfsd_path_lstat(const char *pathname, struct stat *statbuf);
-int nfsd_path_statfs64(const char *pathname,
- struct statfs64 *statbuf);
+int nfsd_path_statfs(const char *pathname,
+ struct statfs *statbuf);
char * nfsd_realpath(const char *path, char *resolved_path);
diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c
index 65e53c1..c3dea4f 100644
--- a/support/misc/nfsd_path.c
+++ b/support/misc/nfsd_path.c
@@ -184,46 +184,46 @@ nfsd_path_lstat(const char *pathname, struct stat *statbuf)
return nfsd_run_stat(nfsd_wq, nfsd_lstatfunc, pathname, statbuf);
}
-struct nfsd_statfs64_data {
+struct nfsd_statfs_data {
const char *pathname;
- struct statfs64 *statbuf;
+ struct statfs *statbuf;
int ret;
int err;
};
static void
-nfsd_statfs64func(void *data)
+nfsd_statfsfunc(void *data)
{
- struct nfsd_statfs64_data *d = data;
+ struct nfsd_statfs_data *d = data;
- d->ret = statfs64(d->pathname, d->statbuf);
+ d->ret = statfs(d->pathname, d->statbuf);
if (d->ret < 0)
d->err = errno;
}
static int
-nfsd_run_statfs64(struct xthread_workqueue *wq,
+nfsd_run_statfs(struct xthread_workqueue *wq,
const char *pathname,
- struct statfs64 *statbuf)
+ struct statfs *statbuf)
{
- struct nfsd_statfs64_data data = {
+ struct nfsd_statfs_data data = {
pathname,
statbuf,
0,
0
};
- xthread_work_run_sync(wq, nfsd_statfs64func, &data);
+ xthread_work_run_sync(wq, nfsd_statfsfunc, &data);
if (data.ret < 0)
errno = data.err;
return data.ret;
}
int
-nfsd_path_statfs64(const char *pathname, struct statfs64 *statbuf)
+nfsd_path_statfs(const char *pathname, struct statfs *statbuf)
{
if (!nfsd_wq)
- return statfs64(pathname, statbuf);
- return nfsd_run_statfs64(nfsd_wq, pathname, statbuf);
+ return statfs(pathname, statbuf);
+ return nfsd_run_statfs(nfsd_wq, pathname, statbuf);
}
struct nfsd_realpath_data {
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 0897b22..6d79a5b 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -513,7 +513,7 @@ validate_export(nfs_export *exp)
*/
struct stat stb;
char *path = exportent_realpath(&exp->m_export);
- struct statfs64 stf;
+ struct statfs stf;
int fs_has_fsid = 0;
if (stat(path, &stb) < 0) {
@@ -528,7 +528,7 @@ validate_export(nfs_export *exp)
if (!can_test())
return;
- if (!statfs64(path, &stf) &&
+ if (!statfs(path, &stf) &&
(stf.f_fsid.__val[0] || stf.f_fsid.__val[1]))
fs_has_fsid = 1;
@@ -0,0 +1,34 @@
From 887ecc7837962e9be77a4fea7d9122648f73a84a Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 15 Aug 2022 14:47:53 -0700
Subject: [PATCH] mountd: Check for return of stat function
simplify the check, stat() return 0 on success -1 on failure
Fixes clang reported errors e.g.
| v4clients.c:29:6: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses]
| if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
| ^ ~~
Upstream-Status: Submitted [https://patchwork.kernel.org/project/linux-nfs/patch/20220816024403.2694169-1-raj.khem@gmail.com/]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: Steve Dickson <steved@redhat.com>
---
support/export/v4clients.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/support/export/v4clients.c b/support/export/v4clients.c
index 5f15b61..3230251 100644
--- a/support/export/v4clients.c
+++ b/support/export/v4clients.c
@@ -26,7 +26,7 @@ void v4clients_init(void)
{
struct stat sb;
- if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
+ if (stat("/proc/fs/nfsd/clients", &sb) != 0 ||
!S_ISDIR(sb.st_mode))
return;
if (clients_fd >= 0)
@@ -0,0 +1,93 @@
From cf0ffbb5c8fa167376926d12a63613f15aa7602f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 15 Aug 2022 14:50:15 -0700
Subject: [PATCH] Fix function prototypes
Clang is now erroring out on functions with out parameter types
Fixes errors like
error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
Upstream-Status: Submitted [https://patchwork.kernel.org/project/linux-nfs/patch/20220816024403.2694169-2-raj.khem@gmail.com/]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
support/export/auth.c | 2 +-
support/export/v4root.c | 2 +-
support/export/xtab.c | 2 +-
utils/exportfs/exportfs.c | 4 ++--
utils/mount/network.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/support/export/auth.c b/support/export/auth.c
index 03ce4b8..2d7960f 100644
--- a/support/export/auth.c
+++ b/support/export/auth.c
@@ -82,7 +82,7 @@ check_useipaddr(void)
}
unsigned int
-auth_reload()
+auth_reload(void)
{
struct stat stb;
static ino_t last_inode;
diff --git a/support/export/v4root.c b/support/export/v4root.c
index c12a7d8..fbb0ad5 100644
--- a/support/export/v4root.c
+++ b/support/export/v4root.c
@@ -198,7 +198,7 @@ static int v4root_add_parents(nfs_export *exp)
* looking for components of the v4 mount.
*/
void
-v4root_set()
+v4root_set(void)
{
nfs_export *exp;
int i;
diff --git a/support/export/xtab.c b/support/export/xtab.c
index c888a80..e210ca9 100644
--- a/support/export/xtab.c
+++ b/support/export/xtab.c
@@ -135,7 +135,7 @@ xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
}
int
-xtab_export_write()
+xtab_export_write(void)
{
return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn, 1);
}
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 6ba615d..0897b22 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -69,14 +69,14 @@ static int _lockfd = -1;
* need these additional lockfile() routines.
*/
static void
-grab_lockfile()
+grab_lockfile(void)
{
_lockfd = open(lockfile, O_CREAT|O_RDWR, 0666);
if (_lockfd != -1)
lockf(_lockfd, F_LOCK, 0);
}
static void
-release_lockfile()
+release_lockfile(void)
{
if (_lockfd != -1) {
lockf(_lockfd, F_ULOCK, 0);
diff --git a/utils/mount/network.c b/utils/mount/network.c
index ed2f825..01ead49 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -179,7 +179,7 @@ static const unsigned long probe_mnt3_only[] = {
static const unsigned int *nfs_default_proto(void);
#ifdef MOUNT_CONFIG
-static const unsigned int *nfs_default_proto()
+static const unsigned int *nfs_default_proto(void)
{
extern unsigned long config_default_proto;
/*
@@ -0,0 +1,39 @@
From 398fed3bb0350cb1229e54e7020ae0e044c206d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20=C3=96lmann?= <u.oelmann@pengutronix.de>
Date: Wed, 17 Feb 2016 08:33:45 +0100
Subject: bugfix: adjust statd service name
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream uses 'rpc-statd.service' and Yocto introduced 'nfs-statd.service'
instead but forgot to update the mount.nfs helper 'start-statd' accordingly.
Upstream-Status: Inappropriate [other]
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Rebase it.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
utils/statd/start-statd | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/utils/statd/start-statd b/utils/statd/start-statd
index af5c950..df9b9be 100755
--- a/utils/statd/start-statd
+++ b/utils/statd/start-statd
@@ -28,10 +28,10 @@ fi
# First try systemd if it's installed.
if [ -d /run/systemd/system ]; then
# Quit only if the call worked.
- if systemctl start rpc-statd.service; then
+ if systemctl start nfs-statd.service; then
# Ensure systemd knows not to stop rpc.statd or its dependencies
# on 'systemctl isolate ..'
- systemctl add-wants --runtime remote-fs.target rpc-statd.service
+ systemctl add-wants --runtime remote-fs.target nfs-statd.service
exit 0
fi
fi
@@ -0,0 +1,36 @@
From 1ab0c326405c6daa06f1a7eb4b0b60bf4e0584c2 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 31 Dec 2019 08:15:34 -0800
Subject: [PATCH] Detect warning options during configure
Certain options maybe compiler specific therefore its better
to detect them before use.
nfs_error copies the format string and appends newline to it
but compiler can forget that it was format string since its not
same fmt string that was passed. Ignore the warning
Wdiscarded-qualifiers is gcc specific and this is no longer needed
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
support/nfs/xcommon.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/support/nfs/xcommon.c b/support/nfs/xcommon.c
index 3989f0b..e080423 100644
--- a/support/nfs/xcommon.c
+++ b/support/nfs/xcommon.c
@@ -98,7 +98,10 @@ nfs_error (const char *fmt, ...) {
fmt2 = xstrconcat2 (fmt, "\n");
va_start (args, fmt);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
vfprintf (stderr, fmt2, args);
+#pragma GCC diagnostic pop
va_end (args);
free (fmt2);
}
@@ -0,0 +1,17 @@
[Unit]
Description=NFS Mount Daemon
DefaultDependencies=no
After=rpcbind.socket
Requires=proc-fs-nfsd.mount
After=proc-fs-nfsd.mount
After=network.target local-fs.target
BindsTo=nfs-server.service
ConditionPathExists=@SYSCONFDIR@/exports
[Service]
EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
ExecStart=@SBINDIR@/rpc.mountd -F $MOUNTD_OPTS
LimitNOFILE=@HIGH_RLIMIT_NOFILE@
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,23 @@
[Unit]
Description=NFS server and services
DefaultDependencies=no
Requires=network.target proc-fs-nfsd.mount
Requires=nfs-mountd.service
Wants=rpcbind.service
After=local-fs.target
After=network.target proc-fs-nfsd.mount rpcbind.service nfs-mountd.service
ConditionPathExists=@SYSCONFDIR@/exports
[Service]
Type=oneshot
EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
ExecStartPre=@SBINDIR@/exportfs -r
ExecStart=@SBINDIR@/rpc.nfsd $NFSD_OPTS $NFSD_COUNT
ExecStop=@SBINDIR@/rpc.nfsd 0
ExecStopPost=@SBINDIR@/exportfs -au
ExecStopPost=@SBINDIR@/exportfs -f
ExecReload=@SBINDIR@/exportfs -r
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,14 @@
[Unit]
Description=NFS status monitor for NFSv2/3 locking.
DefaultDependencies=no
Conflicts=umount.target
Requires=nss-lookup.target rpcbind.service
After=network.target nss-lookup.target rpcbind.service
[Service]
EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
ExecStart=@SBINDIR@/rpc.statd -F $STATD_OPTS
LimitNOFILE=@HIGH_RLIMIT_NOFILE@
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,42 @@
[PATCH] nfs-utils: debianize start-statd
Upstream-Status: Pending
make start-statd command to use nfscommon configure, too.
Signed-off-by: Henrik Riomar <henrik.riomar@ericsson.com>
Signed-off-by: Li Wang <li.wang@windriver.com>
Signed-off-by: Roy Li <rongqing.li@windriver.com>
Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
---
utils/statd/start-statd | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/utils/statd/start-statd b/utils/statd/start-statd
index 2fd6039..f591b34 100755
--- a/utils/statd/start-statd
+++ b/utils/statd/start-statd
@@ -17,6 +17,14 @@ then
# statd already running - must have been slow to respond.
exit 0
fi
+
+# Read config
+DEFAULTFILE=/etc/default/nfs-common
+NEED_IDMAPD=
+if [ -f $DEFAULTFILE ]; then
+ . $DEFAULTFILE
+fi
+
# First try systemd if it's installed.
if [ -d /run/systemd/system ]; then
# Quit only if the call worked.
@@ -25,4 +33,4 @@ fi
cd /
# Fall back to launching it ourselves.
-exec rpc.statd --no-notify
+exec rpc.statd --no-notify $STATDOPTS
--
2.6.6
@@ -0,0 +1,35 @@
# Parameters to be passed to nfs-utils (clients & server) service files.
#
# Options to pass to rpc.nfsd.
NFSD_OPTS=""
# Number of servers to start up; the default is 8 servers.
NFSD_COUNT=""
# Where to mount nfsd filesystem; the default is "/proc/fs/nfsd".
PROCNFSD_MOUNTPOINT=""
# Options used to mount nfsd filesystem; the default is "rw,nodev,noexec,nosuid".
PROCNFSD_MOUNTOPTS=""
# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option.
MOUNTD_OPTS=""
# Parameters to be passed to nfs-common (nfs clients & server) init script.
#
# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".
# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=""
# Options to pass to rpc.statd.
# N.B. statd normally runs on both client and server, and run-time
# options should be specified accordingly.
# STATD_OPTS="-p 32765 -o 32766"
STATD_OPTS=""
@@ -0,0 +1,63 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: nfs-common
# Required-Start: $portmap hwclock
# Required-Stop: $portmap hwclock
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: NFS support for both client and server
# Description: NFS is a popular protocol for file sharing across
# TCP/IP networks. This service provides various
# support functions for NFS mounts.
### END INIT INFO
#
# Startup script for nfs-utils
#
#
# Location of executables:
# Source function library.
. /etc/init.d/functions
test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
test -z "$STATD_PID" && STATD_PID=/var/run/rpc.statd.pid
#
# The default state directory is /var/lib/nfs
test -n "$NFS_STATEDIR" || NFS_STATEDIR=/var/lib/nfs
#
#----------------------------------------------------------------------
# Startup and shutdown functions.
# Actual startup/shutdown is at the end of this file.
start_statd(){
echo -n "starting statd: "
start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID"
echo done
}
stop_statd(){
echo -n 'stopping statd: '
start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID"
echo done
}
#----------------------------------------------------------------------
#
# supported options:
# start
# stop
# restart: stops and starts mountd
#FIXME: need to create the /var/lib/nfs/... directories
case "$1" in
start)
start_statd;;
stop)
stop_statd;;
status)
status $NFS_STATD
exit $?;;
restart)
$0 stop
$0 start;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1;;
esac
@@ -0,0 +1,130 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: nfs-kernel-server
# Required-Start: $remote_fs nfs-common $portmap hwclock
# Required-Stop: $remote_fs nfs-common $portmap hwclock
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Kernel NFS server support
# Description: NFS is a popular protocol for file sharing across
# TCP/IP networks. This service provides NFS server
# functionality, which is configured via the
# /etc/exports file.
### END INIT INFO
#
# Startup script for nfs-utils
#
# Source function library.
. /etc/init.d/functions
#
# The environment variable NFS_SERVERS may be set in /etc/default/nfsd
# Other control variables may be overridden here too
test -r /etc/default/nfsd && . /etc/default/nfsd
#
# Location of executables:
test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd
test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd
#
# The user mode program must also exist (it just starts the kernel
# threads using the kernel module code).
test -x "$NFS_MOUNTD" || exit 0
test -x "$NFS_NFSD" || exit 0
#
# Default is 8 threads, value is settable between 1 and the truely
# ridiculous 99
test "$NFS_SERVERS" != "" && test "$NFS_SERVERS" -gt 0 && test "$NFS_SERVERS" -lt 100 || NFS_SERVERS=8
#
#----------------------------------------------------------------------
# Startup and shutdown functions.
# Actual startup/shutdown is at the end of this file.
#mountd
start_mountd(){
echo -n 'starting mountd: '
start-stop-daemon --start --exec "$NFS_MOUNTD" -- "$@"
echo done
}
stop_mountd(){
echo -n 'stopping mountd: '
start-stop-daemon --stop --quiet --exec "$NFS_MOUNTD"
echo done
}
#
#nfsd
start_nfsd(){
modprobe -q nfsd
grep -q nfsd /proc/filesystems || {
echo NFS daemon support not enabled in kernel
exit 1
}
grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsd
grep -q nfsd /proc/mounts || {
echo nfsd filesystem could not be mounted at /proc/fs/nfsd
exit 1
}
echo -n "starting $1 nfsd kernel threads: "
start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
echo done
}
delay_nfsd(){
for delay in 0 1 2 3 4 5 6 7 8 9
do
if pidof nfsd >/dev/null
then
echo -n .
sleep 1
else
return 0
fi
done
return 1
}
stop_nfsd(){
# WARNING: this kills any process with the executable
# name 'nfsd'.
echo -n 'stopping nfsd: '
start-stop-daemon --stop --quiet --signal 1 --name nfsd
if delay_nfsd || {
echo failed
echo ' using signal 9: '
start-stop-daemon --stop --quiet --signal 9 --name nfsd
delay_nfsd
}
then
echo done
else
echo failed
fi
}
#----------------------------------------------------------------------
#
# supported options:
# start
# stop
# reload: reloads the exports file
# restart: stops and starts mountd
#FIXME: need to create the /var/lib/nfs/... directories
case "$1" in
start)
test -r /etc/exports && exportfs -r
start_nfsd "$NFS_SERVERS"
start_mountd
test -r /etc/exports && exportfs -a;;
stop) exportfs -ua
stop_mountd
stop_nfsd;;
status)
status /usr/sbin/rpc.mountd
RETVAL=$?
status nfsd
rval=$?
[ $RETVAL -eq 0 ] && exit $rval
exit $RETVAL;;
reload) test -r /etc/exports && exportfs -r;;
restart)
$0 stop
$0 start;;
*) echo "Usage: $0 {start|stop|status|reload|restart}"
exit 1;;
esac
@@ -0,0 +1,8 @@
[Unit]
Description=NFSD configuration filesystem
After=systemd-modules-load.service
[Mount]
What=nfsd
Where=/proc/fs/nfsd
Type=nfsd
@@ -0,0 +1,151 @@
SUMMARY = "userspace utilities for kernel nfs"
DESCRIPTION = "The nfs-utils package provides a daemon for the kernel \
NFS server and related tools."
HOMEPAGE = "http://nfs.sourceforge.net/"
SECTION = "console/network"
LICENSE = "MIT & GPL-2.0-or-later & BSD-3-Clause"
LIC_FILES_CHKSUM = "file://COPYING;md5=95f3a93a5c3c7888de623b46ea085a84"
# util-linux for libblkid
DEPENDS = "libcap libevent util-linux sqlite3 libtirpc"
RDEPENDS:${PN} = "${PN}-client"
RRECOMMENDS:${PN} = "kernel-module-nfsd"
inherit useradd
USERADD_PACKAGES = "${PN}-client"
USERADD_PARAM:${PN}-client = "--system --home-dir /var/lib/nfs \
--shell /bin/false --user-group rpcuser"
SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.xz \
file://nfsserver \
file://nfscommon \
file://nfs-utils.conf \
file://nfs-server.service \
file://nfs-mountd.service \
file://nfs-statd.service \
file://proc-fs-nfsd.mount \
file://nfs-utils-debianize-start-statd.patch \
file://bugfix-adjust-statd-service-name.patch \
file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
file://clang-warnings.patch \
file://0005-mountd-Check-for-return-of-stat-function.patch \
file://0006-Fix-function-prototypes.patch \
file://0001-Replace-statfs64-with-statfs.patch \
"
SRC_URI[sha256sum] = "5200873e81c4d610e2462fc262fe18135f2dbe78b7979f95accd159ae64d5011"
# Only kernel-module-nfsd is required here (but can be built-in) - the nfsd module will
# pull in the remainder of the dependencies.
INITSCRIPT_PACKAGES = "${PN} ${PN}-client"
INITSCRIPT_NAME = "nfsserver"
INITSCRIPT_PARAMS = "defaults"
INITSCRIPT_NAME:${PN}-client = "nfscommon"
INITSCRIPT_PARAMS:${PN}-client = "defaults 19 21"
inherit autotools-brokensep update-rc.d systemd pkgconfig
SYSTEMD_PACKAGES = "${PN} ${PN}-client"
SYSTEMD_SERVICE:${PN} = "nfs-server.service nfs-mountd.service"
SYSTEMD_SERVICE:${PN}-client = "nfs-statd.service"
# --enable-uuid is need for cross-compiling
EXTRA_OECONF = "--with-statduser=rpcuser \
--enable-mountconfig \
--enable-libmount-mount \
--enable-uuid \
--disable-gss \
--disable-nfsdcltrack \
--with-statdpath=/var/lib/nfs/statd \
--with-rpcgen=${HOSTTOOLS_DIR}/rpcgen \
"
PACKAGECONFIG ??= "tcp-wrappers \
${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \
"
PACKAGECONFIG:remove:libc-musl = "tcp-wrappers"
PACKAGECONFIG[tcp-wrappers] = "--with-tcp-wrappers,--without-tcp-wrappers,tcp-wrappers"
PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
# libdevmapper is available in meta-oe
PACKAGECONFIG[nfsv41] = "--enable-nfsv41,--disable-nfsv41,libdevmapper,libdevmapper"
# keyutils is available in meta-oe
PACKAGECONFIG[nfsv4] = "--enable-nfsv4,--disable-nfsv4,keyutils,python3-core"
PACKAGES =+ "${PN}-client ${PN}-mount ${PN}-stats ${PN}-rpcctl"
CONFFILES:${PN}-client += "${localstatedir}/lib/nfs/etab \
${localstatedir}/lib/nfs/rmtab \
${localstatedir}/lib/nfs/xtab \
${localstatedir}/lib/nfs/statd/state \
${sysconfdir}/nfsmount.conf"
FILES:${PN}-client = "${sbindir}/*statd \
${sbindir}/rpc.idmapd ${sbindir}/sm-notify \
${sbindir}/showmount ${sbindir}/nfsstat \
${localstatedir}/lib/nfs \
${sysconfdir}/nfs-utils.conf \
${sysconfdir}/nfsmount.conf \
${sysconfdir}/init.d/nfscommon \
${systemd_system_unitdir}/nfs-statd.service"
RDEPENDS:${PN}-client = "${PN}-mount rpcbind"
FILES:${PN}-mount = "${base_sbindir}/*mount.nfs*"
FILES:${PN}-stats = "${sbindir}/mountstats ${sbindir}/nfsiostat ${sbindir}/nfsdclnts"
RDEPENDS:${PN}-stats = "python3-core"
FILES:${PN}-rpcctl = "${sbindir}/rpcctl"
RDEPENDS:${PN}-rpcctl = "python3-core"
FILES:${PN}-staticdev += "${libdir}/libnfsidmap/*.a"
FILES:${PN} += "${systemd_unitdir} ${libdir}/libnfsidmap/ ${nonarch_libdir}/modprobe.d"
do_configure:prepend() {
sed -i -e 's,sbindir = /sbin,sbindir = ${base_sbindir},g' \
${S}/utils/mount/Makefile.am
}
# Make clean needed because the package comes with
# precompiled 64-bit objects that break the build
do_compile:prepend() {
make clean
}
# Works on systemd only
HIGH_RLIMIT_NOFILE ??= "4096"
do_install:append () {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/nfsserver ${D}${sysconfdir}/init.d/nfsserver
install -m 0755 ${WORKDIR}/nfscommon ${D}${sysconfdir}/init.d/nfscommon
install -m 0755 ${WORKDIR}/nfs-utils.conf ${D}${sysconfdir}
install -m 0755 ${S}/utils/mount/nfsmount.conf ${D}${sysconfdir}
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/nfs-server.service ${D}${systemd_system_unitdir}/
install -m 0644 ${WORKDIR}/nfs-mountd.service ${D}${systemd_system_unitdir}/
install -m 0644 ${WORKDIR}/nfs-statd.service ${D}${systemd_system_unitdir}/
sed -i -e 's,@SBINDIR@,${sbindir},g' \
-e 's,@SYSCONFDIR@,${sysconfdir},g' \
-e 's,@HIGH_RLIMIT_NOFILE@,${HIGH_RLIMIT_NOFILE},g' \
${D}${systemd_system_unitdir}/*.service
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -m 0644 ${WORKDIR}/proc-fs-nfsd.mount ${D}${systemd_system_unitdir}/
install -d ${D}${systemd_system_unitdir}/sysinit.target.wants/
ln -sf ../proc-fs-nfsd.mount ${D}${systemd_system_unitdir}/sysinit.target.wants/proc-fs-nfsd.mount
fi
# kernel code as of 3.8 hard-codes this path as a default
install -d ${D}/var/lib/nfs/v4recovery
# chown the directories and files
chown -R rpcuser:rpcuser ${D}${localstatedir}/lib/nfs/statd
chmod 0644 ${D}${localstatedir}/lib/nfs/statd/state
# Make python tools use python 3
sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${sbindir}/mountstats ${D}${sbindir}/nfsiostat
}