protected virtual void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { // // Free managed objects here. // linuxIsoManager.OnUnmount(this); } // // Free any unmanaged objects here. // disposed = true; }
private void UnMount() { Logger.Info("Unmounting {0}...", MountedPath); _isoManager.OnUnmount(this); string cmdFilename = _sudoELF; string cmdArguments = string.Format("\"{0}\" \"{1}\"", _umountELF, MountedPath); if (Syscall.getuid() == 0) { cmdFilename = _umountELF; cmdArguments = string.Format("\"{0}\"", MountedPath); } var process = new Process { StartInfo = new ProcessStartInfo { CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, FileName = cmdFilename, Arguments = cmdArguments, WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false }, EnableRaisingEvents = true }; Logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); StreamReader outputReader = null; StreamReader errorReader = null; try { process.Start(); outputReader = process.StandardOutput; errorReader = process.StandardError; Logger.Debug("Unmount StdOut: " + outputReader.ReadLine()); Logger.Debug("Unmount StdErr: " + errorReader.ReadLine()); } catch (Exception) { throw new IOException("Unable to unmount path " + MountedPath); //TODO: Retry with -f } if (process.ExitCode != 0) { throw new IOException("Unable to unmount path " + MountedPath); } try { Directory.Delete(MountedPath); } catch (Exception) { throw new IOException("Unable to delete mount point " + MountedPath); } }