add FUSE support for VolumeLabel via "volname" option

* closes #64
This commit is contained in:
Sam Kelly 2017-03-19 00:08:28 -04:00
parent 83cd3cab99
commit c085a91991
3 changed files with 18 additions and 2 deletions

View File

@ -40,6 +40,7 @@ struct fsp_fuse_core_opt_data
rellinks; rellinks;
int set_FileInfoTimeout; int set_FileInfoTimeout;
FSP_FSCTL_VOLUME_PARAMS VolumeParams; FSP_FSCTL_VOLUME_PARAMS VolumeParams;
WCHAR VolumeLabel[32];
}; };
static struct fuse_opt fsp_fuse_core_opts[] = static struct fuse_opt fsp_fuse_core_opts[] =
@ -77,6 +78,7 @@ static struct fuse_opt fsp_fuse_core_opts[] =
FUSE_OPT_KEY("intr", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("intr", FUSE_OPT_KEY_DISCARD),
FUSE_OPT_KEY("intr_signal=", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("intr_signal=", FUSE_OPT_KEY_DISCARD),
FUSE_OPT_KEY("modules=", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("modules=", FUSE_OPT_KEY_DISCARD),
FUSE_OPT_KEY("volname=", 'v'),
FSP_FUSE_CORE_OPT("rellinks", rellinks, 1), FSP_FUSE_CORE_OPT("rellinks", rellinks, 1),
FSP_FUSE_CORE_OPT("norellinks", rellinks, 0), FSP_FUSE_CORE_OPT("norellinks", rellinks, 0),
@ -505,6 +507,11 @@ static int fsp_fuse_core_opt_proc(void *opt_data0, const char *arg, int key,
[sizeof opt_data->VolumeParams.FileSystemName / sizeof(WCHAR) - 1] = L'\0'; [sizeof opt_data->VolumeParams.FileSystemName / sizeof(WCHAR) - 1] = L'\0';
memcpy(opt_data->VolumeParams.FileSystemName, L"FUSE-", 5 * sizeof(WCHAR)); memcpy(opt_data->VolumeParams.FileSystemName, L"FUSE-", 5 * sizeof(WCHAR));
return 0; return 0;
case 'v':
arg += sizeof "volname" - 1;
memcpy(&opt_data->VolumeLabel, arg, sizeof opt_data->VolumeLabel);
opt_data->VolumeLabel[sizeof opt_data->VolumeLabel - 1] = L'\0';
return 0;
} }
} }
@ -514,6 +521,8 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env,
{ {
struct fuse *f = 0; struct fuse *f = 0;
struct fsp_fuse_core_opt_data opt_data; struct fsp_fuse_core_opt_data opt_data;
opt_data.VolumeLabel[0] = L'\0';
ULONG Size; ULONG Size;
PWSTR ErrorMessage = L"."; PWSTR ErrorMessage = L".";
NTSTATUS Result; NTSTATUS Result;
@ -589,6 +598,7 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env,
f->data = data; f->data = data;
f->DebugLog = opt_data.debug ? -1 : 0; f->DebugLog = opt_data.debug ? -1 : 0;
memcpy(&f->VolumeParams, &opt_data.VolumeParams, sizeof opt_data.VolumeParams); memcpy(&f->VolumeParams, &opt_data.VolumeParams, sizeof opt_data.VolumeParams);
memcpy(&f->VolumeLabel, &opt_data.VolumeLabel, sizeof opt_data.VolumeLabel);
Size = (lstrlenW(ch->MountPoint) + 1) * sizeof(WCHAR); Size = (lstrlenW(ch->MountPoint) + 1) * sizeof(WCHAR);
f->MountPoint = fsp_fuse_obj_alloc(env, Size); f->MountPoint = fsp_fuse_obj_alloc(env, Size);

View File

@ -646,8 +646,13 @@ static NTSTATUS fsp_fuse_intf_GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem,
VolumeInfo->TotalSize = (UINT64)stbuf.f_blocks * (UINT64)stbuf.f_frsize; VolumeInfo->TotalSize = (UINT64)stbuf.f_blocks * (UINT64)stbuf.f_frsize;
VolumeInfo->FreeSize = (UINT64)stbuf.f_bfree * (UINT64)stbuf.f_frsize; VolumeInfo->FreeSize = (UINT64)stbuf.f_bfree * (UINT64)stbuf.f_frsize;
VolumeInfo->VolumeLabelLength = 0;
VolumeInfo->VolumeLabel[0] = L'\0'; memcpy(&VolumeInfo->VolumeLabel, &f->VolumeLabel, sizeof f->VolumeLabel);
int i;
for(i = 0; i < sizeof VolumeInfo->VolumeLabel; i++)
if(VolumeInfo->VolumeLabel[i] == L'\0')
break;
VolumeInfo->VolumeLabelLength = (UINT16)i;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View File

@ -48,6 +48,7 @@ struct fuse
PWSTR MountPoint; PWSTR MountPoint;
FSP_FILE_SYSTEM *FileSystem; FSP_FILE_SYSTEM *FileSystem;
FSP_SERVICE *Service; /* weak */ FSP_SERVICE *Service; /* weak */
WCHAR VolumeLabel[32];
}; };
struct fsp_fuse_context_header struct fsp_fuse_context_header