protected override void OnStart(String[] Args) { try { String DebugLogFile = null; UInt32 DebugFlags = 0; String VolumePrefix = null; String PassThrough = null; String MountPoint = null; IntPtr DebugLogHandle = (IntPtr)(-1); FileSystemHost Host = null; Ptfs Ptfs = null; int I; for (I = 1; Args.Length > I; I++) { String Arg = Args[I]; if ('-' != Arg[0]) { break; } switch (Arg[1]) { case '?': throw new CommandLineUsageException(); case 'd': argtol(Args, ref I, ref DebugFlags); break; case 'D': argtos(Args, ref I, ref DebugLogFile); break; case 'm': argtos(Args, ref I, ref MountPoint); break; case 'p': argtos(Args, ref I, ref PassThrough); break; case 'u': argtos(Args, ref I, ref VolumePrefix); break; default: throw new CommandLineUsageException(); } } if (Args.Length > I) { throw new CommandLineUsageException(); } if (null == PassThrough && null != VolumePrefix) { I = VolumePrefix.IndexOf('\\'); if (-1 != I && VolumePrefix.Length > I && '\\' != VolumePrefix[I + 1]) { I = VolumePrefix.IndexOf('\\', I + 1); if (-1 != I && VolumePrefix.Length > I + 1 && ( ('A' <= VolumePrefix[I + 1] && VolumePrefix[I + 1] <= 'Z') || ('a' <= VolumePrefix[I + 1] && VolumePrefix[I + 1] <= 'z') ) && '$' == VolumePrefix[I + 2]) { PassThrough = String.Format("{0}:{1}", VolumePrefix[I + 1], VolumePrefix.Substring(I + 3)); } } } if (null == PassThrough || null == MountPoint) { throw new CommandLineUsageException(); } if (null != DebugLogFile) { if (0 > FileSystemHost.SetDebugLogFile(DebugLogFile)) { throw new CommandLineUsageException("cannot open debug log file"); } } Host = new FileSystemHost(Ptfs = new Ptfs(PassThrough)); Host.Prefix = VolumePrefix; if (0 > Host.Mount(MountPoint, null, true, DebugFlags)) { throw new IOException("cannot mount file system"); } MountPoint = Host.MountPoint(); _Host = Host; Log(EVENTLOG_INFORMATION_TYPE, String.Format("{0}{1}{2} -p {3} -m {4}", PROGNAME, null != VolumePrefix && 0 < VolumePrefix.Length ? " -u " : "", null != VolumePrefix && 0 < VolumePrefix.Length ? VolumePrefix : "", PassThrough, MountPoint)); } catch (CommandLineUsageException ex) { Log(EVENTLOG_ERROR_TYPE, String.Format( "{0}" + "usage: {1} OPTIONS\n" + "\n" + "options:\n" + " -d DebugFlags [-1: enable all debug logs]\n" + " -D DebugLogFile [file path; use - for stderr]\n" + " -u \\Server\\Share [UNC prefix (single backslash)]\n" + " -p Directory [directory to expose as pass through file system]\n" + " -m MountPoint [X:|*|directory]\n", ex.HasMessage ? ex.Message + "\n" : "", PROGNAME)); throw; } catch (Exception ex) { Log(EVENTLOG_ERROR_TYPE, String.Format("{0}", ex.Message)); throw; } }
protected override void OnStart(String[] Args) { try { String VolumePrefix = null; String MountPoint = null; FileSystemHost Host = null; Notifyfs Notifyfs = null; int I; for (I = 1; Args.Length > I; I++) { String Arg = Args[I]; if ('-' != Arg[0]) { break; } switch (Arg[1]) { case '?': throw new CommandLineUsageException(); case 'm': argtos(Args, ref I, ref MountPoint); break; case 'u': argtos(Args, ref I, ref VolumePrefix); break; default: throw new CommandLineUsageException(); } } if (Args.Length > I) { throw new CommandLineUsageException(); } if (null == MountPoint) { throw new CommandLineUsageException(); } FileSystemHost.SetDebugLogFile("-"); Host = new FileSystemHost(Notifyfs = new Notifyfs()); Host.Prefix = VolumePrefix; if (0 > Host.Mount(MountPoint)) { throw new IOException("cannot mount file system"); } MountPoint = Host.MountPoint(); _Host = Host; Log(EVENTLOG_INFORMATION_TYPE, String.Format("{0}{1}{2} -m {3}", PROGNAME, null != VolumePrefix && 0 < VolumePrefix.Length ? " -u " : "", null != VolumePrefix && 0 < VolumePrefix.Length ? VolumePrefix : "", MountPoint)); } catch (CommandLineUsageException ex) { Log(EVENTLOG_ERROR_TYPE, String.Format( "{0}" + "usage: {1} OPTIONS\n" + "\n" + "options:\n" + " -u \\Server\\Share [UNC prefix (single backslash)]\n" + " -m MountPoint [X:|*|directory]\n", ex.HasMessage ? ex.Message + "\n" : "", PROGNAME)); throw; } catch (Exception ex) { Log(EVENTLOG_ERROR_TYPE, String.Format("{0}", ex.Message)); throw; } }
protected override void OnStart(String[] Args) { try { String debugLogFile = null; UInt32 debugFlags = 0; String volumePrefix = null; String writePath = null; String readOnlyPath = null; String mountPoint = null; IntPtr debugLogHandle = (IntPtr)(-1); FileSystemHost host = null; int i; for (i = 1; Args.Length > i; i++) { String Arg = Args[i]; if ('-' != Arg[0]) { break; } switch (Arg[1]) { case '?': throw new CommandLineUsageException(); case 'd': argtol(Args, ref i, ref debugFlags); break; case 'D': argtos(Args, ref i, ref debugLogFile); break; case 'm': argtos(Args, ref i, ref mountPoint); break; case 'r': argtos(Args, ref i, ref readOnlyPath); break; case 'w': argtos(Args, ref i, ref writePath); break; case 'u': argtos(Args, ref i, ref volumePrefix); break; default: throw new CommandLineUsageException(); } } if (Args.Length > i) { throw new CommandLineUsageException(); } if (null == readOnlyPath || null == writePath || null == mountPoint) { throw new CommandLineUsageException(); } if (null != debugLogFile) { if (0 > FileSystemHost.SetDebugLogFile(debugLogFile)) { throw new CommandLineUsageException("cannot open debug log file"); } } host = new FileSystemHost(new LayeredFileSystem(writePath, readOnlyPath)); host.Prefix = volumePrefix; if (0 > host.Mount(mountPoint, null, true, debugFlags)) { throw new IOException("cannot mount file system"); } mountPoint = host.MountPoint(); _Host = host; Log(EVENTLOG_INFORMATION_TYPE, String.Format("{0}{1}{2} -w {3} -r {5} -m {4}", PROGNAME, null != volumePrefix && 0 < volumePrefix.Length ? " -u " : "", null != volumePrefix && 0 < volumePrefix.Length ? volumePrefix : "", writePath, mountPoint, readOnlyPath)); } catch (CommandLineUsageException ex) { Log(EVENTLOG_ERROR_TYPE, String.Format( "{0}" + "usage: {1} OPTIONS\n" + "\n" + "options:\n" + " -d DebugFlags [-1: enable all debug logs]\n" + " -D DebugLogFile [file path; use - for stderr]\n" + " -u \\Server\\Share [UNC prefix (single backslash)]\n" + " -w Directory [write file system]\n" + " -r Directory [read only file system]\n" + " -m MountPoint [X:|*|directory]\n", ex.HasMessage ? ex.Message + "\n" : "", PROGNAME)); throw; } catch (Exception ex) { Log(EVENTLOG_ERROR_TYPE, String.Format("{0}", ex.Message)); throw; } }
protected override void OnStart(String[] Args) { try { Boolean CaseInsensitive = false; String DebugLogFile = null; UInt32 DebugFlags = 0; UInt32 FileInfoTimeout = unchecked ((UInt32)(-1)); UInt32 MaxFileNodes = 1024; UInt32 MaxFileSize = 16 * 1024 * 1024; String FileSystemName = null; String VolumePrefix = null; String MountPoint = null; String RootSddl = null; FileSystemHost Host = null; Memfs Memfs = null; int I; for (I = 1; Args.Length > I; I++) { String Arg = Args[I]; if ('-' != Arg[0]) { break; } switch (Arg[1]) { case '?': throw new CommandLineUsageException(); case 'D': argtos(Args, ref I, ref DebugLogFile); break; case 'd': argtol(Args, ref I, ref DebugFlags); break; case 'F': argtos(Args, ref I, ref FileSystemName); break; case 'i': CaseInsensitive = true; break; case 'm': argtos(Args, ref I, ref MountPoint); break; case 'n': argtol(Args, ref I, ref MaxFileNodes); break; case 'S': argtos(Args, ref I, ref RootSddl); break; case 's': argtol(Args, ref I, ref MaxFileSize); break; case 't': argtol(Args, ref I, ref FileInfoTimeout); break; case 'u': argtos(Args, ref I, ref VolumePrefix); break; default: throw new CommandLineUsageException(); } } if (Args.Length > I) { throw new CommandLineUsageException(); } if ((null == VolumePrefix || 0 == VolumePrefix.Length) && null == MountPoint) { throw new CommandLineUsageException(); } if (null != DebugLogFile) { if (0 > FileSystemHost.SetDebugLogFile(DebugLogFile)) { throw new CommandLineUsageException("cannot open debug log file"); } } Host = new FileSystemHost(Memfs = new Memfs( CaseInsensitive, MaxFileNodes, MaxFileSize, RootSddl)); Host.FileInfoTimeout = FileInfoTimeout; Host.Prefix = VolumePrefix; Host.FileSystemName = null != FileSystemName ? FileSystemName : "-MEMFS"; if (0 > Host.Mount(MountPoint, null, false, DebugFlags)) { throw new IOException("cannot mount file system"); } MountPoint = Host.MountPoint(); _Host = Host; Log(EVENTLOG_INFORMATION_TYPE, String.Format("{0} -t {1} -n {2} -s {3}{4}{5}{6}{7}{8}{9}", PROGNAME, (Int32)FileInfoTimeout, MaxFileNodes, MaxFileSize, null != RootSddl ? " -S " : "", null != RootSddl ? RootSddl : "", null != VolumePrefix && 0 < VolumePrefix.Length ? " -u " : "", null != VolumePrefix && 0 < VolumePrefix.Length ? VolumePrefix : "", null != MountPoint ? " -m " : "", null != MountPoint ? MountPoint : "")); } catch (CommandLineUsageException ex) { Log(EVENTLOG_ERROR_TYPE, String.Format( "{0}" + "usage: {1} OPTIONS\n" + "\n" + "options:\n" + " -d DebugFlags [-1: enable all debug logs]\n" + " -D DebugLogFile [file path; use - for stderr]\n" + " -i [case insensitive file system]\n" + " -t FileInfoTimeout [millis]\n" + " -n MaxFileNodes\n" + " -s MaxFileSize [bytes]\n" + " -F FileSystemName\n" + " -S RootSddl [file rights: FA, etc; NO generic rights: GA, etc.]\n" + " -u \\Server\\Share [UNC prefix (single backslash)]\n" + " -m MountPoint [X:|* (required if no UNC prefix)]\n", ex.HasMessage ? ex.Message + "\n" : "", PROGNAME)); throw; } catch (Exception ex) { Log(EVENTLOG_ERROR_TYPE, String.Format("{0}", ex.Message)); throw; } }
protected override void OnStart(string [] args) { try { string debugLogFile = null; uint debugFlags = 0; string volumePrefix = null; string mountPoint = null; IntPtr debugLogHandle = ( IntPtr )(-1); FileSystemHost host = null; FileSystem.CloudFileSystem cloudFileSystem = null; int I; for (I = 1; args.Length > I; I++) { string arg = args [I]; if ('-' != arg [0]) { break; } switch (arg [1]) { case '?': throw new CommandLineUsageException( ); case 'd': SelectArgument(args, ref I, ref debugFlags); break; case 'D': SelectArgument(args, ref I, ref debugLogFile); break; case 'm': SelectArgument(args, ref I, ref mountPoint); break; case 'u': SelectArgument(args, ref I, ref volumePrefix); break; default: throw new CommandLineUsageException( ); } } if (args.Length > I) { throw new CommandLineUsageException( ); } if (null != volumePrefix) { I = volumePrefix.IndexOf('\\'); if (-1 != I && volumePrefix.Length > I && '\\' != volumePrefix [I + 1]) { I = volumePrefix.IndexOf('\\', I + 1); if (-1 != I && volumePrefix.Length > I + 1 && char.IsLetter(volumePrefix [I + 1]) && '$' == volumePrefix [I + 2]) { } } } if (null == mountPoint) { throw new CommandLineUsageException( ); } if (null != debugLogFile) { if (0 > FileSystemHost.SetDebugLogFile(debugLogFile)) { throw new CommandLineUsageException("cannot open debug log file"); } } host = new FileSystemHost(new FileSystem.CloudFileSystem( )) { Prefix = volumePrefix }; if (0 > host.Mount(mountPoint, null, true, debugFlags)) { throw new IOException("cannot mount file system"); } mountPoint = host.MountPoint( ); Host = host; Log( EVENTLOG_INFORMATION_TYPE, $"{ProgramName}{( ! string . IsNullOrEmpty ( volumePrefix ) ? " -u ": string . Empty )}{( ! string . IsNullOrEmpty ( volumePrefix ) ? volumePrefix: string . Empty )} -m {mountPoint}"); } catch (CommandLineUsageException ex) { Log( EVENTLOG_ERROR_TYPE, $"{( ex . HasMessage ? ex . Message + "\n": "" )}" + $"usage: {ProgramName} OPTIONS\n" + "\n" + "options:\n" + " -d DebugFlags [-1: enable all debug logs]\n" + " -D DebugLogFile [file path; use - for stderr]\n" + " -u \\Server\\Share [UNC prefix (single backslash)]\n" + " -m MountPoint [X:|*|directory]\n"); } catch (Exception ex) { Log(EVENTLOG_ERROR_TYPE, $"{ex . Message}"); throw; } }