aboutsummaryrefslogtreecommitdiff
path: root/Emby.IsoMounting/IsoMounter
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.IsoMounting/IsoMounter')
-rw-r--r--Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs11
-rw-r--r--Emby.IsoMounting/IsoMounter/IsoMounter.csproj30
-rw-r--r--Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs298
-rw-r--r--Emby.IsoMounting/IsoMounter/LinuxMount.cs58
-rw-r--r--Emby.IsoMounting/IsoMounter/Plugin.cs33
-rw-r--r--Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs21
6 files changed, 0 insertions, 451 deletions
diff --git a/Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs b/Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs
deleted file mode 100644
index ca6f40cc4..000000000
--- a/Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using MediaBrowser.Model.Plugins;
-
-namespace IsoMounter.Configuration
-{
- /// <summary>
- /// Class PluginConfiguration.
- /// </summary>
- public class PluginConfiguration : BasePluginConfiguration
- {
- }
-}
diff --git a/Emby.IsoMounting/IsoMounter/IsoMounter.csproj b/Emby.IsoMounting/IsoMounter/IsoMounter.csproj
deleted file mode 100644
index 4fa07fbf1..000000000
--- a/Emby.IsoMounting/IsoMounter/IsoMounter.csproj
+++ /dev/null
@@ -1,30 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <ItemGroup>
- <Compile Include="..\..\SharedVersion.cs" />
- </ItemGroup>
-
- <ItemGroup>
- <ProjectReference Include="..\..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
- <ProjectReference Include="..\..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
- </ItemGroup>
-
- <PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
- <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
- <GenerateDocumentationFile>true</GenerateDocumentationFile>
- <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
- </PropertyGroup>
-
- <!-- Code analysers-->
- <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
- <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
- <PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
- </ItemGroup>
-
- <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
- <CodeAnalysisRuleSet>../../jellyfin.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
-
-</Project>
diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs
deleted file mode 100644
index 48cb2e1d5..000000000
--- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.System;
-using Microsoft.Extensions.Logging;
-using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
-
-namespace IsoMounter
-{
- /// <summary>
- /// The ISO manager implementation for Linux.
- /// </summary>
- public class LinuxIsoManager : IIsoMounter
- {
- private const string MountCommand = "mount";
- private const string UnmountCommand = "umount";
- private const string SudoCommand = "sudo";
-
- private readonly ILogger _logger;
- private readonly string _mountPointRoot;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LinuxIsoManager" /> class.
- /// </summary>
- /// <param name="logger">The logger.</param>
- public LinuxIsoManager(ILogger logger)
- {
- _logger = logger;
-
- _mountPointRoot = Path.DirectorySeparatorChar + "tmp" + Path.DirectorySeparatorChar + "Emby";
-
- _logger.LogDebug(
- "[{0}] System PATH is currently set to [{1}].",
- Name,
- Environment.GetEnvironmentVariable("PATH") ?? string.Empty);
-
- _logger.LogDebug(
- "[{0}] System path separator is [{1}].",
- Name,
- Path.PathSeparator);
-
- _logger.LogDebug(
- "[{0}] Mount point root is [{1}].",
- Name,
- _mountPointRoot);
- }
-
- /// <inheritdoc />
- public string Name => "LinuxMount";
-
-#pragma warning disable SA1300
-#pragma warning disable SA1400
- [DllImport("libc", SetLastError = true)]
- static extern uint getuid();
-
-#pragma warning restore SA1300
-#pragma warning restore SA1400
-
- /// <inheritdoc />
- public bool CanMount(string path)
- {
- if (OperatingSystem.Id != OperatingSystemId.Linux)
- {
- return false;
- }
-
- _logger.LogInformation(
- "[{0}] Checking we can attempt to mount [{1}], Extension = [{2}], Operating System = [{3}].",
- Name,
- path,
- Path.GetExtension(path),
- OperatingSystem.Name);
-
- return string.Equals(Path.GetExtension(path), ".iso", StringComparison.OrdinalIgnoreCase);
- }
-
- /// <inheritdoc />
- public Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken)
- {
- string cmdArguments;
- string cmdFilename;
- string mountPoint = Path.Combine(_mountPointRoot, Guid.NewGuid().ToString());
-
- if (string.IsNullOrEmpty(isoPath))
- {
- throw new ArgumentNullException(nameof(isoPath));
- }
-
- _logger.LogInformation(
- "[{Name}] Attempting to mount [{Path}].",
- Name,
- isoPath);
-
- _logger.LogDebug(
- "[{Name}] ISO will be mounted at [{Path}].",
- Name,
- mountPoint);
-
- try
- {
- Directory.CreateDirectory(mountPoint);
- }
- catch (UnauthorizedAccessException ex)
- {
- throw new IOException("Unable to create mount point(Permission denied) for " + isoPath, ex);
- }
- catch (Exception ex)
- {
- throw new IOException("Unable to create mount point for " + isoPath, ex);
- }
-
- if (GetUID() == 0)
- {
- cmdFilename = MountCommand;
- cmdArguments = string.Format(
- CultureInfo.InvariantCulture,
- "\"{0}\" \"{1}\"",
- isoPath,
- mountPoint);
- }
- else
- {
- cmdFilename = SudoCommand;
- cmdArguments = string.Format(
- CultureInfo.InvariantCulture,
- "\"{0}\" \"{1}\" \"{2}\"",
- MountCommand,
- isoPath,
- mountPoint);
- }
-
- _logger.LogDebug(
- "[{0}] Mount command [{1}], mount arguments [{2}].",
- Name,
- cmdFilename,
- cmdArguments);
-
- int exitcode = ExecuteCommand(cmdFilename, cmdArguments);
- if (exitcode == 0)
- {
- _logger.LogInformation(
- "[{0}] ISO mount completed successfully.",
- Name);
-
- return Task.FromResult<IIsoMount>(new LinuxMount(this, isoPath, mountPoint));
- }
-
- _logger.LogInformation(
- "[{0}] ISO mount completed with errors.",
- Name);
-
- try
- {
- Directory.Delete(mountPoint, false);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "[{Name}] Unhandled exception removing mount point.", Name);
- throw;
- }
-
- throw new ExternalException("Mount command failed", exitcode);
- }
-
- private uint GetUID()
- {
- var uid = getuid();
-
- _logger.LogDebug(
- "[{0}] GetUserId() returned [{2}].",
- Name,
- uid);
-
- return uid;
- }
-
- private int ExecuteCommand(string cmdFilename, string cmdArguments)
- {
- var startInfo = new ProcessStartInfo
- {
- FileName = cmdFilename,
- Arguments = cmdArguments,
- UseShellExecute = false,
- CreateNoWindow = true,
- ErrorDialog = false,
- RedirectStandardOutput = true,
- RedirectStandardError = true
- };
-
- var process = new Process()
- {
- StartInfo = startInfo
- };
-
- try
- {
- process.Start();
-
- _logger.LogDebug(
- "[{Name}] Standard output from process is [{Error}].",
- Name,
- process.StandardOutput.ReadToEnd());
-
- _logger.LogDebug(
- "[{Name}] Standard error from process is [{Error}].",
- Name,
- process.StandardError.ReadToEnd());
-
- return process.ExitCode;
- }
- catch (Exception ex)
- {
- _logger.LogDebug(ex, "[{Name}] Unhandled exception executing command.", Name);
- throw;
- }
- finally
- {
- process?.Dispose();
- }
- }
-
- /// <summary>
- /// Unmounts the specified mount.
- /// </summary>
- /// <param name="mount">The mount.</param>
- internal void OnUnmount(LinuxMount mount)
- {
- if (mount == null)
- {
- throw new ArgumentNullException(nameof(mount));
- }
-
- _logger.LogInformation(
- "[{0}] Attempting to unmount ISO [{1}] mounted on [{2}].",
- Name,
- mount.IsoPath,
- mount.MountedPath);
-
- string cmdArguments;
- string cmdFilename;
-
- if (GetUID() == 0)
- {
- cmdFilename = UnmountCommand;
- cmdArguments = string.Format(
- CultureInfo.InvariantCulture,
- "\"{0}\"",
- mount.MountedPath);
- }
- else
- {
- cmdFilename = SudoCommand;
- cmdArguments = string.Format(
- CultureInfo.InvariantCulture,
- "\"{0}\" \"{1}\"",
- UnmountCommand,
- mount.MountedPath);
- }
-
- _logger.LogDebug(
- "[{0}] Umount command [{1}], umount arguments [{2}].",
- Name,
- cmdFilename,
- cmdArguments);
-
- int exitcode = ExecuteCommand(cmdFilename, cmdArguments);
- if (exitcode == 0)
- {
- _logger.LogInformation(
- "[{0}] ISO unmount completed successfully.",
- Name);
- }
- else
- {
- _logger.LogInformation(
- "[{0}] ISO unmount completed with errors.",
- Name);
- }
-
- try
- {
- Directory.Delete(mount.MountedPath, false);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "[{Name}] Unhandled exception removing mount point.", Name);
- throw;
- }
-
- throw new ExternalException("Mount command failed", exitcode);
- }
- }
-}
diff --git a/Emby.IsoMounting/IsoMounter/LinuxMount.cs b/Emby.IsoMounting/IsoMounter/LinuxMount.cs
deleted file mode 100644
index ccad8ce20..000000000
--- a/Emby.IsoMounting/IsoMounter/LinuxMount.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using MediaBrowser.Model.IO;
-
-namespace IsoMounter
-{
- /// <summary>
- /// Class LinuxMount.
- /// </summary>
- internal class LinuxMount : IIsoMount
- {
- private readonly LinuxIsoManager _linuxIsoManager;
-
- private bool _disposed = false;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LinuxMount" /> class.
- /// </summary>
- /// <param name="isoManager">The ISO manager that mounted this ISO file.</param>
- /// <param name="isoPath">The path to the ISO file.</param>
- /// <param name="mountFolder">The folder the ISO is mounted in.</param>
- internal LinuxMount(LinuxIsoManager isoManager, string isoPath, string mountFolder)
- {
- _linuxIsoManager = isoManager;
-
- IsoPath = isoPath;
- MountedPath = mountFolder;
- }
-
- /// <inheritdoc />
- public string IsoPath { get; }
-
- /// <inheritdoc />
- public string MountedPath { get; }
-
- /// <inheritdoc />
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- /// <summary>
- /// Releases the unmanaged resources and disposes of the managed resources used.
- /// </summary>
- /// <param name="disposing">Whether or not the managed resources should be disposed.</param>
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- {
- return;
- }
-
- _linuxIsoManager.OnUnmount(this);
-
- _disposed = true;
- }
- }
-}
diff --git a/Emby.IsoMounting/IsoMounter/Plugin.cs b/Emby.IsoMounting/IsoMounter/Plugin.cs
deleted file mode 100644
index 433294d74..000000000
--- a/Emby.IsoMounting/IsoMounter/Plugin.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using IsoMounter.Configuration;
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.Plugins;
-using MediaBrowser.Model.Serialization;
-
-namespace IsoMounter
-{
- /// <summary>
- /// The LinuxMount plugin class.
- /// </summary>
- public class Plugin : BasePlugin<PluginConfiguration>
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="Plugin" /> class.
- /// </summary>
- /// <param name="applicationPaths">The application paths.</param>
- /// <param name="xmlSerializer">The XML serializer.</param>
- public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
- : base(applicationPaths, xmlSerializer)
- {
- }
-
- /// <inheritdoc />
- public override Guid Id { get; } = new Guid("4682DD4C-A675-4F1B-8E7C-79ADF137A8F8");
-
- /// <inheritdoc />
- public override string Name => "Iso Mounter";
-
- /// <inheritdoc />
- public override string Description => "Mount and stream ISO contents";
- }
-}
diff --git a/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs b/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs
deleted file mode 100644
index 5956fc3b3..000000000
--- a/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System.Reflection;
-using System.Resources;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("IsoMounter")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Jellyfin Project")]
-[assembly: AssemblyProduct("Jellyfin Server")]
-[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: NeutralResourcesLanguage("en")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]