--- /dev/null
+# Copyright (C) 2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=nfs-kernel-server
+PKG_VERSION:=1.3.0
+PKG_RELEASE:=1
+PKG_MD5SUM:=3ac3726eda563946d1f44ac3e5b61d56
+
+PKG_SOURCE_URL:=@SF/nfs
+PKG_SOURCE:=nfs-utils-$(PKG_VERSION).tar.bz2
+
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/nfs-utils-$(PKG_VERSION)
+PKG_BUILD_DIR:=$(BUILD_DIR)/nfs-utils-$(PKG_VERSION)
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+PKG_BUILD_DEPENDS:=$(PKG_NAME)/host
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/nfs-kernel-server/Default
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Filesystem
+ DEPENDS:=+libwrap +libblkid +libuuid $(LIBRPC_DEPENDS)
+ URL:=http://nfs.sourceforge.net/
+endef
+
+define Package/nfs-kernel-server
+ $(call Package/nfs-kernel-server/Default)
+ TITLE:=Kernel NFS server support
+ DEPENDS+= +kmod-fs-nfsd +kmod-fs-nfs +portmap
+endef
+
+define Package/nfs-kernel-server/description
+ Kernel NFS server support
+endef
+
+define Package/nfs-kernel-server-utils
+ $(call Package/nfs-kernel-server/Default)
+ TITLE:=NFS server utils
+ DEPENDS:=nfs-kernel-server
+endef
+
+define Package/nfs-kernel-server-utils/description
+ NFS server utils
+endef
+
+define Package/nfs-kernel-server/conffiles
+/etc/exports
+endef
+
+define Package/nfs-utils
+ $(call Package/nfs-kernel-server/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS+= +libevent +USE_UCLIBC:librpc
+ TITLE:=updated mount utility (includes nfs4)
+endef
+
+define Package/nfs-utils/description
+ Updated mount.nfs command - allows mounting nfs4 volumes
+endef
+
+TARGET_CFLAGS += -I$(PKG_BUILD_DIR)/lib -I$(STAGING_DIR)/usr/include/libevent \
+ -I$(STAGING_DIR)/usr/include/ -Drpc_uint=uint
+TARGET_LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib $(LIBRPC) \
+ -L$(STAGING_DIR)/usr/lib/libevent
+
+CONFIGURE_ARGS += \
+ --disable-gss \
+ --disable-nfsv4 \
+ --disable-nfsv41 \
+ --enable-static \
+ --enable-shared \
+ --disable-caps \
+ --disable-tirpc \
+ --disable-nfsdcld
+
+CONFIGURE_VARS += \
+ CONFIG_SQLITE3_TRUE="\#" \
+ CONFIG_NFSDCLD_TRUE="\#"
+
+MAKE_FLAGS += \
+ OPT="$(TARGET_CFLAGS)" \
+ INSTALLSUID="install -m 4755" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ RPCGEN_PATH=$(STAGING_DIR_HOST)/bin/rpcgen \
+ RPCGEN=$(STAGING_DIR_HOST)/bin/rpcgen
+
+HOST_CFLAGS += -Dlinux
+
+HOST_CONFIGURE_ARGS += \
+ --disable-gss \
+ --disable-nfsv4 \
+ --disable-nfsv41 \
+ --without-tcp-wrappers
+
+HOST_CONFIGURE_VARS += \
+ ac_cv_lib_event_event_dispatch=yes \
+ ac_cv_lib_nfsidmap_nfs4_init_name_mapping=yes \
+ ac_cv_lib_blkid_blkid_get_library_version=yes \
+ ac_cv_header_event_h=yes \
+ ac_cv_header_nfsidmap_h=yes \
+ ac_cv_header_blkid_blkid_h=yes \
+ GSSGLUE_CFLAGS=" " \
+ GSSGLUE_LIBS=" " \
+ RPCSECGSS_CFLAGS=" " \
+ RPCSECGSS_LIBS=" " \
+ CONFIG_SQLITE3_TRUE="\#" \
+ CONFIG_NFSDCLD_TRUE="\#"
+
+define Host/Compile
+ $(MAKE) -C $(HOST_BUILD_DIR)/tools/rpcgen all
+endef
+
+define Host/Install
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/tools/rpcgen/rpcgen $(STAGING_DIR_HOST)/bin/rpcgen
+endef
+
+define Package/nfs-kernel-server/install
+ $(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/sbin
+ $(INSTALL_DATA) ./files/nfsd.exports $(1)/etc/exports
+ $(INSTALL_BIN) ./files/nfsd.init $(1)/etc/init.d/nfsd
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/statd/sm-notify $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/statd/statd $(1)/usr/sbin/rpc.statd
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/nfsd/nfsd $(1)/usr/sbin/rpc.nfsd
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/mountd/mountd $(1)/usr/sbin/rpc.mountd
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/exportfs/exportfs $(1)/usr/sbin/
+endef
+
+define Package/nfs-kernel-server-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/showmount/showmount $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/nfsstat/nfsstat $(1)/usr/sbin
+endef
+
+define Package/nfs-utils/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/mount.nfs $(1)/sbin/
+ (cd $(1)/sbin; ln -sf mount.nfs mount.nfs4; ln -sf mount.nfs umount.nfs; ln -sf mount.nfs umount.nfs4)
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,nfs-kernel-server))
+$(eval $(call BuildPackage,nfs-kernel-server-utils))
+$(eval $(call BuildPackage,nfs-utils))
--- /dev/null
+--- a/support/nfs/svc_socket.c
++++ b/support/nfs/svc_socket.c
+@@ -40,10 +40,13 @@ int getservport(u_long number, const cha
+ char rpcdata[1024], servdata[1024];
+ struct rpcent rpcbuf, *rpcp;
+ struct servent servbuf, *servp = NULL;
+- int ret;
+-
++ int ret=0;
++#ifndef __UCLIBC__
+ ret = getrpcbynumber_r(number, &rpcbuf, rpcdata, sizeof rpcdata,
+ &rpcp);
++#else
++ rpcp = getrpcbynumber (number);
++#endif
+ if (ret == 0 && rpcp != NULL) {
+ /* First try name. */
+ ret = getservbyname_r(rpcp->r_name, proto, &servbuf, servdata,
+--- a/utils/mountd/cache.c
++++ b/utils/mountd/cache.c
+@@ -166,6 +166,7 @@ static void auth_unix_gid(FILE *f)
+ pw = getpwuid(uid);
+ if (!pw)
+ rv = -1;
++#ifndef __UCLIBC__
+ else {
+ rv = getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
+ if (rv == -1 && ngroups >= groups_len) {
+@@ -180,6 +181,7 @@ static void auth_unix_gid(FILE *f)
+ }
+ }
+ }
++#endif
+ qword_printuint(f, uid);
+ qword_printtimefrom(f, DEFAULT_TTL);
+ if (rv >= 0) {