SYS-FVERSION(2)                                   SYS-FVERSION(2)

     NAME
          fversion - initialize 9P connection and negotiate version

     SYNOPSIS
          include "sys.m";
          sys := load Sys Sys->PATH;

          fversion: fn(fd: ref FD, bufsize: int, version: string): (int, string);

     DESCRIPTION
          Fversion initialises the 9P connection represented by fd and
          negotiates the maximum message size and the version of the
          protocol to be used.

          The bufsize determines the size of the I/O buffer used to
          stage 9P requests to the server, subject to the constraints
          of the server itself.  The version is a text string that
          represents the highest version level the protocol will sup-
          port.

          Fversion returns a tuple (n,useversion) where n is -1 if the
          request was rejected, and otherwise n is bufsize and
          useversion is a string representing the negotiated, possibly
          lower, version of the protocol.

          Default values of zero for bufsize and the empty string for
          version will negotiate sensible defaults for the connection.

          The interpretation of the version strings is defined in
          version(5).

          It is rare to use fversion directly; usually the default
          negotiation performed by the kernel during mount (see sys-
          bind(2)) is sufficient.

     SEE ALSO
          sys-fauth(2), intro(5), version(5).

     DIAGNOSTICS
          Fversion returns a value of -1 for n on error, including
          failure to negotiate acceptable values, and sets the system
          error string.

     BUGS
          The returned value of n when no error occurs should be the
          negotiated message size but is currently the original
          bufsize parameter.

     Page 1                       Plan 9            (printed 12/22/24)