guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] gnu: Allow nfs filesystems to be automatically mounted.


From: John Darrington
Subject: Re: [PATCH] gnu: Allow nfs filesystems to be automatically mounted.
Date: Thu, 24 Nov 2016 00:32:58 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Wed, Nov 23, 2016 at 11:07:27PM +0100, Ludovic Court??s wrote:
     John Darrington <address@hidden> skribis:
     
     > * gnu/build/file-systems.scm (mount-file-system): Append target addr= 
when
     > mounting nfs filesystems.
     > ---
     >  gnu/build/file-systems.scm | 16 +++++++++++++++-
     >  1 file changed, 15 insertions(+), 1 deletion(-)
     >
     > diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
     > index 0d55e91..c6fc784 100644
     > --- a/gnu/build/file-systems.scm
     > +++ b/gnu/build/file-systems.scm
     > @@ -481,7 +481,21 @@ run a file system check."
     >               (call-with-output-file mount-point (const #t)))
     >             (mkdir-p mount-point))
     >  
     > -       (mount source mount-point type flags options)
     > +       (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)))
     
     Looking at mount(8), it seems that the normal way is for ???source??? to be
     something like ???knuth.cwi.nl:/dir???.  The kernel then takes care of
     parsing that and doing name resolution somehow.
     
     In that case, we don???t have anything to do, good for us.

Unforunately that is not the case.  :(

Attempting to mount a NFS system by a direct system call will fail unless you
pass addr= as an option (try it if you don't believe me).  The mount.nfs
command when used with -v shows what actually goes on:

$ sudo  mount.nfs -v 192.168.0.125:/export/junk  /mnt
 mount.nfs: timeout set for Wed Nov 23 23:50:43 2016
 mount.nfs: trying text-based options 
'vers=4.2,addr=192.168.0.125,clientaddr=192.168.0.22'
 mount.nfs: mount(2): Protocol not supported
 mount.nfs: trying text-based options 
'vers=4.1,addr=192.168.0.125,clientaddr=192.168.0.22'
 mount.nfs: mount(2): No such file or directory
 mount.nfs: trying text-based options 'addr=192.168.0.125'
 mount.nfs: prog 100003, trying vers=3, prot=6
 mount.nfs: trying 192.168.0.125 prog 100003 vers 3 prot TCP port 2049
 mount.nfs: prog 100005, trying vers=3, prot=17
 mount.nfs: trying 192.168.0.125 prog 100005 vers 3 prot UDP port 45585
 192.168.0.125:/export/junk on /mnt type nfs

As you can see, it does a kind of crude protocol negotiation with the server.

It's also instructive to experiment a bit by running a command like:

 sudo strace mount -v :/export/junk  -o addr=192.168.0.125 /mnt
in which one can see the system call: 
mount(":/export/junk", "/mnt", "nfs", MS_MGC_VAL, "addr=192.168.0.125") = 0

However running the same command but dropping the option will result in:
 sudo strace mount -v :/export/junk  /mnt
mount(":/export/junk", "/mnt", "nfs", MS_MGC_VAL, NULL) = -1 EINVAL (Invalid 
argument)


So I think we really do need this patch or something similar to it.


     mount(8) doesn???t mention ???addr???.  Do you have documentation about it?

This aspect of NFS is poorly documented.  The best I found is a discussion at
http://stackoverflow.com/questions/28350912/nfs-mount-system-call-in-linux


     
J'
     

-- 
Avoid eavesdropping.  Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]