sftpfs: define st_blksize and st_blocks.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-12-30 15:04:34 +03:00
parent a8a8e85279
commit 95556224a6
3 changed files with 26 additions and 0 deletions

View File

@ -217,7 +217,10 @@ sftpfs_fstat (void *data, struct stat *buf, GError ** mcerror)
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) != 0)
{
buf->st_size = attrs.filesize;
sftpfs_blksize (buf);
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) != 0)
buf->st_mode = attrs.permissions;

View File

@ -119,6 +119,22 @@ sftpfs_waitsocket (sftpfs_super_data_t * super_data, GError ** mcerror)
return select (super_data->socket_handle + 1, readfd, writefd, NULL, &timeout);
}
/* --------------------------------------------------------------------------------------------- */
/* Adjust block size and number of blocks */
void
sftpfs_blksize (struct stat *s)
{
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
s->st_blksize = LIBSSH2_CHANNEL_WINDOW_DEFAULT; /* FIXME */
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
/* In according to stat(2), this is the size in 512-byte units */
s->st_blocks = 1 + ((s->st_size - 1) / 512);
#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
}
/* --------------------------------------------------------------------------------------------- */
/**
* Getting information about a symbolic link.
@ -188,7 +204,10 @@ sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror)
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) != 0)
{
buf->st_size = attrs.filesize;
sftpfs_blksize (buf);
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) != 0)
buf->st_mode = attrs.permissions;
@ -267,7 +286,10 @@ sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror)
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) != 0)
{
buf->st_size = attrs.filesize;
sftpfs_blksize (buf);
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) != 0)
buf->st_mode = attrs.permissions;

View File

@ -71,6 +71,7 @@ void sftpfs_ssherror_to_gliberror (sftpfs_super_data_t * super_data, int libssh_
int sftpfs_waitsocket (sftpfs_super_data_t * super_data, GError ** mcerror);
const char *sftpfs_fix_filename (const char *file_name);
void sftpfs_blksize (struct stat *s);
int sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
int sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
int sftpfs_readlink (const vfs_path_t * vpath, char *buf, size_t size, GError ** mcerror);