libssh2_sftp_mkdir_ex(3)
π libssh2_sftp_mkdir_ex β create a directory on the remote file system π
okay bestie, this is a page from the libssh2 manual (that's the manual name btw, we're in the libssh2 section 3 girlies). Sit down, grab a lil snack π, and let's make some folders on a remote machine together. no cap.
β¨ NAME β¨
libssh2_sftp_mkdir_ex β create a directory on the remote file system
literally that's it, that's the whole job. make a folder. remote. slay.
πΈ SYNOPSIS πΈ
#include <libssh2.h>
#include <libssh2_sftp.h>
int
libssh2_sftp_mkdir_ex(LIBSSH2_SFTP *sftp,
const char *path, unsigned int path_len,
long mode);
int
libssh2_sftp_mkdir(LIBSSH2_SFTP *sftp,
const char *path,
long mode);
so there's the β¨extraβ¨ version with path_len, and then the lil convenience one without it. both iconic, both valid. π
π¦ DESCRIPTION π¦
okay so let's break down the arguments, one by one, because every single one matters:
sftpβ the SFTP instance, as returned bylibssh2_sftp_init(3). you gotta have one of these first, it's giving "you can't sit with us until you init."pathβ the full path of the new directory you wanna create. π heads up though: the new directory's parents must all exist before you make this call. so if you're making/a/b/c, then/aand/a/bneed to already be there. no auto-magic recursive mkdir here, sorry babe. πpath_lenβ the length of that full path of the new directory you're creating. yes, you gotta tell it how long your string is. it's a whole thing.modeβ the directory creation mode (e.g.0755). classic permissions moment.
and then, like, it creates a directory on the remote file system. that's the vibe. that's the whole point. π
π«Ά RETURN VALUE π«Ά
- returns
0on success β¨ - returns a negative number on failure π
- returns
LIBSSH2_ERROR_EAGAINwhen it would otherwise block.
and listen, real talk: while LIBSSH2_ERROR_EAGAIN is a negative number, it is not really a failure per se. it's just the "not right now, come back later" energy. don't panic, bestie. π§
π ERRORS π
here's the roster of things that can go wrong:
LIBSSH2_ERROR_ALLOCβ an internal memory allocation call failed.LIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket.LIBSSH2_ERROR_SOCKET_TIMEOUTβ (yeah, that one just sits there, no explanation given, it's mysterious like that π΅οΈ)LIBSSH2_ERROR_SFTP_PROTOCOLβ an invalid SFTP protocol response was received on the socket, or an SFTP operation caused anerrorcodeto be returned by the server.
lowkey if you see any of these, something's not giving. check your socket, check your server, check your whole life. π
π SEE ALSO π
go read that one too, it's part of the fam. iykyk. π
π cute lil sign-off π
this page came to you from libssh2 0.15, dated 1 Jun 2007 β yes, she's an elder icon and she still ate. now go forth and make directories, bestie. mwah. π β¨π¦
π¦ 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