mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-31 03:58:38 -05:00 
			
		
		
		
	dll: fuse: implementation checkpoint
This commit is contained in:
		| @@ -23,20 +23,76 @@ | ||||
| struct fsp_fuse_core_opt_data | ||||
| { | ||||
|     struct fsp_fuse_env *env; | ||||
|     int debug; | ||||
|     int help; | ||||
|     int help, debug; | ||||
|     int hard_remove, use_ino, readdir_ino, direct_io, | ||||
|         kernel_cache, auto_cache, set_umask, umask, | ||||
|         set_uid, uid, set_gid, gid, | ||||
|         set_attr_timeout, attr_timeout; | ||||
|     FILETIME VolumeCreationTime; | ||||
|     int set_FileInfoTimeout; | ||||
|     int CaseSensitiveSearch, CasePreservedNames, UnicodeOnDisk, PersistentAcls, | ||||
|         ReparsePoints, NamedStreams, ReadOnlyVolume; | ||||
|     FSP_FSCTL_VOLUME_PARAMS VolumeParams; | ||||
| }; | ||||
|  | ||||
| static struct fuse_opt fsp_fuse_core_opts[] = | ||||
| { | ||||
|     FSP_FUSE_CORE_OPT("-d", debug, 1), | ||||
|     FSP_FUSE_CORE_OPT("debug", debug, 1), | ||||
|     FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP), | ||||
|     FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), | ||||
|     FUSE_OPT_KEY("-h", 'h'), | ||||
|     FUSE_OPT_KEY("--help", 'h'), | ||||
|     FUSE_OPT_KEY("-V", 'V'), | ||||
|     FUSE_OPT_KEY("--version", 'V'), | ||||
|     FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP), | ||||
|     FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), | ||||
|     FSP_FUSE_CORE_OPT("-d", debug, 1), | ||||
|     FSP_FUSE_CORE_OPT("debug", debug, 1), | ||||
|  | ||||
|     FSP_FUSE_CORE_OPT("hard_remove", hard_remove, 1), | ||||
|     FSP_FUSE_CORE_OPT("use_ino", use_ino, 1), | ||||
|     FSP_FUSE_CORE_OPT("readdir_ino", readdir_ino, 1), | ||||
|     FSP_FUSE_CORE_OPT("direct_io", direct_io, 1), | ||||
|     FSP_FUSE_CORE_OPT("kernel_cache", kernel_cache, 1), | ||||
|     FSP_FUSE_CORE_OPT("auto_cache", auto_cache, 1), | ||||
|     FSP_FUSE_CORE_OPT("noauto_cache", auto_cache, 0), | ||||
|     FSP_FUSE_CORE_OPT("umask=", set_umask, 1), | ||||
|     FSP_FUSE_CORE_OPT("umask=%o", umask, 0), | ||||
|     FSP_FUSE_CORE_OPT("uid=", set_uid, 1), | ||||
|     FSP_FUSE_CORE_OPT("uid=%d", uid, 0), | ||||
|     FSP_FUSE_CORE_OPT("gid=", set_gid, 1), | ||||
|     FSP_FUSE_CORE_OPT("gid=%d", gid, 0), | ||||
|     FUSE_OPT_KEY("entry_timeout", FUSE_OPT_KEY_DISCARD), | ||||
|     FSP_FUSE_CORE_OPT("attr_timeout=", set_attr_timeout, 1), | ||||
|     FSP_FUSE_CORE_OPT("attr_timeout=%d", attr_timeout, 0), | ||||
|     FUSE_OPT_KEY("ac_attr_timeout", FUSE_OPT_KEY_DISCARD), | ||||
|     FUSE_OPT_KEY("negative_timeout", FUSE_OPT_KEY_DISCARD), | ||||
|     FUSE_OPT_KEY("noforget", FUSE_OPT_KEY_DISCARD), | ||||
|     FUSE_OPT_KEY("intr", FUSE_OPT_KEY_DISCARD), | ||||
|     FUSE_OPT_KEY("intr_signal=", FUSE_OPT_KEY_DISCARD), | ||||
|     FUSE_OPT_KEY("modules=", FUSE_OPT_KEY_DISCARD), | ||||
|  | ||||
|     FSP_FUSE_CORE_OPT("SectorSize=%hu", VolumeParams.SectorSize, 4096), | ||||
|     FSP_FUSE_CORE_OPT("SectorsPerAllocationUnit=%hu", VolumeParams.SectorsPerAllocationUnit, 1), | ||||
|     FSP_FUSE_CORE_OPT("MaxComponentLength=%hu", VolumeParams.MaxComponentLength, 0), | ||||
|     FSP_FUSE_CORE_OPT("VolumeCreationTime=%llx", VolumeCreationTime, 0), | ||||
|     FSP_FUSE_CORE_OPT("VolumeCreationTimeLo=%x", VolumeCreationTime.dwLowDateTime, 0), | ||||
|     FSP_FUSE_CORE_OPT("VolumeCreationTimeHi=%x", VolumeCreationTime.dwHighDateTime, 0), | ||||
|     FSP_FUSE_CORE_OPT("VolumeSerialNumber=%lx", VolumeParams.VolumeSerialNumber, 0), | ||||
|     FSP_FUSE_CORE_OPT("TransactTimeout=%u", VolumeParams.TransactTimeout, 0), | ||||
|     FSP_FUSE_CORE_OPT("IrpTimeout=%u", VolumeParams.IrpTimeout, 0), | ||||
|     FSP_FUSE_CORE_OPT("IrpCapacity=%u", VolumeParams.IrpCapacity, 0), | ||||
|     FSP_FUSE_CORE_OPT("FileInfoTimeout=", set_FileInfoTimeout, 1), | ||||
|     FSP_FUSE_CORE_OPT("FileInfoTimeout=%d", VolumeParams.FileInfoTimeout, 0), | ||||
|     FSP_FUSE_CORE_OPT("CaseSensitiveSearch", CaseSensitiveSearch, 1), | ||||
|     FSP_FUSE_CORE_OPT("CasePreservedNames", CasePreservedNames, 1), | ||||
|     FSP_FUSE_CORE_OPT("UnicodeOnDisk", UnicodeOnDisk, 1), | ||||
|     FSP_FUSE_CORE_OPT("PersistentAcls", PersistentAcls, 1), | ||||
|     FSP_FUSE_CORE_OPT("ReparsePoints", ReparsePoints, 1), | ||||
|     FSP_FUSE_CORE_OPT("NamedStreams", NamedStreams, 1), | ||||
|     FUSE_OPT_KEY("HardLinks", FUSE_OPT_KEY_DISCARD), | ||||
|     FUSE_OPT_KEY("ExtendedAttributes", FUSE_OPT_KEY_DISCARD), | ||||
|     FSP_FUSE_CORE_OPT("ReadOnlyVolume", ReadOnlyVolume, 1), | ||||
|     FUSE_OPT_KEY("--UNC=", 'U'), | ||||
|     FUSE_OPT_KEY("--VolumePrefix=", 'U'), | ||||
|  | ||||
|     FUSE_OPT_END, | ||||
| }; | ||||
|  | ||||
| @@ -161,33 +217,6 @@ FSP_FUSE_API int fsp_fuse_is_lib_option(struct fsp_fuse_env *env, | ||||
|     return fsp_fuse_opt_match(env, fsp_fuse_core_opts, opt); | ||||
| } | ||||
|  | ||||
| static int fsp_fuse_core_opt_proc(void *opt_data0, const char *arg, int key, | ||||
|     struct fuse_args *outargs) | ||||
| { | ||||
|     struct fsp_fuse_core_opt_data *opt_data = opt_data0; | ||||
|  | ||||
|     switch (key) | ||||
|     { | ||||
|     default: | ||||
|         return 1; | ||||
|     case 'h': | ||||
| #if 0 | ||||
|         FspServiceLog(EVENTLOG_ERROR_TYPE, L"" | ||||
|             "Core options:\n" | ||||
|             "    -d   -o debug          enable debug output (implies -f)\n" | ||||
|             "\n"); | ||||
| #endif | ||||
|         opt_data->help = 1; | ||||
|         return 1; | ||||
|     case 'V': | ||||
|         FspServiceLog(EVENTLOG_ERROR_TYPE, | ||||
|             L"" LIBRARY_NAME "-FUSE version %d.%d", | ||||
|             FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION); | ||||
|         opt_data->help = 1; | ||||
|         return 1; | ||||
|     } | ||||
| } | ||||
|  | ||||
| static NTSTATUS fsp_fuse_svcstart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv) | ||||
| { | ||||
|     struct fuse *f = Service->UserContext; | ||||
| @@ -204,6 +233,53 @@ static NTSTATUS fsp_fuse_svcstop(FSP_SERVICE *Service) | ||||
|     return STATUS_SUCCESS; | ||||
| } | ||||
|  | ||||
| static int fsp_fuse_core_opt_proc(void *opt_data0, const char *arg, int key, | ||||
|     struct fuse_args *outargs) | ||||
| { | ||||
|     struct fsp_fuse_core_opt_data *opt_data = opt_data0; | ||||
|  | ||||
|     switch (key) | ||||
|     { | ||||
|     default: | ||||
|         return 1; | ||||
|     case 'h': | ||||
|         FspServiceLog(EVENTLOG_ERROR_TYPE, L"" | ||||
|             LIBRARY_NAME "-FUSE options:\n" | ||||
|             "    -o SectorSize=N        sector size for Windows (512-4096, deflt: 4096)\n" | ||||
|             "    -o SectorsPerAllocationUnit=N  allocation unit size (deflt: 1*SectorSize)\n" | ||||
|             "    -o MaxComponentLength=N    max file name component length (deflt: 255)\n" | ||||
|             "    -o VolumeCreationTime=T    volume creation time (FILETIME hex format)\n" | ||||
|             "    -o VolumeSerialNumber=N    32-bit wide\n" | ||||
|             "    -o FileInfoTimeout=N       FileInfo/Security/VolumeInfo timeout (millisec)\n" | ||||
|             "    -o CaseSensitiveSearch     file system supports case-sensitive file names\n" | ||||
|             "    -o CasePreservedNames      file system preserves the case of file names\n" | ||||
|             "    -o UnicodeOnDisk           file system supports Unicode in file names\n" | ||||
|             "    -o PersistentAcls          file system preserves and enforces ACL's\n" | ||||
|             "    -o ReparsePoints           file system supports reparse points\n" | ||||
|             "    -o NamedStreams            file system supports named streams\n" | ||||
|             "    -o ReadOnlyVolume          file system is read only\n" | ||||
|             "    --UNC=U --VolumePrefix=U   UNC prefix (\\Server\\Share)\n" | ||||
|             "\n"); | ||||
|         opt_data->help = 1; | ||||
|         return 1; | ||||
|     case 'V': | ||||
|         FspServiceLog(EVENTLOG_ERROR_TYPE, L"" | ||||
|             LIBRARY_NAME "-FUSE version %d.%d", | ||||
|             FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION); | ||||
|         opt_data->help = 1; | ||||
|         return 1; | ||||
|     case 'U': | ||||
|         if ('U' == arg[2]) | ||||
|             arg += sizeof "--UNC" - 1; | ||||
|         else if ('V' == arg[2]) | ||||
|             arg += sizeof "--VolumePrefix" - 1; | ||||
|         if (0 == MultiByteToWideChar(CP_UTF8, 0, arg, -1, | ||||
|             opt_data->VolumeParams.Prefix, sizeof opt_data->VolumeParams.Prefix / sizeof(WCHAR))) | ||||
|             return -1; | ||||
|         return 0; | ||||
|     } | ||||
| } | ||||
|  | ||||
| FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env, | ||||
|     struct fuse_chan *ch, struct fuse_args *args, | ||||
|     const struct fuse_operations *ops, size_t opsize, void *data) | ||||
| @@ -211,7 +287,6 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env, | ||||
|     struct fsp_fuse_core_opt_data opt_data; | ||||
|     struct fuse *f = 0; | ||||
|     PWSTR ServiceName = FspDiagIdent(); | ||||
|     FSP_FSCTL_VOLUME_PARAMS VolumeParams; | ||||
|     PWSTR ErrorMessage = L"."; | ||||
|     NTSTATUS Result; | ||||
|  | ||||
| @@ -223,21 +298,26 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env, | ||||
|     if (opt_data.help) | ||||
|         return 0; | ||||
|  | ||||
|     memset(&VolumeParams, 0, sizeof VolumeParams); | ||||
| #if 0 | ||||
|     /* initialize VolumeParams from command line args */ | ||||
|     VolumeParams.SectorSize = FSP_FUSE_SECTOR_SIZE; | ||||
|     VolumeParams.SectorsPerAllocationUnit = FSP_FUSE_SECTORS_PER_ALLOCATION_UNIT; | ||||
|     VolumeParams.VolumeCreationTime = MemfsGetSystemTime(); | ||||
|     VolumeParams.VolumeSerialNumber = (UINT32)(MemfsGetSystemTime() / (10000 * 1000)); | ||||
|     VolumeParams.FileInfoTimeout = FileInfoTimeout; | ||||
|     VolumeParams.CaseSensitiveSearch = 1; | ||||
|     VolumeParams.CasePreservedNames = 1; | ||||
|     VolumeParams.UnicodeOnDisk = 1; | ||||
|     VolumeParams.PersistentAcls = 1; | ||||
|     if (0 != VolumePrefix) | ||||
|         wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), VolumePrefix); | ||||
| #endif | ||||
|     opt_data.VolumeParams.VolumeCreationTime = *(PUINT64)&opt_data.VolumeCreationTime; | ||||
|     if (0 == opt_data.VolumeParams.VolumeCreationTime) | ||||
|     { | ||||
|         FILETIME FileTime; | ||||
|         GetSystemTimeAsFileTime(&FileTime); | ||||
|         opt_data.VolumeParams.VolumeCreationTime = *(PUINT64)&FileTime; | ||||
|     } | ||||
|     if (0 == opt_data.VolumeParams.VolumeSerialNumber) | ||||
|         opt_data.VolumeParams.VolumeSerialNumber = | ||||
|             ((PLARGE_INTEGER)&opt_data.VolumeParams.VolumeCreationTime)->HighPart ^ | ||||
|             ((PLARGE_INTEGER)&opt_data.VolumeParams.VolumeCreationTime)->LowPart; | ||||
|     if (!opt_data.set_FileInfoTimeout && opt_data.set_attr_timeout) | ||||
|         opt_data.VolumeParams.FileInfoTimeout = opt_data.set_attr_timeout * 1000; | ||||
|     opt_data.VolumeParams.CaseSensitiveSearch = !!opt_data.CaseSensitiveSearch; | ||||
|     opt_data.VolumeParams.CasePreservedNames = !!opt_data.CasePreservedNames; | ||||
|     opt_data.VolumeParams.UnicodeOnDisk = !!opt_data.UnicodeOnDisk; | ||||
|     opt_data.VolumeParams.PersistentAcls = !!opt_data.PersistentAcls; | ||||
|     opt_data.VolumeParams.ReparsePoints = !!opt_data.ReparsePoints; | ||||
|     opt_data.VolumeParams.NamedStreams = !!opt_data.NamedStreams; | ||||
|     opt_data.VolumeParams.ReadOnlyVolume = !!opt_data.ReadOnlyVolume; | ||||
|  | ||||
|     f = MemAlloc(sizeof *f); | ||||
|     if (0 == f) | ||||
| @@ -250,13 +330,17 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env, | ||||
|     FspServiceAllowConsoleMode(f->Service); | ||||
|     f->Service->UserContext = f; | ||||
|  | ||||
|     Result = FspFileSystemCreate(L"" FSP_FSCTL_NET_DEVICE_NAME, &VolumeParams, 0, &f->FileSystem); | ||||
|     Result = FspFileSystemCreate(L"" FSP_FSCTL_NET_DEVICE_NAME, &opt_data.VolumeParams, 0, | ||||
|         &f->FileSystem); | ||||
|     if (!NT_SUCCESS(Result)) | ||||
|     { | ||||
|         ErrorMessage = L": cannot create " LIBRARY_NAME " file system object."; | ||||
|         goto fail; | ||||
|     } | ||||
|  | ||||
|     if (opt_data.debug) | ||||
|         FspFileSystemSetDebugLog(f->FileSystem, -1); | ||||
|  | ||||
|     if (L'\0' != ch->MountPoint) | ||||
|     { | ||||
|         Result = FspFileSystemSetMountPoint(f->FileSystem, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user