mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] config: boardsetup: add nfs client specifications
@ 2019-11-22 14:15 Alexander Aring
  2019-11-25 10:02 ` Roland Hieber
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Aring @ 2019-11-22 14:15 UTC (permalink / raw)
  To: ptxdist; +Cc: Alexander Aring

This patch adds additional client specifications for the nfsroot mount.
The default value is the same as it was hardcoded before. This offers to
change this line without maintaining the whole file in a separate BSP.

The client specifications is part of the official export format which is
set right after the directory which is exported, for more information
lookup:

https://linux.die.net/man/8/unfsd

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 config/boardsetup/Kconfig     | 17 +++++++++++++++++
 scripts/lib/ptxd_make_nfsd.sh |  7 ++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/config/boardsetup/Kconfig b/config/boardsetup/Kconfig
index 8ffa27224..2d3791807 100644
--- a/config/boardsetup/Kconfig
+++ b/config/boardsetup/Kconfig
@@ -39,6 +39,23 @@ config BOARDSETUP_NFSROOT_PATH
 	  above given path is exported by nfs server. This field will be ignored
 	  if you don't use nfsroot.
 
+config BOARDSETUP_NFSROOT_CLIENT_SPECIFICATIONS
+	string
+	prompt "nfsroot client specifications"
+	default "(rw,no_root_squash)"
+	help
+	  Specify the list of client specifications for the nfsroot export.
+	  Example: "1.2.3.4(rw) 192.168.2.0/24(ro,all_squash)"
+
+	  Clients can be specified using either a hostname, an IP address, or an IP
+	  network. Networks can be given by specifying the number of leading 1 bits
+	  in the netmask or by giving the full netmask. If the hostname is empty, the
+	  directory is exported to everyone.
+
+	  Options can follow a client specification and have to be enclosed in
+	  parenthesis, with the opening paren directly following the client name or
+	  address. If no options are given, ro and root_squash are enabled by default.
+
 config BOARDSETUP_TFTP_PATH
 	string
 	prompt "tftp path"
diff --git a/scripts/lib/ptxd_make_nfsd.sh b/scripts/lib/ptxd_make_nfsd.sh
index 0bc9c906b..f7d8136d0 100644
--- a/scripts/lib/ptxd_make_nfsd.sh
+++ b/scripts/lib/ptxd_make_nfsd.sh
@@ -8,6 +8,7 @@
 
 ptxd_make_nfsd_exec() {
     local port
+    local client_specficiations
     local root="/$(basename "${ptx_nfsroot}")"
     local base="$(dirname "${ptx_nfsroot}")"
 
@@ -15,11 +16,15 @@ ptxd_make_nfsd_exec() {
 	port=2049
     fi
 
+    if ! client_specficiations="$(ptxd_get_kconfig "${PTXDIST_BOARDSETUP}" "PTXCONF_BOARDSETUP_NFSROOT_CLIENT_SPECIFICATIONS")"; then
+	client_specficiations="(rw,no_root_squash)"
+    fi
+
     echo
     echo "Mount rootfs with nfsroot=${root},v3,tcp,port=${port},mountport=${port}"
     echo
 
-    echo "/ (rw,no_root_squash)" > "${PTXDIST_TEMPDIR}/exports" &&
+    echo "/ ${client_specficiations}" > "${PTXDIST_TEMPDIR}/exports" &&
     UNFS_BASE="${base}" unfsd -e "${PTXDIST_TEMPDIR}/exports" -n ${port} -m ${port} -p -d
 }
 export -f ptxd_make_nfsd_exec
-- 
2.20.1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ptxdist] [PATCH] config: boardsetup: add nfs client specifications
  2019-11-22 14:15 [ptxdist] [PATCH] config: boardsetup: add nfs client specifications Alexander Aring
@ 2019-11-25 10:02 ` Roland Hieber
  0 siblings, 0 replies; 2+ messages in thread
From: Roland Hieber @ 2019-11-25 10:02 UTC (permalink / raw)
  To: Alexander Aring; +Cc: ptxdist

On Fri, Nov 22, 2019 at 09:15:34AM -0500, Alexander Aring wrote:
> This patch adds additional client specifications for the nfsroot mount.
> The default value is the same as it was hardcoded before. This offers to
> change this line without maintaining the whole file in a separate BSP.
> 
> The client specifications is part of the official export format which is
> set right after the directory which is exported, for more information
> lookup:
> 
> https://linux.die.net/man/8/unfsd
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  config/boardsetup/Kconfig     | 17 +++++++++++++++++
>  scripts/lib/ptxd_make_nfsd.sh |  7 ++++++-
>  2 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/config/boardsetup/Kconfig b/config/boardsetup/Kconfig
> index 8ffa27224..2d3791807 100644
> --- a/config/boardsetup/Kconfig
> +++ b/config/boardsetup/Kconfig
> @@ -39,6 +39,23 @@ config BOARDSETUP_NFSROOT_PATH
>  	  above given path is exported by nfs server. This field will be ignored
>  	  if you don't use nfsroot.
>  
> +config BOARDSETUP_NFSROOT_CLIENT_SPECIFICATIONS
> +	string
> +	prompt "nfsroot client specifications"
> +	default "(rw,no_root_squash)"
> +	help
> +	  Specify the list of client specifications for the nfsroot export.
> +	  Example: "1.2.3.4(rw) 192.168.2.0/24(ro,all_squash)"
> +
> +	  Clients can be specified using either a hostname, an IP address, or an IP
> +	  network. Networks can be given by specifying the number of leading 1 bits
> +	  in the netmask or by giving the full netmask. If the hostname is empty, the
> +	  directory is exported to everyone.
> +
> +	  Options can follow a client specification and have to be enclosed in
> +	  parenthesis, with the opening paren directly following the client name or
> +	  address. If no options are given, ro and root_squash are enabled by default.
> +
>  config BOARDSETUP_TFTP_PATH
>  	string
>  	prompt "tftp path"
> diff --git a/scripts/lib/ptxd_make_nfsd.sh b/scripts/lib/ptxd_make_nfsd.sh
> index 0bc9c906b..f7d8136d0 100644
> --- a/scripts/lib/ptxd_make_nfsd.sh
> +++ b/scripts/lib/ptxd_make_nfsd.sh
> @@ -8,6 +8,7 @@
>  
>  ptxd_make_nfsd_exec() {
>      local port
> +    local client_specficiations

                       ^-- typo alert, but seems to be consistent
                           nevertheless :)

 - Roland

>      local root="/$(basename "${ptx_nfsroot}")"
>      local base="$(dirname "${ptx_nfsroot}")"
>  
> @@ -15,11 +16,15 @@ ptxd_make_nfsd_exec() {
>  	port=2049
>      fi
>  
> +    if ! client_specficiations="$(ptxd_get_kconfig "${PTXDIST_BOARDSETUP}" "PTXCONF_BOARDSETUP_NFSROOT_CLIENT_SPECIFICATIONS")"; then
> +	client_specficiations="(rw,no_root_squash)"
> +    fi
> +
>      echo
>      echo "Mount rootfs with nfsroot=${root},v3,tcp,port=${port},mountport=${port}"
>      echo
>  
> -    echo "/ (rw,no_root_squash)" > "${PTXDIST_TEMPDIR}/exports" &&
> +    echo "/ ${client_specficiations}" > "${PTXDIST_TEMPDIR}/exports" &&
>      UNFS_BASE="${base}" unfsd -e "${PTXDIST_TEMPDIR}/exports" -n ${port} -m ${port} -p -d
>  }
>  export -f ptxd_make_nfsd_exec
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-25 10:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 14:15 [ptxdist] [PATCH] config: boardsetup: add nfs client specifications Alexander Aring
2019-11-25 10:02 ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox