1libssh2_sftp_fstat_ex(3) libssh2 libssh2_sftp_fstat_ex(3)
2
3
4
6 libssh2_sftp_fstat_ex - get or set attributes on an SFTP file handle
7
9 #include <libssh2.h>
10 #include <libssh2_sftp.h>
11
12 int
13 libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *handle,
14 LIBSSH2_SFTP_ATTRIBUTES *attrs, int setstat)
15
16 #define libssh2_sftp_fstat(handle, attrs) \
17 libssh2_sftp_fstat_ex((handle), (attrs), 0)
18 #define libssh2_sftp_fsetstat(handle, attrs) \
19 libssh2_sftp_fstat_ex((handle), (attrs), 1)
20
22 handle - SFTP File Handle as returned by libssh2_sftp_open_ex(3)
23
24 attrs - Pointer to an LIBSSH2_SFTP_ATTRIBUTES structure to set file
25 metadata from or into depending on the value of setstat.
26
27 setstat - When non-zero, the file's metadata will be updated with the
28 data found in attrs according to the values of attrs->flags and other
29 relevant member attributes.
30
31 Get or Set statbuf type data for a given LIBSSH2_SFTP_HANDLE instance.
32
34 LIBSSH2_SFTP_ATTRIBUTES is a typedefed struct that is defined as below
35
36 struct _LIBSSH2_SFTP_ATTRIBUTES {
37
38 /* If flags & ATTR_* bit is set, then the value in this
39 * struct will be meaningful Otherwise it should be ignored
40 */
41 unsigned long flags;
42
43 /* size of file, in bytes */
44 libssh2_uint64_t filesize;
45
46 /* numerical representation of the user and group owner of
47 * the file
48 */
49 unsigned long uid, gid;
50
51 /* bitmask of permissions */
52 unsigned long permissions;
53
54 /* access time and modified time of file */
55 unsigned long atime, mtime;
56 };
57
58 You will find a full set of defines and macros to identify flags and
59 permissions on the libssh2_sftp.h header file, but some of the most
60 common ones are:
61
62 To check for specific user permissions, the set of defines are in the
63 pattern LIBSSH2_SFTP_S_I<action><who> where <action> is R, W or X for
64 read, write and executable and <who> is USR, GRP and OTH for user,
65 group and other. So, you check for a user readable file, use the bit
66 LIBSSH2_SFTP_S_IRUSR while you want to see if it is executable for
67 other, you use LIBSSH2_SFTP_S_IXOTH and so on.
68
69 To check for specific file types, you would previously (before libssh2
70 1.2.5) use the standard posix S_IS***() macros, but since 1.2.5 libssh2
71 offers its own set of macros for this functionality:
72
73 LIBSSH2_SFTP_S_ISLNK
74 Test for a symbolic link
75
76 LIBSSH2_SFTP_S_ISREG
77 Test for a regular file
78
79 LIBSSH2_SFTP_S_ISDIR
80 Test for a directory
81
82 LIBSSH2_SFTP_S_ISCHR
83 Test for a character special file
84
85 LIBSSH2_SFTP_S_ISBLK
86 Test for a block special file
87
88 LIBSSH2_SFTP_S_ISFIFO
89 Test for a pipe or FIFO special file
90
91 LIBSSH2_SFTP_S_ISSOCK
92 Test for a socket
93
95 Return 0 on success or negative on failure. It returns LIBSSH2_ER‐
96 ROR_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is
97 a negative number, it is not really a failure per se.
98
100 LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed.
101
102 LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket.
103
104 LIBSSH2_ERROR_SOCKET_TIMEOUT -
105
106 LIBSSH2_ERROR_SFTP_PROTOCOL - An invalid SFTP protocol response was re‐
107 ceived on the socket, or an SFTP operation caused an errorcode to be
108 returned by the server.
109
111 This function has been around since forever, but most of the LIB‐
112 SSH2_SFTP_S_* defines were introduced in libssh2 0.14 and the LIB‐
113 SSH2_SFTP_S_IS***() macros were introduced in libssh2 1.2.5.
114
116 libssh2_sftp_open_ex(3)
117
118
119
120libssh2 0.15 1 Jun 2007 libssh2_sftp_fstat_ex(3)