libssh2_sftp_posix_rename_ex(3)
π libssh2_sftp_posix_rename_ex β the glow-up rename, bestie
okay so this is the libssh2_sftp_posix_rename_ex(3) page from the libssh2 manual, and it's literally the one you want when you need a rename that actually behaves. sit with me, we're gonna go through it together π«Ά
β¨ NAME β¨
libssh2_sftp_posix_rename_ex β rename an SFTP file using POSIX semantics. no cap, that's the whole vibe.
πΈ SYNOPSIS πΈ
#include <libssh2.h>
#include <libssh2_sftp.h>
int
libssh2_sftp_posix_rename_ex(LIBSSH2_SFTP *sftp,
const char *source_filename,
size_t source_filename_len,
const char *dest_filename,
size_t dest_filename_len);
π¦ DESCRIPTION π¦
okay so here's the cast, one by one π
sftpβ the SFTP instance, as returned bylibssh2_sftp_init(3). your main character.sourcefileβ path and name of the existing filesystem entry. the thing that's already there.sourcefile_lenβ length of the path and name of the existing filesystem entry.destfileβ path and name of the target filesystem entry. where it's going.destfile_lenβ length of the path and name of the target filesystem entry.
so this function implements the posix-rename@openssh.com extension, and honestly? it's giving useful. like, when you're moving files across filesystems on a remote server, this is the one you want π₯.
here's the tea though: SSH_FXP_RENAME does not specify a specific implementation, and many servers will attempt to user hard links when moving files using SSH_FXP_RENAME. so you can't just assume it's doing the nice thing. rude, honestly.
and if the server does not support posix-rename@openssh.com, this function will return LIBSSH2_FX_OP_UNSUPPORTED and you can call libssh2_sftp_rename_ex (3) as a backup. always have a backup plan, bestie π
π RETURN VALUE π
- returns
0on success β¨ - returns a negative number on failure
- returns
LIBSSH2_ERROR_EAGAINwhen it would otherwise block
and yes, LIBSSH2_ERROR_EAGAIN is a negative number, but it is not really a failure per se. it's just... not yet. don't panic, don't spiral, just try again later π
π ERRORS π
the mood-killers, listed for your convenience:
LIBSSH2_FX_OP_UNSUPPORTEDβ Server does not supportposix-rename@openssh.comLIBSSH2_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.
π SEE ALSO π
and that's the whole page, periodt π
go rename something responsibly. this was libssh2 version 1.11.1, dated 9 May 2024 β mwah, love that for us πβπ
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms