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
3 changes: 2 additions & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,15 @@ int dis_getopts(dis_context_t dis_ctx, int argc, char** argv)
int trueval = TRUE;


long_opts = malloc(nb_options * sizeof(struct option));
long_opts = calloc(nb_options + 1, sizeof(struct option));
while(nb_options--)
{
long_opts[nb_options].name = dis_opt[nb_options].opt.name;
long_opts[nb_options].has_arg = dis_opt[nb_options].opt.has_arg;
long_opts[nb_options].flag = dis_opt[nb_options].opt.flag;
long_opts[nb_options].val = dis_opt[nb_options].opt.val;
}
/* long_opts[nb_options+1] is the required {NULL,0,NULL,0} sentinel, zeroed by calloc */


while((optchar = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1)
Expand Down
24 changes: 23 additions & 1 deletion src/dislocker-fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,59 @@ dis_context_t dis_ctx;
/**
* Stubs used for FUSE operations.
*/
#ifdef __APPLE__
static int fs_getattr(const char *path, struct fuse_darwin_attr *stbuf,
struct fuse_file_info *fi)
#else
static int fs_getattr(const char *path, struct stat *stbuf,
struct fuse_file_info *fi)
#endif
{
(void) fi;
int res = 0;

if(!path || !stbuf)
return -EINVAL;

memset(stbuf, 0, sizeof(struct stat));
memset(stbuf, 0, sizeof(*stbuf));
if(strcmp(path, "/") == 0)
{
#ifdef __APPLE__
stbuf->mode = S_IFDIR | 0555;
stbuf->nlink = 2;
#else
stbuf->st_mode = S_IFDIR | 0555;
stbuf->st_nlink = 2;
#endif
}
else if(strcmp(path, NTFS_FILERELATIVEPATH) == 0)
{
mode_t m = dis_is_read_only(dis_ctx) ? 0444 : 0666;
#ifdef __APPLE__
stbuf->mode = S_IFREG | m;
stbuf->nlink = 1;
stbuf->size = (off_t)dis_inouts_volume_size(dis_ctx);
#else
stbuf->st_mode = S_IFREG | m;
stbuf->st_nlink = 1;
stbuf->st_size = (off_t)dis_inouts_volume_size(dis_ctx);
#endif
}
else
res = -ENOENT;

return res;
}

#ifdef __APPLE__
static int fs_readdir(const char *path, void *buf, fuse_darwin_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi,
enum fuse_readdir_flags flags)
#else
static int fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi,
enum fuse_readdir_flags flags)
#endif
{
/* Both variables aren't used here */
(void) offset;
Expand Down