aboutsummaryrefslogtreecommitdiff
path: root/sample.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-08-12 17:12:26 +0200
committerAndreas Schneider <mail@cynapses.org>2009-08-12 17:13:42 +0200
commit2dc3b5c67527b9403befb2d54c43a3fab23be4e2 (patch)
tree3ed03126c1f312ca47c2950a8d054a0a3dd83d08 /sample.c
parent63011c29a0922a7fd57a14bb2b45695e716a9b00 (diff)
downloadlibssh-2dc3b5c67527b9403befb2d54c43a3fab23be4e2.tar.gz
libssh-2dc3b5c67527b9403befb2d54c43a3fab23be4e2.tar.xz
libssh-2dc3b5c67527b9403befb2d54c43a3fab23be4e2.zip
Add sftp_extension_supported() function.
Diffstat (limited to 'sample.c')
-rw-r--r--sample.c118
1 files changed, 60 insertions, 58 deletions
diff --git a/sample.c b/sample.c
index c114b52..c38f9c7 100644
--- a/sample.c
+++ b/sample.c
@@ -327,66 +327,68 @@ void do_sftp(SSH_SESSION *session){
sftp_unlink(sftp_session, "/tmp/sftp_symlink_test");
- sftpstatvfs = sftp_statvfs(sftp_session, "/tmp");
- if (sftpstatvfs == NULL) {
- fprintf(stderr, "statvfs failed (%s)\n", ssh_get_error(session));
- return;
- }
+ if (sftp_extension_supported(sftp_session, "statvfs@openssh.com", "2")) {
+ sftpstatvfs = sftp_statvfs(sftp_session, "/tmp");
+ if (sftpstatvfs == NULL) {
+ fprintf(stderr, "statvfs failed (%s)\n", ssh_get_error(session));
+ return;
+ }
- printf("sftp statvfs:\n"
- "\tfile system block size: %llu\n"
- "\tfundamental fs block size: %llu\n"
- "\tnumber of blocks (unit f_frsize): %llu\n"
- "\tfree blocks in file system: %llu\n"
- "\tfree blocks for non-root: %llu\n"
- "\ttotal file inodes: %llu\n"
- "\tfree file inodes: %llu\n"
- "\tfree file inodes for to non-root: %llu\n"
- "\tfile system id: %llu\n"
- "\tbit mask of f_flag values: %llu\n"
- "\tmaximum filename length: %llu\n",
- sftpstatvfs->f_bsize,
- sftpstatvfs->f_frsize,
- sftpstatvfs->f_blocks,
- sftpstatvfs->f_bfree,
- sftpstatvfs->f_bavail,
- sftpstatvfs->f_files,
- sftpstatvfs->f_ffree,
- sftpstatvfs->f_favail,
- sftpstatvfs->f_fsid,
- sftpstatvfs->f_flag,
- sftpstatvfs->f_namemax);
-
- sftp_statvfs_free(sftpstatvfs);
-
- if (statvfs("/tmp", &sysstatvfs) < 0) {
- fprintf(stderr, "statvfs failed (%s)\n", strerror(errno));
- return;
- }
+ printf("sftp statvfs:\n"
+ "\tfile system block size: %llu\n"
+ "\tfundamental fs block size: %llu\n"
+ "\tnumber of blocks (unit f_frsize): %llu\n"
+ "\tfree blocks in file system: %llu\n"
+ "\tfree blocks for non-root: %llu\n"
+ "\ttotal file inodes: %llu\n"
+ "\tfree file inodes: %llu\n"
+ "\tfree file inodes for to non-root: %llu\n"
+ "\tfile system id: %llu\n"
+ "\tbit mask of f_flag values: %llu\n"
+ "\tmaximum filename length: %llu\n",
+ sftpstatvfs->f_bsize,
+ sftpstatvfs->f_frsize,
+ sftpstatvfs->f_blocks,
+ sftpstatvfs->f_bfree,
+ sftpstatvfs->f_bavail,
+ sftpstatvfs->f_files,
+ sftpstatvfs->f_ffree,
+ sftpstatvfs->f_favail,
+ sftpstatvfs->f_fsid,
+ sftpstatvfs->f_flag,
+ sftpstatvfs->f_namemax);
+
+ sftp_statvfs_free(sftpstatvfs);
+
+ if (statvfs("/tmp", &sysstatvfs) < 0) {
+ fprintf(stderr, "statvfs failed (%s)\n", strerror(errno));
+ return;
+ }
- printf("sys statvfs:\n"
- "\tfile system block size: %llu\n"
- "\tfundamental fs block size: %llu\n"
- "\tnumber of blocks (unit f_frsize): %llu\n"
- "\tfree blocks in file system: %llu\n"
- "\tfree blocks for non-root: %llu\n"
- "\ttotal file inodes: %llu\n"
- "\tfree file inodes: %llu\n"
- "\tfree file inodes for to non-root: %llu\n"
- "\tfile system id: %llu\n"
- "\tbit mask of f_flag values: %llu\n"
- "\tmaximum filename length: %llu\n",
- sysstatvfs.f_bsize,
- sysstatvfs.f_frsize,
- sysstatvfs.f_blocks,
- sysstatvfs.f_bfree,
- sysstatvfs.f_bavail,
- sysstatvfs.f_files,
- sysstatvfs.f_ffree,
- sysstatvfs.f_favail,
- sysstatvfs.f_fsid,
- sysstatvfs.f_flag,
- sysstatvfs.f_namemax);
+ printf("sys statvfs:\n"
+ "\tfile system block size: %llu\n"
+ "\tfundamental fs block size: %llu\n"
+ "\tnumber of blocks (unit f_frsize): %llu\n"
+ "\tfree blocks in file system: %llu\n"
+ "\tfree blocks for non-root: %llu\n"
+ "\ttotal file inodes: %llu\n"
+ "\tfree file inodes: %llu\n"
+ "\tfree file inodes for to non-root: %llu\n"
+ "\tfile system id: %llu\n"
+ "\tbit mask of f_flag values: %llu\n"
+ "\tmaximum filename length: %llu\n",
+ sysstatvfs.f_bsize,
+ sysstatvfs.f_frsize,
+ sysstatvfs.f_blocks,
+ sysstatvfs.f_bfree,
+ sysstatvfs.f_bavail,
+ sysstatvfs.f_files,
+ sysstatvfs.f_ffree,
+ sysstatvfs.f_favail,
+ sysstatvfs.f_fsid,
+ sysstatvfs.f_flag,
+ sysstatvfs.f_namemax);
+ }
/* the connection is made */
/* opening a directory */