Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions qcowtools/mount_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ extern mount_handle_t *qcowmount_mount_handle;
* Returns 1 if successful or -1 on error
*/
int mount_fuse_set_stat_info(
#ifdef __APPLE__
struct fuse_darwin_attr *stat_info,
#else
struct stat *stat_info,
#endif
size64_t size,
uint16_t file_mode,
int64_t access_time,
Expand Down Expand Up @@ -91,6 +95,34 @@ int mount_fuse_set_stat_info(

return( -1 );
}
#ifdef __APPLE__
stat_info->size = (off_t) size;
stat_info->mode = file_mode;

if( ( file_mode & 0x4000 ) != 0 )
{
stat_info->nlink = 2;
}
else
{
stat_info->nlink = 1;
}
#if defined( HAVE_GETEUID )
stat_info->uid = geteuid();
#endif
#if defined( HAVE_GETEGID )
stat_info->gid = getegid();
#endif

stat_info->atimespec.tv_sec = access_time / 1000000000;
stat_info->atimespec.tv_nsec = access_time % 1000000000;

stat_info->ctimespec.tv_sec = inode_change_time / 1000000000;
stat_info->ctimespec.tv_nsec = inode_change_time % 1000000000;

stat_info->mtimespec.tv_sec = modification_time / 1000000000;
stat_info->mtimespec.tv_nsec = modification_time % 1000000000;
#else
stat_info->st_size = (off_t) size;
stat_info->st_mode = file_mode;

Expand All @@ -117,6 +149,7 @@ int mount_fuse_set_stat_info(
stat_info->st_atime_nsec = access_time % 1000000000;
stat_info->st_ctime_nsec = inode_change_time % 1000000000;
stat_info->st_mtime_nsec = modification_time % 1000000000;
#endif
#endif
return( 1 );
}
Expand All @@ -126,9 +159,15 @@ int mount_fuse_set_stat_info(
*/
int mount_fuse_filldir(
void *buffer,
#ifdef __APPLE__
fuse_darwin_fill_dir_t filler,
const char *name,
struct fuse_darwin_attr *stat_info, // Change parameter type here
#else
fuse_fill_dir_t filler,
const char *name,
struct stat *stat_info,
#endif
mount_file_entry_t *file_entry,
libcerror_error_t **error )
{
Expand Down Expand Up @@ -668,20 +707,32 @@ int mount_fuse_opendir(
int mount_fuse_readdir(
const char *path,
void *buffer,
#ifdef __APPLE__
fuse_darwin_fill_dir_t filler,
#else
fuse_fill_dir_t filler,
#endif
off_t offset QCOWTOOLS_ATTRIBUTE_UNUSED,
struct fuse_file_info *file_info QCOWTOOLS_ATTRIBUTE_UNUSED,
enum fuse_readdir_flags flags QCOWTOOLS_ATTRIBUTE_UNUSED )
#else
int mount_fuse_readdir(
const char *path,
void *buffer,
#ifdef __APPLE__
fuse_darwin_fill_dir_t filler,
#else
fuse_fill_dir_t filler,
#endif
off_t offset QCOWTOOLS_ATTRIBUTE_UNUSED,
struct fuse_file_info *file_info QCOWTOOLS_ATTRIBUTE_UNUSED )
#endif
{
#ifdef __APPLE__
struct fuse_darwin_attr *stat_info = NULL;
#else
struct stat *stat_info = NULL;
#endif
libcerror_error_t *error = NULL;
mount_file_entry_t *parent_file_entry = NULL;
mount_file_entry_t *sub_file_entry = NULL;
Expand Down Expand Up @@ -747,7 +798,11 @@ int mount_fuse_readdir(
goto on_error;
}
stat_info = memory_allocate_structure(
#ifdef __APPLE__
struct fuse_darwin_attr );
#else
struct stat );
#endif

if( stat_info == NULL )
{
Expand Down Expand Up @@ -1070,13 +1125,22 @@ int mount_fuse_releasedir(
#if defined( HAVE_LIBFUSE3 )
int mount_fuse_getattr(
const char *path,
#ifdef __APPLE__
struct fuse_darwin_attr *stat_info,
#else
struct stat *stat_info,
#endif
struct fuse_file_info *file_info QCOWTOOLS_ATTRIBUTE_UNUSED )
#else
int mount_fuse_getattr(
const char *path,
#ifdef __APPLE__
struct fuse_darwin_attr *stat_info,
struct fuse_file_info *file_info )
#else
struct stat *stat_info )
#endif
#endif
{
libcerror_error_t *error = NULL;
mount_file_entry_t *file_entry = NULL;
Expand Down
27 changes: 27 additions & 0 deletions qcowtools/mount_fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ extern "C" {
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE )

int mount_fuse_set_stat_info(
#ifdef __APPLE__
struct fuse_darwin_attr *stat_info,
#else
struct stat *stat_info,
#endif
size64_t size,
uint16_t file_mode,
int64_t access_time,
Expand All @@ -69,9 +73,15 @@ int mount_fuse_set_stat_info(

int mount_fuse_filldir(
void *buffer,
#ifdef __APPLE__
fuse_darwin_fill_dir_t filler,
const char *name,
struct fuse_darwin_attr *stat_info,
#else
fuse_fill_dir_t filler,
const char *name,
struct stat *stat_info,
#endif
mount_file_entry_t *file_entry,
libcerror_error_t **error );

Expand All @@ -98,15 +108,23 @@ int mount_fuse_opendir(
int mount_fuse_readdir(
const char *path,
void *buffer,
#ifdef __APPLE__
fuse_darwin_fill_dir_t filler,
#else
fuse_fill_dir_t filler,
#endif
off_t offset,
struct fuse_file_info *file_info,
enum fuse_readdir_flags flags );
#else
int mount_fuse_readdir(
const char *path,
void *buffer,
#ifdef __APPLE__
fuse_darwin_fill_dir_t filler,
#else
fuse_fill_dir_t filler,
#endif
off_t offset,
struct fuse_file_info *file_info );
#endif
Expand All @@ -118,13 +136,22 @@ int mount_fuse_releasedir(
#if defined( HAVE_LIBFUSE3 )
int mount_fuse_getattr(
const char *path,
#ifdef __APPLE__
struct fuse_darwin_attr *stat_info,
#else
struct stat *stat_info,
#endif
struct fuse_file_info *file_info );
#else
int mount_fuse_getattr(
const char *path,
#ifdef __APPLE__
struct fuse_darwin_attr *stat_info,
struct fuse_file_info *file_info );
#else
struct stat *stat_info );
#endif
#endif

void mount_fuse_destroy(
void *private_data );
Expand Down