ddn.net.sftp.types

SFTP version 3 protocol types (draft-ietf-secsh-filexfer-02).

Constants, attribute records, status codes, open flags, and the result types used across the SFTP client. Pure data definitions with no dependency on any concrete SSH implementation.

Types 14

enumSftpExtensionName : string

Initial OpenSSH extension names advertised through VERSION.

limits = "limits@openssh.com"Server-reported transfer limits
posixRename = "posix-rename@openssh.com"Atomic rename with POSIX replace semantics
fsync = "fsync@openssh.com"Flush a written file handle to stable storage
statvfs = "statvfs@openssh.com"Filesystem information by path (version 2)
fstatvfs = "fstatvfs@openssh.com"Filesystem information by open handle (version 2)
hardlink = "hardlink@openssh.com"Create a hard link (version 1)
copyData = "copy-data"Server-side copy between open handles (version 1, no vendor suffix)

Filesystem information reported by statvfs@openssh.com and fstatvfs@openssh.com version 2.

All fields are 64-bit as transmitted; flag carries the server's mount flag bits verbatim, including any bits unknown to this client.

Fields
ulong blockSizeOptimal transfer block size
ulong fragmentSizeFundamental filesystem block size
ulong blocksTotal data blocks (in fragmentSize units)
ulong blocksFreeFree blocks
ulong blocksAvailableFree blocks available to unprivileged users
ulong filesTotal file nodes
ulong filesFreeFree file nodes
ulong filesAvailableFile nodes available to unprivileged users
ulong filesystemIdFilesystem identifier
ulong flagMount flag bits (see SftpStatVfsFlags); unknown bits are preserved
ulong nameMaxMaximum filename length
enumSftpStatVfsFlags : ulong

Known mount flag bits for SftpStatVfs.flag.

READ_ONLY = 0x1The filesystem is mounted read-only
NO_SUID = 0x2Set-user-ID and set-group-ID bits are ignored by exec

Server limits reported by limits@openssh.com version 1.

A zero field means the server imposes no limit beyond the protocol; the client always constrains requests with its own local bounds.

Fields
ulong maxPacketMaximum total SFTP packet size the server accepts (0 = unlimited)
ulong maxReadMaximum READ data length (0 = unlimited)
ulong maxWriteMaximum WRITE data length (0 = unlimited)
ulong maxOpenHandlesMaximum simultaneously open handles (0 = unlimited); optional field reported by newer servers

Argument order used by the version 3 SYMLINK request.

opensshOpenSSH compatibility: target path followed by link path
draftPublished draft order: link path followed by target path
enumSftpPacketType : ubyte

SFTP packet types (client and server).

init = 1Client: protocol version negotiation
msgVersion = 2Server: protocol version response
open = 3Client: open or create a file
close = 4Client: close a handle
read = 5Client: read from a handle
write = 6Client: write to a handle
lstat = 7Client: retrieve attributes without following symbolic links
fstat = 8Client: retrieve attributes by handle
setstat = 9Client: update attributes by path
fsetstat = 10Client: update attributes by handle
opendir = 11Client: open a directory
name = 104Server: directory listing entry
readdir = 12Client: read directory entries
remove = 13Client: remove a file
mkdir = 14Client: create a directory
rmdir = 15Client: remove a directory
realpath = 16Client: canonicalize a path
stat = 17Client: retrieve attributes following symbolic links
rename = 18Client: rename a file
readlink = 19Client: read a symlink target
symlink = 20Client: create a symlink
status = 101Server: status response
handle = 102Server: handle response
data = 103Server: data response
attrs = 105Server: attributes response
extendedReply = 201Server: extended reply
extended = 200Client: extended request
enumSftpStatusCode : uint

SFTP status/error codes (draft section 7).

ok = 0No error; the operation succeeded
eof = 1End of file reached
noSuchFile = 2File does not exist
permissionDenied = 3Permission denied
failure = 4Generic failure
badMessage = 5A bad handle was supplied
noConnection = 6Connection lost / protocol violation
connectionLost = 7The connection was lost while the operation was pending
opUnsupported = 8Operation not supported
enumSftpOpenFlags : uint

SFTP open flags (draft section 6.3).

read = 0x00000001Read access
write = 0x00000002Write access
append = 0x00000004Append-only (mutually exclusive with read)
creat = 0x00000008Create the file if it does not exist (with write)
excl = 0x00000010Fail if the file already exists (with creat)
trunc = 0x00000020Truncate the file to zero length (with write)
enumSftpAttrFlags : uint

File attribute flags (draft section 5).

size = 0x00000001Size field is present
uidgid = 0x00000002UID and GID fields are present
permissions = 0x00000004Permissions field is present
acmodtime = 0x00000008Access and modify times are present
extended = 0x80000000Extended attribute pairs follow
enumSftpFileType : uint

POSIX file type bits for permission fields.

fifo = 0x1000FIFO (named pipe)
chr = 0x2000Character device
dir = 0x4000Directory
blk = 0x6000Block device
reg = 0x8000Regular file
lnk = 0xA000Symbolic link
sock = 0xC000Socket
structSftpAttrs

File attributes as transmitted in SFTP v3.

Fields
uint flagsRaw flags present in this attribute set
ulong sizeFile size in bytes (valid when flags includes size)
uint uidOwning user id (valid when flags includes uidgid)
uint gidOwning group id (valid when flags includes uidgid)
uint permissionsPermission bits including file type (valid when flags includes permissions)
uint atimeLast access time in seconds since epoch (valid when flags includes acmodtime)
uint mtimeLast modification time in seconds since epoch (valid when flags includes acmodtime)
SftpExtendedAttribute[] extendedVendor-specific attributes, preserved as protocol bytes
Methods
bool hasSize() const pure nothrow @safe @nogcReturns: true when the size field is present.
bool hasUidGid() const pure nothrow @safe @nogcReturns: true when uid/gid fields are present.
bool hasPermissions() const pure nothrow @safe @nogcReturns: true when the permissions field is present.
bool hasAcModTime() const pure nothrow @safe @nogcReturns: true when atime/mtime fields are present.
uint fileType() const pure nothrow @safe @nogcReturns: the file type portion of permissions, or 0 when absent.
bool isDirectory() const pure nothrow @safe @nogcReturns: true when this is a directory.
bool isRegularFile() const pure nothrow @safe @nogcReturns: true when this is a regular file.
bool isSymlink() const pure nothrow @safe @nogcReturns: true when this is a symbolic link.

One vendor-specific attribute pair.

Fields
immutable(ubyte)[] typeExtension type bytes
immutable(ubyte)[] dataExtension value bytes
structSftpName

One directory entry from a READDIR response.

Fields
immutable(ubyte)[] nameEntry name bytes (a single remote path component)
immutable(ubyte)[] longnameServer-formatted long listing bytes (advisory only)
SftpAttrs attrsEntry attributes

Server-reported status of an operation.

Fields
SftpStatusCode codeStatus code
string messageHuman-readable diagnostic from the server
Methods
bool ok() const pure nothrow @safe @nogcReturns: true when the code is ok.
bool isEof() const pure nothrow @safe @nogcReturns: true when the code is eof.