XDR types for the MOUNT v3 protocol — RFC 1813 appendix I.
Constants:
MNTPATHLEN = 1024 # max path bytes
MNTNAMLEN = 255 # max name bytes
FHSIZE3 = 64 # max v3 file-handle bytesLinked-list types (mountlist, exportnode, groupnode) use
XDR optional-data (§4.19) chains: each node carries its data plus
an optional pointer to the next node, and the chain ends with a
false flag. We model them as plain Elixir lists at the Elixir
layer and serialise/deserialise the chain shape on encode/decode.
Summary
Types
Mount path string, ≤ 1024 bytes.
Opaque file-handle, ≤ 64 bytes.
Mount status — :ok is success, the rest are RFC 1813 errno-style codes.
Hostname / group name string, ≤ 255 bytes.
Functions
Decode an XDR optional-data linked list into a flat Elixir list.
Each item is decoded by decoder/1 which consumes one item from
the binary and returns {:ok, item, rest}.
Decode a bounded dirpath.
Decode one exportnode.
Decode a fhandle3.
Decode one mountlist entry.
Decode a bounded name.
Decode a 32-bit mountstat3 code back to its atom. Unknown codes
surface as {:unknown, n} so handlers can report it without
crashing.
Encode a list of items as an XDR optional-data linked list. Each
item is encoded by encoder, then a TRUE flag points at the next
item; the final item is followed by a FALSE flag (no next).
Encode a bounded dirpath (path name).
Encode one exportnode — directory + group list (chained).
Encode a fhandle3 — variable-length opaque ≤ 64 bytes.
Encode one mountlist entry — hostname + directory.
Encode a failure mountres3 (status only, no body).
Encode a successful mountres3 (MNT_OK with file-handle and the
list of accepted auth flavours).
Encode a bounded name.
Encode a mountstat3 atom as its 32-bit wire integer.
RFC 1813 max v3 file-handle size.
RFC 1813 max name length.
RFC 1813 max path length.
Types
@type dirpath() :: binary()
Mount path string, ≤ 1024 bytes.
@type fhandle3() :: binary()
Opaque file-handle, ≤ 64 bytes.
@type mountstat3() ::
:ok
| :perm
| :noent
| :io
| :acces
| :notdir
| :inval
| :nametoolong
| :notsupp
| :serverfault
Mount status — :ok is success, the rest are RFC 1813 errno-style codes.
@type name() :: binary()
Hostname / group name string, ≤ 255 bytes.
Functions
@spec decode_chain(binary(), (binary() -> {:ok, term(), binary()} | {:error, term()})) :: {:ok, [term()], binary()} | {:error, term()}
Decode an XDR optional-data linked list into a flat Elixir list.
Each item is decoded by decoder/1 which consumes one item from
the binary and returns {:ok, item, rest}.
Decode a bounded dirpath.
@spec decode_exportnode(binary()) :: {:ok, Tahr.Mount.Types.ExportNode.t(), binary()} | {:error, term()}
Decode one exportnode.
Decode a fhandle3.
@spec decode_mountlist_entry(binary()) :: {:ok, Tahr.Mount.Types.MountList.t(), binary()} | {:error, term()}
Decode one mountlist entry.
Decode a bounded name.
@spec decode_stat(binary()) :: {:ok, mountstat3() | {:unknown, non_neg_integer()}, binary()} | {:error, term()}
Decode a 32-bit mountstat3 code back to its atom. Unknown codes
surface as {:unknown, n} so handlers can report it without
crashing.
Encode a list of items as an XDR optional-data linked list. Each
item is encoded by encoder, then a TRUE flag points at the next
item; the final item is followed by a FALSE flag (no next).
Encode a bounded dirpath (path name).
@spec encode_exportnode(Tahr.Mount.Types.ExportNode.t()) :: binary()
Encode one exportnode — directory + group list (chained).
Encode a fhandle3 — variable-length opaque ≤ 64 bytes.
@spec encode_mountlist_entry(Tahr.Mount.Types.MountList.t()) :: binary()
Encode one mountlist entry — hostname + directory.
@spec encode_mountres3_err(mountstat3()) :: binary()
Encode a failure mountres3 (status only, no body).
@spec encode_mountres3_ok(fhandle3(), [non_neg_integer()]) :: binary()
Encode a successful mountres3 (MNT_OK with file-handle and the
list of accepted auth flavours).
Encode a bounded name.
@spec encode_stat(mountstat3()) :: binary()
Encode a mountstat3 atom as its 32-bit wire integer.
@spec fhsize3() :: 64
RFC 1813 max v3 file-handle size.
@spec mntnamlen() :: 255
RFC 1813 max name length.
@spec mntpathlen() :: 1024
RFC 1813 max path length.