all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Darrington <john@darrington.wattle.id.au>
To: Ludovic Court??s <ludo@gnu.org>
Cc: guix-devel@gnu.org, John Darrington <jmd@gnu.org>
Subject: Re: [PATCH] gnu: Allow nfs filesystems to be automatically mounted.
Date: Thu, 24 Nov 2016 00:32:58 +0100	[thread overview]
Message-ID: <20161123233258.GA17068@jocasta.intra> (raw)
In-Reply-To: <87mvgp4zq8.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 4031 bytes --]

On Wed, Nov 23, 2016 at 11:07:27PM +0100, Ludovic Court??s wrote:
     John Darrington <jmd@gnu.org> 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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2016-11-23 23:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10 21:14 [PATCH 1/4] gnu: Separate util-linux into three packages John Darrington
2016-11-10 21:14 ` [PATCH 2/4] gnu: nfs-utils: Change input from util-linux to util-linux/mount John Darrington
2016-11-10 21:14 ` [PATCH 3/4] gnu: Move util-linux/mount to new file and deal with the effects John Darrington
2016-11-10 21:14 ` [PATCH 4/4] Add fs-search paths to util-linux John Darrington
2016-11-11 14:43 ` [PATCH 1/4] gnu: Separate util-linux into three packages Hartmut Goebel
2016-11-11 16:03   ` John Darrington
2016-11-11 16:40     ` Hartmut Goebel
2016-11-11 19:36       ` John Darrington
2016-11-12 14:53 ` Ludovic Courtès
2016-11-12 15:28   ` John Darrington
2016-11-12 17:09     ` John Darrington
2016-11-12 22:55       ` Ludovic Courtès
2016-11-13  8:21         ` John Darrington
2016-11-13 11:59           ` Ludovic Courtès
2016-11-13 14:06             ` John Darrington
2016-11-14  9:48               ` Ludovic Courtès
2016-11-14 17:46                 ` John Darrington
2016-11-15 10:46                   ` Ludovic Courtès
2016-11-16 21:06                     ` mount syscall John Darrington
2016-11-17  9:47                       ` Ludovic Courtès
2016-11-22 19:15                         ` [PATCH] gnu: Allow nfs filesystems to be automatically mounted John Darrington
2016-11-23 22:07                           ` Ludovic Courtès
2016-11-23 23:32                             ` John Darrington [this message]
2016-11-24 16:08                               ` Ludovic Courtès
2016-11-26  9:36                                 ` [PATCH] gnu: Allow nfs file systems " John Darrington
2016-11-26 18:37                                   ` Ludovic Courtès
2016-11-26 19:33                                     ` John Darrington
2016-11-28 13:59                                       ` Ludovic Courtès
2016-11-28 14:07                                         ` John Darrington
2016-11-28 21:05                                           ` Ludovic Courtès
2016-11-29  6:27                                             ` John Darrington
2016-11-29 21:51                                               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161123233258.GA17068@jocasta.intra \
    --to=john@darrington.wattle.id.au \
    --cc=guix-devel@gnu.org \
    --cc=jmd@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.