Implement an example for statvfs.
Этот коммит содержится в:
родитель
e68c3b09a6
Коммит
63011c29a0
65
sample.c
65
sample.c
@ -21,6 +21,7 @@ clients must be made or how a client should react.
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/statvfs.h>
|
||||
#ifdef HAVE_PTY_H
|
||||
#include <pty.h>
|
||||
#endif
|
||||
@ -280,6 +281,8 @@ void do_sftp(SSH_SESSION *session){
|
||||
SFTP_SESSION *sftp_session=sftp_new(session);
|
||||
SFTP_DIR *dir;
|
||||
SFTP_ATTRIBUTES *file;
|
||||
SFTP_STATVFS *sftpstatvfs;
|
||||
struct statvfs sysstatvfs;
|
||||
SFTP_FILE *fichier;
|
||||
SFTP_FILE *to;
|
||||
int len=1;
|
||||
@ -324,6 +327,67 @@ 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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
/* the connection is made */
|
||||
/* opening a directory */
|
||||
dir=sftp_opendir(sftp_session,"./");
|
||||
@ -388,6 +452,7 @@ void do_sftp(SSH_SESSION *session){
|
||||
}
|
||||
}
|
||||
sftp_close(to);
|
||||
|
||||
/* close the sftp session */
|
||||
sftp_free(sftp_session);
|
||||
printf("sftp session terminated\n");
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user