xref: /plan9/sys/man/2/fversion (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
FVERSION 2
NAME
fversion - initialize 9P connection and negotiate version
SYNOPSIS

#include <u.h> #include <libc.h>

int fversion(int fd, int bufsize, char *version, int nversion)

DESCRIPTION

Fversion is used to initialize the 9P connection represented by fd and to negotiate 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 support. The version will be overwritten with the negotiated, possibly lower, version of the protocol. The return value of fversion is the length of the returned version string; the value of nversion is therefore not the length of the version string presented to the system call, but the total length of the buffer to accept the final result, in the manner of a read system call.

Default values of zero for bufsize and the empty string for version will negotiate sensible defaults for the connection. If version is the empty string, nversion must still be large enough to receive the returned version string.

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 bind (2)) or even more commonly amount (see auth (2)) is sufficient.

SOURCE
/sys/src/libc/9syscall
SEE ALSO
intro (5), version (5), fauth (2).
DIAGNOSTICS
Sets errstr .