libssh2_sftp_symlink_ex(3)
π libssh2_sftp_symlink_ex(3) π
okay bestie, welcome to the libssh2 manual, this one's about symbolic links and she does BOTH jobs: reading them AND setting them. main character energy fr fr π¦
β¨ NAME β¨
libssh2_sftp_symlink_ex β read or set a symbolic link π
β¨ SYNOPSIS β¨
#include <libssh2.h>
#include <libssh2_sftp.h>
int
libssh2_sftp_symlink_ex(LIBSSH2_SFTP *sftp, const char *path,
unsigned int path_len, char *target,
unsigned int target_len, int link_type);
β¨ DESCRIPTION β¨
So basically this function does the whole symlink thing on the remote side β it either creates a symlink or reads out symlink info from over there. Slay. π
sftpβ the SFTP instance, the one you got back fromlibssh2_sftp_init(3)π«pathβ the remote filesystem object you're either creating a symlink from, or resolving. pick your fighter.path_lenβ how long that remote filesystem object's name is (the one you're creating a symlink from or resolving).targetβ a pointer to a buffer. and here's the tea: what this buffer is FOR totally depends on whatlink_typeis set to πLIBSSH2_SFTP_SYMLINKβ the remote filesystem object to link to.LIBSSH2_SFTP_READLINKβ a pre-allocated buffer that the symlink target gets resolved into.LIBSSH2_SFTP_REALPATHβ a pre-allocated buffer that the realpath target gets resolved into.
target_lenβ the length of the name of the remote filesystem target object.link_typeβ one of those three constants we just talked about, and it decides the entire resulting behavior of this function. no pressure bestie π
These are convenience macros, and honestly they're the ones you'll actually be using:
libssh2_sftp_symlink(3): creates a symbolic link between two filesystem objects.libssh2_sftp_readlink(3): resolves a symbolic link filesystem object to its next target.libssh2_sftp_realpath(3): resolves a complex, relative, or symlinked filepath to its effective target.
β¨ RETURN VALUE β¨
it depends on the vibe you picked:
- With
LIBSSH2_SFTP_SYMLINK, it returns0on success, or negative on failure. - With
LIBSSH2_SFTP_READLINKorLIBSSH2_SFTP_REALPATH, it returns the number of bytes it copied into the target buffer (not counting the terminating zero), or negative on failure.
It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. And yes, LIBSSH2_ERROR_EAGAIN is a negative number, but ngl it's not really a failure per se, don't panic π«Ά
From 1.2.8, LIBSSH2_ERROR_BUFFER_TOO_SMALL gets returned if the given target buffer is too small to fit the requested object name.
π BUG π
Passing in a too small buffer when receiving data only results in libssh2 1.2.7 or earlier to not copy the entire data amount, and it is not possible for the application to tell when it happens!
that's it, that's the bug. silently truncating and refusing to tell you? it's giving toxic. π
β¨ ERRORS β¨
LIBSSH2_ERROR_ALLOCβ an internal memory allocation call failed. rip. πLIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket.LIBSSH2_ERROR_SOCKET_TIMEOUTβ (no description given, she's mysterious like that) π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 β¨
okay that's the whole page bestie, go forth and symlink responsibly πβ
libssh2 0.15 Β· 1 Jun 2007 β yeah she's vintage, but she ate and left no crumbs ππ
π¦ 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