libssh  0.11.0
The SSH library
Loading...
Searching...
No Matches
sftp.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2003-2008 by Aris Adamantiadis
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
37#ifndef SFTP_H
38#define SFTP_H
39
40#include <sys/types.h>
41
42#include "libssh.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#ifdef _WIN32
49#ifndef uid_t
50 typedef uint32_t uid_t;
51#endif /* uid_t */
52#ifndef gid_t
53 typedef uint32_t gid_t;
54#endif /* gid_t */
55#ifdef _MSC_VER
56
57# ifndef _SSIZE_T_DEFINED
58# undef ssize_t
59# include <BaseTsd.h>
60 typedef _W64 SSIZE_T ssize_t;
61# define _SSIZE_T_DEFINED
62# endif /* _SSIZE_T_DEFINED */
63
64#endif /* _MSC_VER */
65#endif /* _WIN32 */
66
67#define LIBSFTP_VERSION 3
68
69typedef struct sftp_attributes_struct* sftp_attributes;
70typedef struct sftp_client_message_struct* sftp_client_message;
71typedef struct sftp_dir_struct* sftp_dir;
72typedef struct sftp_ext_struct *sftp_ext;
73typedef struct sftp_file_struct* sftp_file;
74typedef struct sftp_message_struct* sftp_message;
75typedef struct sftp_packet_struct* sftp_packet;
76typedef struct sftp_request_queue_struct* sftp_request_queue;
77typedef struct sftp_session_struct* sftp_session;
78typedef struct sftp_status_message_struct* sftp_status_message;
80typedef struct sftp_limits_struct* sftp_limits_t;
81typedef struct sftp_aio_struct* sftp_aio;
82
83struct sftp_session_struct {
84 ssh_session session;
85 ssh_channel channel;
86 int server_version;
87 int client_version;
88 int version;
89 sftp_request_queue queue;
90 uint32_t id_counter;
91 int errnum;
92 void **handles;
93 sftp_ext ext;
94 sftp_packet read_packet;
95 sftp_limits_t limits;
96};
97
98struct sftp_packet_struct {
99 sftp_session sftp;
100 uint8_t type;
101 ssh_buffer payload;
102};
103
104/* file handler */
105struct sftp_file_struct {
106 sftp_session sftp;
107 char *name;
108 uint64_t offset;
109 ssh_string handle;
110 int eof;
111 int nonblocking;
112};
113
114struct sftp_dir_struct {
115 sftp_session sftp;
116 char *name;
117 ssh_string handle; /* handle to directory */
118 ssh_buffer buffer; /* contains raw attributes from server which haven't been parsed */
119 uint32_t count; /* counts the number of following attributes structures into buffer */
120 int eof; /* end of directory listing */
121};
122
123struct sftp_message_struct {
124 sftp_session sftp;
125 uint8_t packet_type;
126 ssh_buffer payload;
127 uint32_t id;
128};
129
130/* this is a bunch of all data that could be into a message */
131struct sftp_client_message_struct {
132 sftp_session sftp;
133 uint8_t type;
134 uint32_t id;
135 char *filename; /* can be "path" */
136 uint32_t flags;
137 sftp_attributes attr;
138 ssh_string handle;
139 uint64_t offset;
140 uint32_t len;
141 int attr_num;
142 ssh_buffer attrbuf; /* used by sftp_reply_attrs */
143 ssh_string data; /* can be newpath of rename() */
144 ssh_buffer complete_message; /* complete message in case of retransmission*/
145 char *str_data; /* cstring version of data */
146 char *submessage; /* for extended messages */
147};
148
149struct sftp_request_queue_struct {
150 sftp_request_queue next;
151 sftp_message message;
152};
153
154/* SSH_FXP_MESSAGE described into .7 page 26 */
155struct sftp_status_message_struct {
156 uint32_t id;
157 uint32_t status;
158 ssh_string error_unused; /* not used anymore */
159 ssh_string lang_unused; /* not used anymore */
160 char *errormsg;
161 char *langmsg;
162};
163
164struct sftp_attributes_struct {
165 char *name;
166 char *longname; /* ls -l output on openssh, not reliable else */
167 uint32_t flags;
168 uint8_t type;
169 uint64_t size;
170 uint32_t uid;
171 uint32_t gid;
172 char *owner; /* set if openssh and version 4 */
173 char *group; /* set if openssh and version 4 */
174 uint32_t permissions;
175 uint64_t atime64;
176 uint32_t atime;
177 uint32_t atime_nseconds;
178 uint64_t createtime;
179 uint32_t createtime_nseconds;
180 uint64_t mtime64;
181 uint32_t mtime;
182 uint32_t mtime_nseconds;
183 ssh_string acl;
184 uint32_t extended_count;
185 ssh_string extended_type;
186 ssh_string extended_data;
187};
188
193 uint64_t f_bsize;
194 uint64_t f_frsize;
195 uint64_t f_blocks;
196 uint64_t f_bfree;
197 uint64_t f_bavail;
198 uint64_t f_files;
199 uint64_t f_ffree;
200 uint64_t f_favail;
201 uint64_t f_fsid;
202 uint64_t f_flag;
203 uint64_t f_namemax;
204};
205
210 uint64_t max_packet_length;
214};
215
230LIBSSH_API sftp_session sftp_new(ssh_session session);
231
242LIBSSH_API sftp_session sftp_new_channel(ssh_session session, ssh_channel channel);
243
244
250LIBSSH_API void sftp_free(sftp_session sftp);
251
264LIBSSH_API int sftp_init(sftp_session sftp);
265
278LIBSSH_API int sftp_get_error(sftp_session sftp);
279
288LIBSSH_API unsigned int sftp_extensions_get_count(sftp_session sftp);
289
299LIBSSH_API const char *sftp_extensions_get_name(sftp_session sftp, unsigned int indexn);
300
312LIBSSH_API const char *sftp_extensions_get_data(sftp_session sftp, unsigned int indexn);
313
331LIBSSH_API int sftp_extension_supported(sftp_session sftp, const char *name,
332 const char *data);
333
346LIBSSH_API sftp_dir sftp_opendir(sftp_session session, const char *path);
347
361LIBSSH_API sftp_attributes sftp_readdir(sftp_session session, sftp_dir dir);
362
372LIBSSH_API int sftp_dir_eof(sftp_dir dir);
373
386LIBSSH_API sftp_attributes sftp_stat(sftp_session session, const char *path);
387
403LIBSSH_API sftp_attributes sftp_lstat(sftp_session session, const char *path);
404
415LIBSSH_API sftp_attributes sftp_fstat(sftp_file file);
416
422LIBSSH_API void sftp_attributes_free(sftp_attributes file);
423
431LIBSSH_API int sftp_closedir(sftp_dir dir);
432
442LIBSSH_API int sftp_close(sftp_file file);
443
472LIBSSH_API sftp_file sftp_open(sftp_session session, const char *file, int accesstype,
473 mode_t mode);
474
480LIBSSH_API void sftp_file_set_nonblocking(sftp_file handle);
481
487LIBSSH_API void sftp_file_set_blocking(sftp_file handle);
488
508LIBSSH_API ssize_t sftp_read(sftp_file file, void *buf, size_t count);
509
541SSH_DEPRECATED LIBSSH_API int sftp_async_read_begin(sftp_file file,
542 uint32_t len);
543
567SSH_DEPRECATED LIBSSH_API int sftp_async_read(sftp_file file,
568 void *data,
569 uint32_t len,
570 uint32_t id);
571
593LIBSSH_API ssize_t sftp_write(sftp_file file, const void *buf, size_t count);
594
611LIBSSH_API void sftp_aio_free(sftp_aio aio);
612#define SFTP_AIO_FREE(x) \
613 do { if(x != NULL) {sftp_aio_free(x); x = NULL;} } while(0)
614
678LIBSSH_API ssize_t sftp_aio_begin_read(sftp_file file,
679 size_t len,
680 sftp_aio *aio);
681
715LIBSSH_API ssize_t sftp_aio_wait_read(sftp_aio *aio,
716 void *buf,
717 size_t buf_size);
718
784LIBSSH_API ssize_t sftp_aio_begin_write(sftp_file file,
785 const void *buf,
786 size_t len,
787 sftp_aio *aio);
788
816LIBSSH_API ssize_t sftp_aio_wait_write(sftp_aio *aio);
817
827LIBSSH_API int sftp_seek(sftp_file file, uint32_t new_offset);
828
839LIBSSH_API int sftp_seek64(sftp_file file, uint64_t new_offset);
840
850LIBSSH_API unsigned long sftp_tell(sftp_file file);
851
860LIBSSH_API uint64_t sftp_tell64(sftp_file file);
861
868LIBSSH_API void sftp_rewind(sftp_file file);
869
881LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file);
882
894LIBSSH_API int sftp_rmdir(sftp_session sftp, const char *directory);
895
911LIBSSH_API int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode);
912
928LIBSSH_API int sftp_rename(sftp_session sftp, const char *original, const char *newname);
929
949LIBSSH_API int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr);
950
971LIBSSH_API int
972sftp_lsetstat(sftp_session sftp, const char *file, sftp_attributes attr);
973
989LIBSSH_API int sftp_chown(sftp_session sftp, const char *file, uid_t owner, gid_t group);
990
1006LIBSSH_API int sftp_chmod(sftp_session sftp, const char *file, mode_t mode);
1007
1022LIBSSH_API int sftp_utimes(sftp_session sftp, const char *file, const struct timeval *times);
1023
1037LIBSSH_API int sftp_symlink(sftp_session sftp, const char *target, const char *dest);
1038
1052LIBSSH_API char *sftp_readlink(sftp_session sftp, const char *path);
1053
1068LIBSSH_API int sftp_hardlink(sftp_session sftp, const char *oldpath, const char *newpath);
1069
1081LIBSSH_API sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path);
1082
1092LIBSSH_API sftp_statvfs_t sftp_fstatvfs(sftp_file file);
1093
1099LIBSSH_API void sftp_statvfs_free(sftp_statvfs_t statvfs_o);
1100
1115LIBSSH_API int sftp_fsync(sftp_file file);
1116
1126LIBSSH_API sftp_limits_t sftp_limits(sftp_session sftp);
1127
1133LIBSSH_API void sftp_limits_free(sftp_limits_t limits);
1134
1146LIBSSH_API char *sftp_canonicalize_path(sftp_session sftp, const char *path);
1147
1155LIBSSH_API int sftp_server_version(sftp_session sftp);
1156
1168LIBSSH_API char *sftp_expand_path(sftp_session sftp, const char *path);
1169
1189LIBSSH_API char *sftp_home_directory(sftp_session sftp, const char *username);
1190
1191#ifdef WITH_SERVER
1201LIBSSH_API sftp_session sftp_server_new(ssh_session session, ssh_channel chan);
1202
1210SSH_DEPRECATED LIBSSH_API int sftp_server_init(sftp_session sftp);
1211
1217LIBSSH_API void sftp_server_free(sftp_session sftp);
1218#endif /* WITH_SERVER */
1219
1220/* sftpserver.c */
1221
1222LIBSSH_API sftp_client_message sftp_get_client_message(sftp_session sftp);
1223LIBSSH_API void sftp_client_message_free(sftp_client_message msg);
1224LIBSSH_API uint8_t sftp_client_message_get_type(sftp_client_message msg);
1225LIBSSH_API const char *sftp_client_message_get_filename(sftp_client_message msg);
1226LIBSSH_API void sftp_client_message_set_filename(sftp_client_message msg, const char *newname);
1227LIBSSH_API const char *sftp_client_message_get_data(sftp_client_message msg);
1228LIBSSH_API uint32_t sftp_client_message_get_flags(sftp_client_message msg);
1229LIBSSH_API const char *sftp_client_message_get_submessage(sftp_client_message msg);
1230LIBSSH_API int sftp_send_client_message(sftp_session sftp, sftp_client_message msg);
1231LIBSSH_API int sftp_reply_name(sftp_client_message msg, const char *name,
1232 sftp_attributes attr);
1233LIBSSH_API int sftp_reply_handle(sftp_client_message msg, ssh_string handle);
1234LIBSSH_API ssh_string sftp_handle_alloc(sftp_session sftp, void *info);
1235LIBSSH_API int sftp_reply_attr(sftp_client_message msg, sftp_attributes attr);
1236LIBSSH_API void *sftp_handle(sftp_session sftp, ssh_string handle);
1237LIBSSH_API int sftp_reply_status(sftp_client_message msg, uint32_t status, const char *message);
1238LIBSSH_API int sftp_reply_names_add(sftp_client_message msg, const char *file,
1239 const char *longname, sftp_attributes attr);
1240LIBSSH_API int sftp_reply_names(sftp_client_message msg);
1241LIBSSH_API int sftp_reply_data(sftp_client_message msg, const void *data, int len);
1242LIBSSH_API void sftp_handle_remove(sftp_session sftp, void *handle);
1243
1244/* SFTP commands and constants */
1245#define SSH_FXP_INIT 1
1246#define SSH_FXP_VERSION 2
1247#define SSH_FXP_OPEN 3
1248#define SSH_FXP_CLOSE 4
1249#define SSH_FXP_READ 5
1250#define SSH_FXP_WRITE 6
1251#define SSH_FXP_LSTAT 7
1252#define SSH_FXP_FSTAT 8
1253#define SSH_FXP_SETSTAT 9
1254#define SSH_FXP_FSETSTAT 10
1255#define SSH_FXP_OPENDIR 11
1256#define SSH_FXP_READDIR 12
1257#define SSH_FXP_REMOVE 13
1258#define SSH_FXP_MKDIR 14
1259#define SSH_FXP_RMDIR 15
1260#define SSH_FXP_REALPATH 16
1261#define SSH_FXP_STAT 17
1262#define SSH_FXP_RENAME 18
1263#define SSH_FXP_READLINK 19
1264#define SSH_FXP_SYMLINK 20
1265
1266#define SSH_FXP_STATUS 101
1267#define SSH_FXP_HANDLE 102
1268#define SSH_FXP_DATA 103
1269#define SSH_FXP_NAME 104
1270#define SSH_FXP_ATTRS 105
1271
1272#define SSH_FXP_EXTENDED 200
1273#define SSH_FXP_EXTENDED_REPLY 201
1274
1275/* attributes */
1276/* sftp draft is completely braindead : version 3 and 4 have different flags for same constants */
1277/* and even worst, version 4 has same flag for 2 different constants */
1278/* follow up : i won't develop any sftp4 compliant library before having a clarification */
1279
1280#define SSH_FILEXFER_ATTR_SIZE 0x00000001
1281#define SSH_FILEXFER_ATTR_PERMISSIONS 0x00000004
1282#define SSH_FILEXFER_ATTR_ACCESSTIME 0x00000008
1283#define SSH_FILEXFER_ATTR_ACMODTIME 0x00000008
1284#define SSH_FILEXFER_ATTR_CREATETIME 0x00000010
1285#define SSH_FILEXFER_ATTR_MODIFYTIME 0x00000020
1286#define SSH_FILEXFER_ATTR_ACL 0x00000040
1287#define SSH_FILEXFER_ATTR_OWNERGROUP 0x00000080
1288#define SSH_FILEXFER_ATTR_SUBSECOND_TIMES 0x00000100
1289#define SSH_FILEXFER_ATTR_EXTENDED 0x80000000
1290#define SSH_FILEXFER_ATTR_UIDGID 0x00000002
1291
1292/* types */
1293#define SSH_FILEXFER_TYPE_REGULAR 1
1294#define SSH_FILEXFER_TYPE_DIRECTORY 2
1295#define SSH_FILEXFER_TYPE_SYMLINK 3
1296#define SSH_FILEXFER_TYPE_SPECIAL 4
1297#define SSH_FILEXFER_TYPE_UNKNOWN 5
1298
1307#define SSH_FX_OK 0
1309#define SSH_FX_EOF 1
1311#define SSH_FX_NO_SUCH_FILE 2
1313#define SSH_FX_PERMISSION_DENIED 3
1315#define SSH_FX_FAILURE 4
1317#define SSH_FX_BAD_MESSAGE 5
1319#define SSH_FX_NO_CONNECTION 6
1321#define SSH_FX_CONNECTION_LOST 7
1323#define SSH_FX_OP_UNSUPPORTED 8
1325#define SSH_FX_INVALID_HANDLE 9
1327#define SSH_FX_NO_SUCH_PATH 10
1329#define SSH_FX_FILE_ALREADY_EXISTS 11
1331#define SSH_FX_WRITE_PROTECT 12
1333#define SSH_FX_NO_MEDIA 13
1334
1337/* file flags */
1338#define SSH_FXF_READ 0x01
1339#define SSH_FXF_WRITE 0x02
1340#define SSH_FXF_APPEND 0x04
1341#define SSH_FXF_CREAT 0x08
1342#define SSH_FXF_TRUNC 0x10
1343#define SSH_FXF_EXCL 0x20
1344#define SSH_FXF_TEXT 0x40
1345
1346/* file type flags */
1347#define SSH_S_IFMT 00170000
1348#define SSH_S_IFSOCK 0140000
1349#define SSH_S_IFLNK 0120000
1350#define SSH_S_IFREG 0100000
1351#define SSH_S_IFBLK 0060000
1352#define SSH_S_IFDIR 0040000
1353#define SSH_S_IFCHR 0020000
1354#define SSH_S_IFIFO 0010000
1355
1356/* rename flags */
1357#define SSH_FXF_RENAME_OVERWRITE 0x00000001
1358#define SSH_FXF_RENAME_ATOMIC 0x00000002
1359#define SSH_FXF_RENAME_NATIVE 0x00000004
1360
1361#define SFTP_OPEN SSH_FXP_OPEN
1362#define SFTP_CLOSE SSH_FXP_CLOSE
1363#define SFTP_READ SSH_FXP_READ
1364#define SFTP_WRITE SSH_FXP_WRITE
1365#define SFTP_LSTAT SSH_FXP_LSTAT
1366#define SFTP_FSTAT SSH_FXP_FSTAT
1367#define SFTP_SETSTAT SSH_FXP_SETSTAT
1368#define SFTP_FSETSTAT SSH_FXP_FSETSTAT
1369#define SFTP_OPENDIR SSH_FXP_OPENDIR
1370#define SFTP_READDIR SSH_FXP_READDIR
1371#define SFTP_REMOVE SSH_FXP_REMOVE
1372#define SFTP_MKDIR SSH_FXP_MKDIR
1373#define SFTP_RMDIR SSH_FXP_RMDIR
1374#define SFTP_REALPATH SSH_FXP_REALPATH
1375#define SFTP_STAT SSH_FXP_STAT
1376#define SFTP_RENAME SSH_FXP_RENAME
1377#define SFTP_READLINK SSH_FXP_READLINK
1378#define SFTP_SYMLINK SSH_FXP_SYMLINK
1379#define SFTP_EXTENDED SSH_FXP_EXTENDED
1380
1381/* openssh flags */
1382#define SSH_FXE_STATVFS_ST_RDONLY 0x1 /* read-only */
1383#define SSH_FXE_STATVFS_ST_NOSUID 0x2 /* no setuid */
1384
1385#ifdef __cplusplus
1386}
1387#endif
1388
1389#endif /* SFTP_H */
1390
LIBSSH_API sftp_attributes sftp_fstat(sftp_file file)
Get information about a file or directory from a file handle.
Definition sftp.c:3031
LIBSSH_API void sftp_file_set_nonblocking(sftp_file handle)
Make the sftp communication for this file handle non blocking.
Definition sftp.c:1133
LIBSSH_API int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode)
Create a directory.
Definition sftp.c:1673
LIBSSH_API int sftp_rename(sftp_session sftp, const char *original, const char *newname)
Rename or move a file or directory.
Definition sftp.c:1775
LIBSSH_API const char * sftp_extensions_get_name(sftp_session sftp, unsigned int indexn)
Get the name of the extension provided by the server.
Definition sftp.c:576
LIBSSH_API void sftp_statvfs_free(sftp_statvfs_t statvfs_o)
Free the memory of an allocated statvfs.
Definition sftp.c:2672
LIBSSH_API int sftp_utimes(sftp_session sftp, const char *file, const struct timeval *times)
Change the last modification and access time of a file.
Definition sftp.c:2087
LIBSSH_API sftp_attributes sftp_readdir(sftp_session session, sftp_dir dir)
Get a single file attributes structure of a directory.
Definition sftp.c:762
LIBSSH_API int sftp_seek64(sftp_file file, uint64_t new_offset)
Seek to a specific location in a file. This is the 64bit version.
Definition sftp.c:1501
LIBSSH_API int sftp_closedir(sftp_dir dir)
Close a directory handle opened by sftp_opendir().
Definition sftp.c:989
LIBSSH_API int sftp_close(sftp_file file)
Close an open file handle.
Definition sftp.c:970
LIBSSH_API char * sftp_expand_path(sftp_session sftp, const char *path)
Canonicalize path using expand-path@openssh.com extension.
Definition sftp.c:3102
SSH_DEPRECATED LIBSSH_API int sftp_server_init(sftp_session sftp)
Initialize the sftp server.
Definition sftp.c:261
LIBSSH_API ssize_t sftp_aio_wait_read(sftp_aio *aio, void *buf, size_t buf_size)
Wait for an asynchronous read to complete and store the read data in the supplied buffer.
Definition sftp_aio.c:137
LIBSSH_API void sftp_server_free(sftp_session sftp)
Close and deallocate a sftp server session.
Definition sftp.c:294
LIBSSH_API ssize_t sftp_aio_wait_write(sftp_aio *aio)
Wait for an asynchronous write to complete.
Definition sftp_aio.c:405
LIBSSH_API unsigned int sftp_extensions_get_count(sftp_session sftp)
Get the count of extensions provided by the server.
Definition sftp.c:568
LIBSSH_API void sftp_aio_free(sftp_aio aio)
Deallocate memory corresponding to a sftp aio handle.
Definition sftp_aio.c:48
LIBSSH_API int sftp_get_error(sftp_session sftp)
Get the last sftp error.
Definition sftp.c:409
LIBSSH_API unsigned long sftp_tell(sftp_file file)
Report current byte position in file.
Definition sftp.c:1513
LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file)
Unlink (delete) a file.
Definition sftp.c:1528
LIBSSH_API sftp_attributes sftp_lstat(sftp_session session, const char *path)
Get information about a file or directory.
Definition sftp.c:3027
SSH_DEPRECATED LIBSSH_API int sftp_async_read(sftp_file file, void *data, uint32_t len, uint32_t id)
Wait for an asynchronous read to complete and save the data.
Definition sftp.c:1307
LIBSSH_API sftp_statvfs_t sftp_fstatvfs(sftp_file file)
Get information about a mounted file system.
Definition sftp.c:2596
LIBSSH_API void sftp_free(sftp_session sftp)
Close and deallocate a sftp session.
Definition sftp.c:322
LIBSSH_API ssize_t sftp_aio_begin_read(sftp_file file, size_t len, sftp_aio *aio)
Start an asynchronous read from a file using an opened sftp file handle.
Definition sftp_aio.c:53
LIBSSH_API sftp_limits_t sftp_limits(sftp_session sftp)
Get information about the various limits the server might impose.
Definition sftp.c:2821
LIBSSH_API int sftp_lsetstat(sftp_session sftp, const char *file, sftp_attributes attr)
This request is like setstat (excluding mode and size) but sets file attributes on symlinks themselve...
Definition sftp.c:1975
LIBSSH_API int sftp_seek(sftp_file file, uint32_t new_offset)
Seek to a specific location in a file.
Definition sftp.c:1490
LIBSSH_API sftp_session sftp_server_new(ssh_session session, ssh_channel chan)
Create a new sftp server session.
Definition sftp.c:223
LIBSSH_API void sftp_attributes_free(sftp_attributes file)
Free a sftp attribute structure.
Definition sftp.c:880
LIBSSH_API void sftp_limits_free(sftp_limits_t limits)
Free the memory of an allocated limits.
Definition sftp.c:2848
LIBSSH_API sftp_attributes sftp_stat(sftp_session session, const char *path)
Get information about a file or directory.
Definition sftp.c:3023
LIBSSH_API const char * sftp_extensions_get_data(sftp_session sftp, unsigned int indexn)
Get the data of the extension provided by the server.
Definition sftp.c:592
LIBSSH_API uint64_t sftp_tell64(sftp_file file)
Report current byte position in file.
Definition sftp.c:1517
LIBSSH_API char * sftp_home_directory(sftp_session sftp, const char *username)
Get the specified user's home directory.
Definition sftp.c:3197
LIBSSH_API int sftp_chown(sftp_session sftp, const char *file, uid_t owner, gid_t group)
Change the file owner and group.
Definition sftp.c:2064
LIBSSH_API char * sftp_readlink(sftp_session sftp, const char *path)
Read the value of a symbolic link.
Definition sftp.c:2199
LIBSSH_API int sftp_extension_supported(sftp_session sftp, const char *name, const char *data)
Check if the given extension is supported.
Definition sftp.c:608
SSH_DEPRECATED LIBSSH_API int sftp_async_read_begin(sftp_file file, uint32_t len)
Start an asynchronous read from a file using an opened sftp file handle.
Definition sftp.c:1268
LIBSSH_API sftp_session sftp_new_channel(ssh_session session, ssh_channel channel)
Start a new sftp session with an existing channel.
Definition sftp.c:170
LIBSSH_API sftp_file sftp_open(sftp_session session, const char *file, int accesstype, mode_t mode)
Open a file on the server.
Definition sftp.c:1005
LIBSSH_API void sftp_file_set_blocking(sftp_file handle)
Make the sftp communication for this file handle blocking.
Definition sftp.c:1137
LIBSSH_API int sftp_rmdir(sftp_session sftp, const char *directory)
Remove a directory.
Definition sftp.c:1603
LIBSSH_API void sftp_rewind(sftp_file file)
Rewinds the position of the file pointer to the beginning of the file.
Definition sftp.c:1522
LIBSSH_API int sftp_dir_eof(sftp_dir dir)
Tell if the directory has reached EOF (End Of File).
Definition sftp.c:875
LIBSSH_API sftp_dir sftp_opendir(sftp_session session, const char *path)
Open a directory used to obtain directory entries.
Definition sftp.c:664
LIBSSH_API int sftp_init(sftp_session sftp)
Initialize the sftp protocol with the server.
Definition sftp.c:421
LIBSSH_API ssize_t sftp_read(sftp_file file, void *buf, size_t count)
Read from a file using an opened sftp file handle.
Definition sftp.c:1143
LIBSSH_API int sftp_server_version(sftp_session sftp)
Get the version of the SFTP protocol supported by the server.
Definition sftp.c:757
LIBSSH_API int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr)
Set file attributes on a file, directory or symbolic link.
Definition sftp.c:1888
LIBSSH_API char * sftp_canonicalize_path(sftp_session sftp, const char *path)
Canonicalize a sftp path.
Definition sftp.c:2858
LIBSSH_API int sftp_symlink(sftp_session sftp, const char *target, const char *dest)
Create a symbolic link.
Definition sftp.c:2104
LIBSSH_API ssize_t sftp_aio_begin_write(sftp_file file, const void *buf, size_t len, sftp_aio *aio)
Start an asynchronous write to a file using an opened sftp file handle.
Definition sftp_aio.c:310
LIBSSH_API sftp_session sftp_new(ssh_session session)
Creates a new sftp session.
Definition sftp.c:103
LIBSSH_API int sftp_chmod(sftp_session sftp, const char *file, mode_t mode)
Change permissions of a file.
Definition sftp.c:2077
LIBSSH_API sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path)
Get information about a mounted file system.
Definition sftp.c:2414
LIBSSH_API int sftp_fsync(sftp_file file)
Synchronize a file's in-core state with storage device.
Definition sftp.c:2497
LIBSSH_API ssize_t sftp_write(sftp_file file, const void *buf, size_t count)
Write to a file using an opened sftp file handle.
Definition sftp.c:1390
LIBSSH_API int sftp_hardlink(sftp_session sftp, const char *oldpath, const char *newpath)
Create a hard link.
Definition sftp.c:2292
Definition sftp_aio.c:35
Definition sftpserver.c:818
SFTP limits structure.
Definition sftp.h:209
uint64_t max_write_length
Definition sftp.h:212
uint64_t max_open_handles
Definition sftp.h:213
uint64_t max_read_length
Definition sftp.h:211
SFTP statvfs structure.
Definition sftp.h:192
uint64_t f_blocks
Definition sftp.h:195
uint64_t f_ffree
Definition sftp.h:199
uint64_t f_files
Definition sftp.h:198
uint64_t f_bavail
Definition sftp.h:197
uint64_t f_namemax
Definition sftp.h:203
uint64_t f_bfree
Definition sftp.h:196
uint64_t f_favail
Definition sftp.h:200
uint64_t f_flag
Definition sftp.h:202
uint64_t f_frsize
Definition sftp.h:194
uint64_t f_fsid
Definition sftp.h:201