libssh2_sftp_fsync(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_fsync ✨

okay bestie, we're diving into the libssh2 manual, page libssh2_sftp_fsync(3) πŸ’… this one's short and sweet and honestly iconic.


πŸ¦‹ NAME πŸ¦‹

libssh2_sftp_fsync β€” make that remote file actually hit the disk, no cap


🌸 SYNOPSIS 🌸

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

int
libssh2_sftp_fsync(LIBSSH2_SFTP_HANDLE *handle)

πŸ’– DESCRIPTION πŸ’–

so basically this function makes the remote server sync the file's data and metadata to disk. literally the remote equivalent of fsync(2), periodt. πŸ’Ύβœ¨

for this to work you need fsync@openssh.com support on the server. no server support = no fsync, sorry bestie 😭

πŸ‘‘ RETURN VALUE πŸ‘‘

returns 0 on success, or a negative number on failure. πŸ’€

if you're running in non-blocking mode, it returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. and like… yes, LIBSSH2_ERROR_EAGAIN is technically a negative number, but it is not really a failure per se. it's giving "hold on, try again later" energy, not "everything is broken" energy. πŸ™ˆ


πŸ”₯ ERRORS πŸ”₯

  • LIBSSH2_ERROR_ALLOC β€” an internal memory allocation call failed. the malloc said no 😭
  • LIBSSH2_ERROR_SOCKET_SEND β€” couldn't send data on the socket. the socket is not socketing πŸ’€
  • LIBSSH2_ERROR_SFTP_PROTOCOL β€” an invalid SFTP protocol response came back on the socket, or an SFTP operation made the server return an errorcode. specifically, this one can pop up if the SSH server doesn't support the fsync operation β€” in that case the SFTP subcode LIBSSH2_FX_OP_UNSUPPORTED gets returned. so if you see that, it's the server, not you 🫢

🌈 AVAILABILITY 🌈

added in libssh2 1.4.4 and OpenSSH 6.3. vintage, but make it fashion ⭐


🧚 SEE ALSO 🧚


and that's the whole vibe, bestie! go forth and fsync responsibly πŸ’…

this page came to you from the libssh2 manual, dated 8 Apr 2013 β€” mwah, xoxo, sync your disks πŸ’–