From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Darrington Subject: [PATCH] gnu: Allow nfs file systems to be automatically mounted. Date: Sat, 26 Nov 2016 10:36:30 +0100 Message-ID: <1480152990-7080-1-git-send-email-jmd@gnu.org> References: <8760nc6et6.fsf@gnu.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAZPZ-0007ki-An for guix-devel@gnu.org; Sat, 26 Nov 2016 04:36:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAZPU-0000Ni-Cf for guix-devel@gnu.org; Sat, 26 Nov 2016 04:36:45 -0500 In-Reply-To: <8760nc6et6.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org Cc: John Darrington * gnu/build/file-systems.scm (mount-file-system): Append target addr= when mounting nfs filesystems. --- gnu/build/file-systems.scm | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index c6fc784..ca788ec 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -464,6 +464,22 @@ form: DEVICE, MOUNT-POINT, and TYPE must be strings; OPTIONS can be a string or #f; FLAGS must be a list of symbols. CHECK? is a Boolean indicating whether to run a file system check." + + (define (mount-nfs source mount-point type flags options) + (let* ((host (match (string-split source #\:) ((h _) h))) + (aa (car (getaddrinfo host "nfs"))) + (sa (addrinfo:addr aa)) + (inet-addr (inet-ntop (sockaddr:fam sa) + (sockaddr:addr sa)))) + + ;; Mounting an NFS file system requires passing the address + ;; of the server in the addr= option + (mount source mount-point type flags + (string-append "addr=" + inet-addr + (if options + (string-append "," options) + ""))))) (match spec ((source title mount-point type (flags ...) options check?) (let ((source (canonicalize-device-spec source title)) @@ -481,21 +497,11 @@ run a file system check." (call-with-output-file mount-point (const #t))) (mkdir-p mount-point)) - (mount source mount-point type flags - (cond - ((string-match "^nfs.*" type) - (let* ((host (car (string-split source #\:))) - (aa (car (getaddrinfo host #f))) - (sa (addrinfo:addr aa)) - (inet-addr (inet-ntop (sockaddr:fam sa) - (sockaddr:addr sa)))) - (string-append "addr=" - inet-addr - (if options - (string-append "," options) - "")))) - (else - options))) + (cond + ((string-match "^nfs.*" type) + (mount-nfs source mount-point type flags options)) + (else + (mount source mount-point type flags options))) ;; For read-only bind mounts, an extra remount is needed, as per ;; , which still applies to Linux 4.0. -- 2.1.4