libssh2_sftp_statvfs(3)

πŸ“¦
version 1.11.1 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ libssh2_sftp_statvfs(3) β€” the libssh2 manual, bestie edition ✨

okay so welcome to the libssh2 manual page for libssh2_sftp_statvfs, and yes we're doing this together, grab a snack πŸ“


πŸ’– NAME πŸ’–

libssh2_sftp_statvfs, libssh2_sftp_fstatvfs β€” get file system statistics

like, it's giving "how much space is left on this filesystem" energy, but make it SFTP 🌸


✨ SYNOPSIS ✨

#include <libssh2.h>
#include <libssh2_sftp.h>

int
libssh2_sftp_statvfs(LIBSSH2_SFTP *sftp, const char *path,
                     size_t path_len, LIBSSH2_SFTP_STATVFS *st);

int
libssh2_sftp_fstatvfs(LIBSSH2_SFTP_HANDLE *handle,
                      LIBSSH2_SFTP_STATVFS *st)

πŸ¦‹ DESCRIPTION πŸ¦‹

These functions provide statvfs(2)-like operations and they require statvfs@openssh.com and fstatvfs@openssh.com extension support on the server. no extension support, no stats, periodt 😭

Here's the cast of characters, one by one, because everyone deserves their moment:

  • sftp β€” SFTP instance as returned by libssh2_sftp_init(3)
  • handle β€” SFTP File Handle as returned by libssh2_sftp_open_ex(3)
  • path β€” full path of any file within the mounted file system.
  • path_len β€” length of the full path.
  • st β€” Pointer to a LIBSSH2_SFTP_STATVFS structure to place file system statistics into.

πŸ‘‘ DATA TYPES πŸ‘‘

LIBSSH2_SFTP_STATVFS is a typedefed struct that is defined as below πŸ‘‡

struct _LIBSSH2_SFTP_STATVFS {
    libssh2_uint64_t  f_bsize;    /* file system block size */
    libssh2_uint64_t  f_frsize;   /* fragment size */
    libssh2_uint64_t  f_blocks;   /* size of fs in f_frsize units */
    libssh2_uint64_t  f_bfree;    /* # free blocks */
    libssh2_uint64_t  f_bavail;   /* # free blocks for non-root */
    libssh2_uint64_t  f_files;    /* # inodes */
    libssh2_uint64_t  f_ffree;    /* # free inodes */
    libssh2_uint64_t  f_favail;   /* # free inodes for non-root */
    libssh2_uint64_t  f_fsid;     /* file system ID */
    libssh2_uint64_t  f_flag;     /* mount flags */
    libssh2_uint64_t  f_namemax;  /* maximum filename length */
};
ngl it is unspecified whether all members of the returned struct have meaningful values on all file systems. so like… don't come for the library if a field is just vibing there with no meaning, okay? πŸ™ˆ

The field f_flag is a bit mask. Bits are defined as follows:

  • LIBSSH2_SFTP_ST_RDONLY β€” Read-only file system.
  • LIBSSH2_SFTP_ST_NOSUID β€” Set-user-ID/set-group-ID bits are ignored by exec(3).

πŸ’… RETURN VALUE πŸ’…

Returns 0 on success or negative on failure. If used in non-blocking mode, it returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. And while LIBSSH2_ERROR_EAGAIN is a negative number, it is not really a failure per se β€” it's literally just the "bestie I need a sec" of return codes, not a flop 🫢


πŸ’€ ERRORS πŸ’€

  • LIBSSH2_ERROR_ALLOC β€” An internal memory allocation call failed.
  • LIBSSH2_ERROR_SOCKET_SEND β€” Unable to send data on socket.
  • LIBSSH2_ERROR_SOCKET_TIMEOUT β€”
  • LIBSSH2_ERROR_SFTP_PROTOCOL β€” An invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server.

(yes the LIBSSH2_ERROR_SOCKET_TIMEOUT one just kinda ends there with no description. iconic honestly. we keep it exactly as it is πŸ’œ)


🌈 AVAILABILITY 🌈

Added in libssh2 1.2.6 β€” a classic, a legend, an OG ⭐


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie, you ate it πŸ’…βœ¨ this came to you from the libssh2 manual (that's the source name, right there), dated 22 May 2010 β€” yeah it's old but it's still serving, and this page is titled libssh2_sftp_statvfs(3) because that's literally what we're reading πŸŽ€ go get those file system stats, mwah πŸ’–