From 51d6dacf4befe42f3609cd1eed47622ff829faf6 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 21 Apr 2015 14:54:49 +0200 Subject: [PATCH] added nfsd v3 --- Makefile | 101 ++++++++++++++++++++++++- dist/README | 23 ++++++ fs-add/etc/config.default | 6 ++ fs-add/etc/exports | 2 + fs-add/etc/init.d/axe-settings | 23 ++++++ fs-add/etc/init.d/nfsd | 19 +++++ fs-add/etc/init.d/rcS | 3 +- fs-add/etc/inittab | 2 + fs-add/etc/netconfig | 5 ++ fs-add/etc/nsswitch.conf | 13 ++++ fs-add/etc/services | 7 ++ fs-add/sbin/sd-hotplug.sh | 33 +++++--- kernel/arch/sh/configs/idl4k_defconfig | 3 +- patches/kernel.config | 3 +- tools/do_min_fs.py | 1 + 15 files changed, 226 insertions(+), 18 deletions(-) create mode 100644 fs-add/etc/exports create mode 100755 fs-add/etc/init.d/axe-settings create mode 100755 fs-add/etc/init.d/nfsd create mode 100644 fs-add/etc/netconfig create mode 100644 fs-add/etc/nsswitch.conf diff --git a/Makefile b/Makefile index e3023131..62989712 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BUILD=7 +BUILD=8 VERSION=$(shell date +%Y%m%d%H%M)-$(BUILD) CPUS=4 STLINUX=/opt/STM/STLinux-2.4 @@ -32,6 +32,24 @@ DROPBEAR_BIN_FILES=dbclient dropbearconvert dropbearkey scp ETHTOOL=ethtool-3.18 +LIBTIRPC_VERSION=0.2.5 +LIBTIRPC=libtirpc-$(LIBTIRPC_VERSION) + +RPCBIND_VERSION=0.2.2 +RPCBIND=rpcbind-$(RPCBIND_VERSION) +RPCBIND_SBIN_FILES=rpcbind rpcinfo + +NFSUTILS_VERSION=1.3.2 +NFSUTILS=nfs-utils-$(NFSUTILS_VERSION) +NFSUTILS_SBIN_FILES=utils/showmount/showmount \ + utils/exportfs/exportfs \ + utils/nfsstat/nfsstat \ + utils/mountd/mountd \ + utils/statd/start-statd \ + utils/statd/sm-notify \ + utils/statd/statd \ + utils/nfsd/nfsd + # 10087? OSCAM_REV=10619 @@ -66,7 +84,7 @@ dist: # create CPIO # -fs.cpio: kernel-modules busybox dropbear ethtool minisatip oscam tools/axehelper +fs.cpio: kernel-modules busybox dropbear ethtool minisatip oscam tools/axehelper nfsutils fakeroot tools/do_min_fs.py \ -r "$(VERSION)" \ -b "bash strace" \ @@ -79,6 +97,8 @@ fs.cpio: kernel-modules busybox dropbear ethtool minisatip oscam tools/axehelper $(foreach f,$(DROPBEAR_SBIN_FILES), -e "apps/$(DROPBEAR)/$(f):sbin/$(f)") \ $(foreach f,$(DROPBEAR_BIN_FILES), -e "apps/$(DROPBEAR)/$(f):usr/bin/$(f)") \ -e "apps/$(ETHTOOL)/ethtool:sbin/ethtool" \ + $(foreach f,$(RPCBIND_SBIN_FILES), -e "apps/$(RPCBIND)/$(f):usr/sbin/$(f)") \ + $(foreach f,$(NFSUTILS_SBIN_FILES), -e "apps/$(NFSUTILS)/$(f):usr/sbin/$(notdir $(f))") \ -e "apps/minisatip/minisatip:sbin/minisatip" \ -e "apps/minisatip/icons/lr.jpg:usr/share/minisatip/icons/lr.jpg" \ -e "apps/minisatip/icons/lr.png:usr/share/minisatip/icons/lr.png" \ @@ -146,7 +166,7 @@ kernel: kernel/arch/sh/boot/uImage.gz .PHONY: kernel-mrproper kernel-mrproper: - make -C kernel -k ${CPUS} ARCH=sh CROSS_COMPILE=$(TOOLCHAIN_KERNEL)/bin/sh4-linux- mrproper + make -C kernel -j ${CPUS} ARCH=sh CROSS_COMPILE=$(TOOLCHAIN_KERNEL)/bin/sh4-linux- mrproper define RPM_UNPACK @mkdir -p $(1) @@ -277,6 +297,81 @@ apps/$(ETHTOOL)/ethtool: apps/$(ETHTOOL)/configure .PHONY: ethtool ethtool: apps/$(ETHTOOL)/ethtool +# +# libtirpc +# + +apps/$(LIBTIRPC)/configure: + $(call WGET,http://sourceforge.net/projects/libtirpc/files/libtirpc/$(LIBTIRPC_VERSION)/$(LIBTIRPC).tar.bz2,apps/$(LIBTIRPC).tar.bz2) + tar -C apps -xjf apps/$(LIBTIRPC).tar.bz2 + +apps/$(LIBTIRPC)/src/.libs/libtirpc.a: apps/$(LIBTIRPC)/configure + cd apps/$(LIBTIRPC) && \ + CC=$(TOOLCHAIN)/bin/sh4-linux-gcc \ + CFLAGS="-O2" \ + ./configure \ + --host=sh4-linux \ + --prefix=/ \ + --disable-shared \ + --disable-gssapi \ + --disable-ipv6 + make -C apps/$(LIBTIRPC) + +.PHONY: libtirpc +libtirpc: apps/$(LIBTIRPC)/src/.libs/libtirpc.a + +# +# rpcbind +# + +apps/$(RPCBIND)/configure: + $(call WGET,http://sourceforge.net/projects/rpcbind/files/rpcbind/$(RPCBIND_VERSION)/$(RPCBIND).tar.bz2,apps/$(RPCBIND).tar.bz2) + tar -C apps -xjf apps/$(RPCBIND).tar.bz2 + +apps/$(RPCBIND)/rpcbind: apps/$(LIBTIRPC)/src/.libs/libtirpc.a apps/$(RPCBIND)/configure + cd apps/$(RPCBIND) && \ + CC=$(TOOLCHAIN)/bin/sh4-linux-gcc \ + CFLAGS="-O2" \ + TIRPC_CFLAGS="-I$(PWD)/apps/$(LIBTIRPC)/tirpc" \ + TIRPC_LIBS="-L$(PWD)/apps/$(LIBTIRPC)/src/.libs -Wl,-Bstatic -ltirpc -Wl,-Bdynamic" \ + ./configure \ + --host=sh4-linux \ + --prefix=/ \ + --with-systemdsystemunitdir=no + make -C apps/$(RPCBIND) + +.PHONY: rpcbind +rpcbind: apps/$(RPCBIND)/rpcbind + +# +# nfs-utils +# + +apps/$(NFSUTILS)/configure: + $(call WGET,http://sourceforge.net/projects/nfs/files/nfs-utils/$(NFSUTILS_VERSION)/$(NFSUTILS).tar.bz2,apps/$(NFSUTILS).tar.bz2) + tar -C apps -xjf apps/$(NFSUTILS).tar.bz2 + +apps/$(NFSUTILS)/utils/exportfs/exportfs: apps/$(RPCBIND)/rpcbind apps/$(NFSUTILS)/configure + cd apps/$(NFSUTILS) && \ + CC=$(TOOLCHAIN)/bin/sh4-linux-gcc \ + CFLAGS="-O2" \ + TIRPC_CFLAGS="-I$(PWD)/apps/$(LIBTIRPC)/tirpc" \ + TIRPC_LIBS="-L$(PWD)/apps/$(LIBTIRPC)/src/.libs -Wl,-Bstatic -ltirpc -Wl,-Bdynamic" \ + ./configure \ + --host=sh4-linux \ + --prefix=/ \ + --disable-mount \ + --disable-nfsdcltrack \ + --disable-nfsv4 \ + --disable-gss \ + --disable-ipv6 \ + --disable-uuid \ + --without-tcp-wrappers + make -C apps/$(NFSUTILS) + +.PHONY: nfsutils +nfsutils: apps/$(NFSUTILS)/utils/exportfs/exportfs + # # oscam # diff --git a/dist/README b/dist/README index e614e90a..ece1b2b4 100644 --- a/dist/README +++ b/dist/README @@ -6,6 +6,7 @@ This directory contains USB and flash firmware for Update: - check differences in /etc/config.default against /etc/sysconfig/config + - example: diff -u /etc/config.default /etc/sysconfig/config Installation: @@ -40,6 +41,20 @@ Customization: - inetd.conf file is linked to /etc/sysconfig/inetd.conf - oscam configs are in /etc/sysconfig/oscam directory +httpd: + + - /media tree is exported + +ftpd: + + - /media tree is exported, use root/satip as login + +nfsd: + + - only v3 protocol is supported + - to list connected clients 'showmount' + - to list exports 'exportfs' + Minisatip config: - you may add extra parameters to MINISATIP_OPTS= in /etc/sysconfig/config @@ -121,6 +136,14 @@ Bugs: History: + satip-axe-201504211434-8 - Tue Apr 21 2015 + - faster boot (approx. 25 seconds from flash) + - tuners - configurable gain (0-16dB) - STV6210_BAMP in config + - enabled inetd/httpd/ftpd/nfsd by default + - added nfsd v3 support + - added ethtool + - extended debug tools for I2C bus (axe-debug, axehelper) + satip-axe-201504142137-7 - Tue Apr 14 2015 - minisatip - allow configurable DVR read buffer (-b option) diff --git a/fs-add/etc/config.default b/fs-add/etc/config.default index e7455907..c2a04f65 100644 --- a/fs-add/etc/config.default +++ b/fs-add/etc/config.default @@ -61,6 +61,12 @@ MINISATIP_OPTS="" # INETD="yes" +# +# nfsd v3 +# +NFSD="yes" +NFSD_HOTPLUG_EXPORT="*" # replace with host or subnet, '*' = world + # # oscamd # diff --git a/fs-add/etc/exports b/fs-add/etc/exports new file mode 100644 index 00000000..4b3d737a --- /dev/null +++ b/fs-add/etc/exports @@ -0,0 +1,2 @@ +# example line: +#/mnt/1 *(ro,insecure,all_squash,no_subtree_check) diff --git a/fs-add/etc/init.d/axe-settings b/fs-add/etc/init.d/axe-settings new file mode 100755 index 00000000..fca27684 --- /dev/null +++ b/fs-add/etc/init.d/axe-settings @@ -0,0 +1,23 @@ +#!/bin/sh + +if test -z "$STV6210_BAMP"; then + test -r /etc/sysconfig/config && . /etc/sysconfig/config +fi + +val="" +case "$STV6210_BAMP" in +0dB|0|1dB|1) val=0 ;; +2dB|2|3dB|3) val=1 ;; +4dB|4|5dB|5) val=2 ;; +6dB|6|7dB|7) val=3 ;; +8dB|8|9dB|9) val=4 ;; +10dB|10|11dB|11) val=5 ;; +12dB|12|13dB|13) val=6 ;; +14dB|14|15dB|15) val=7 ;; +16dB|16|17dB|17) val=8 ;; +esac +if ! test -z "$val"; then + axe-debug tdump > /tmp/stv6120-init.txt + logger -p local0.notice "Setting STV6210 gain to ${val}" + echo $val > /sys/devices/platform/i2c-stm.0/i2c-0/stv6120_gain +fi diff --git a/fs-add/etc/init.d/nfsd b/fs-add/etc/init.d/nfsd new file mode 100755 index 00000000..39e24ab7 --- /dev/null +++ b/fs-add/etc/init.d/nfsd @@ -0,0 +1,19 @@ +#!/bin/sh + +test -r /etc/sysconfig/config && . /etc/sysconfig/config + +if test "$NFSD" != "yes"; then + exit 0 +fi + +if test -r /etc/sysconfig/exports ; then + rm /etc/exports + ln -s /etc/sysconfig/exports /etc/exports +fi + +opts="--no-nfs-version 4" + +rpcbind & +exportfs -r +nfsd $opts 8 & +exec mountd -F $opts diff --git a/fs-add/etc/init.d/rcS b/fs-add/etc/init.d/rcS index dde14dc1..7c2d4711 100755 --- a/fs-add/etc/init.d/rcS +++ b/fs-add/etc/init.d/rcS @@ -30,7 +30,8 @@ mv /var /var.2 mkdir /tmp/var ln -s /tmp/var /var rm -rf /var.2 -mkdir -p /tmp/var/run /tmp/var/log /tmp/var/spool +mkdir -p /tmp/var/run /tmp/var/log /tmp/var/spool /var/lib/nfs +mount -t nfsd nfsd /proc/fs/nfsd # sysctl.conf sysctl -q -p diff --git a/fs-add/etc/inittab b/fs-add/etc/inittab index ad11d5c3..a2013347 100755 --- a/fs-add/etc/inittab +++ b/fs-add/etc/inittab @@ -6,6 +6,8 @@ ttyAS0::askfirst:/bin/sh ::once:/etc/init.d/network # Time Network Protocol ::once:/etc/init.d/ntpd +# NFSD +::once:/etc/init.d/nfsd # minisatip ::once:/etc/init.d/satip # telnetd diff --git a/fs-add/etc/netconfig b/fs-add/etc/netconfig new file mode 100644 index 00000000..4a5e890e --- /dev/null +++ b/fs-add/etc/netconfig @@ -0,0 +1,5 @@ +udp tpi_clts v inet udp /dev/udp - +tcp tpi_cots_ord v inet tcp /dev/tcp - +icmp tpi_raw - inet icmp /dev/icmp - +rawip tpi_raw - inet - /dev/rawip - +local tpi_cots_ord - loopback - - - diff --git a/fs-add/etc/nsswitch.conf b/fs-add/etc/nsswitch.conf new file mode 100644 index 00000000..75cfb09c --- /dev/null +++ b/fs-add/etc/nsswitch.conf @@ -0,0 +1,13 @@ +passwd: files +shadow: files +group: files +hosts: files dns +ethers: files +netmasks: files +networks: files +protocols: files +rpc: files +services: files +netgroup: files +automount: files +aliases: files diff --git a/fs-add/etc/services b/fs-add/etc/services index fd6b12c3..29cd380b 100644 --- a/fs-add/etc/services +++ b/fs-add/etc/services @@ -281,3 +281,10 @@ remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem socks 1080/tcp # socks proxy server socks 1080/udp # socks proxy server + +# +# NFSD +# + +nfs 2049/tcp +nfs 2049/udp diff --git a/fs-add/sbin/sd-hotplug.sh b/fs-add/sbin/sd-hotplug.sh index 6c5faf53..eea1b27d 100755 --- a/fs-add/sbin/sd-hotplug.sh +++ b/fs-add/sbin/sd-hotplug.sh @@ -4,25 +4,29 @@ add() { BLKID=$(/sbin/blkid /dev/$MDEV) eval ${BLKID#*:} +LABEL=$(echo "$LABEL" | sed -e 's/ /_/g') if [ -n "$LABEL" ]; then - MOUNT_POINT=/media/$LABEL + MOUNT_POINT="/media/$LABEL" else - MOUNT_POINT=/media/$MDEV + MOUNT_POINT="/media/$MDEV" fi logger -p local0.notice "Mounting $MDEV : $MOUNT_POINT" mkdir -p "$MOUNT_POINT" -for fs_type in vfat msdos ; do - if $(mount -t $fs_type -o umask=0 /dev/$MDEV "$MOUNT_POINT" 2>/dev/null) ; then - logger -p local0.notice "... $MDEV mounted using $fs_type filesystem" - exit 0 - fi -done -for fs_type in ext4 ext3 ext2 ; do - if $(mount -t $fs_type /dev/$MDEV "$MOUNT_POINT" 2>/dev/null) ; then - logger -p local0.notice "... $MDEV mounted using $fs_type filesystem" +for fs_type in vfat msdos ext4 ext3 ext2 ; do + case "$fs_type" in + vfat|msdos) opts="-o umask=0" ;; + *) opts= ;; + esac + if $(mount -t $fs_type $opts /dev/$MDEV "$MOUNT_POINT" 2>/dev/null) ; then + nfs= + if test "$NFSD" = "yes" -a -n "$NFSD_HOTPLUG_EXPORT"; then + exportfs -o rw,nohide,insecure,no_subtree_check "$NFSD_HOTPLUG_EXPORT":"$MOUNT_POINT" + nfs=" (nfsd exported)" + fi + logger -p local0.notice "... $MDEV mounted using $fs_type filesystem${nfs}" exit 0 fi done @@ -36,8 +40,11 @@ logger -p local0.notice "Unmounting $MDEV" for MOUNT_POINT in /media/* ; do if test -d "$MOUNT_POINT"; then d=$(mountpoint -n "$MOUNT_POINT" 2> /dev/null | cut -d ' ' -f 1) - if test "$d" = "$MDEV" -o "$d" = "UNKNOWN"; then + if test "$d" = "$MDEV" -o "$d" = "/dev/$MDEV" -o "$d" = "UNKNOWN"; then logger -p local0.notice "Unmounting $MDEV : $MOUNT_POINT" + if test "$NFSD" = "yes" -a -n "$NFSD_HOTPLUG_EXPORT"; then + exportfs -u "$NFSD_HOTPLUG_EXPORT":"$MOUNT_POINT" + fi umount -f "$MOUNT_POINT" rmdir "$MOUNT_POINT" fi @@ -46,6 +53,8 @@ done } +. /etc/sysconfig/config + case "$ACTION" in add) add ;; remove) remove ;; diff --git a/kernel/arch/sh/configs/idl4k_defconfig b/kernel/arch/sh/configs/idl4k_defconfig index 93659ef4..539e554a 100644 --- a/kernel/arch/sh/configs/idl4k_defconfig +++ b/kernel/arch/sh/configs/idl4k_defconfig @@ -1330,7 +1330,8 @@ CONFIG_NFS_V3=y # CONFIG_NFS_V3_ACL is not set # CONFIG_NFS_V4 is not set CONFIG_ROOT_NFS=y -# CONFIG_NFSD is not set +CONFIG_NFSD=y +CONFIG_NFSD_V3=y CONFIG_LOCKD=y CONFIG_LOCKD_V4=y CONFIG_NFS_COMMON=y diff --git a/patches/kernel.config b/patches/kernel.config index 93659ef4..539e554a 100644 --- a/patches/kernel.config +++ b/patches/kernel.config @@ -1330,7 +1330,8 @@ CONFIG_NFS_V3=y # CONFIG_NFS_V3_ACL is not set # CONFIG_NFS_V4 is not set CONFIG_ROOT_NFS=y -# CONFIG_NFSD is not set +CONFIG_NFSD=y +CONFIG_NFSD_V3=y CONFIG_LOCKD=y CONFIG_LOCKD_V4=y CONFIG_NFS_COMMON=y diff --git a/tools/do_min_fs.py b/tools/do_min_fs.py index 6cfe4be2..6ebd4550 100755 --- a/tools/do_min_fs.py +++ b/tools/do_min_fs.py @@ -308,6 +308,7 @@ def gen_fs(lib_list, init_type): run_cmd('cp -d ' + target_prefix + '/usr/lib/libz.so*' + ' fs/usr/lib/') run_cmd('cp -d ' + target_prefix + '/usr/lib/libstdc++.so*' + ' fs/usr/lib/') run_cmd('cp -d ' + target_prefix + '/usr/lib/libglib-2.0.so*' + ' fs/usr/lib/') + run_cmd('cp -d ' + target_prefix + '/lib/libnsl*' + ' fs/usr/lib/') if init_type == 'busybox': setup_busybox()