2018-06-25 19:08:16 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:21 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2018-06-25 19:08:16 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : IReadOnlyFilesystem.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Filesystem plugins.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Interface for filesystem plugins that offer read-only support of their
|
|
|
|
|
|
// contents.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
2018-06-25 19:22:42 +01:00
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
|
|
// the following conditions:
|
|
|
|
|
|
//
|
|
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
|
|
//
|
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
|
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
|
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
|
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2018-06-25 19:08:16 +01:00
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:16 +00:00
|
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2018-06-25 19:08:16 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
2021-09-16 04:42:08 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:15 +00:00
|
|
|
|
using Aaru.CommonTypes.Structs;
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-11-15 15:58:40 +00:00
|
|
|
|
namespace Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Defines the interface to implement reading the contents of a filesystem</summary>
|
|
|
|
|
|
public interface IReadOnlyFilesystem : IFilesystem
|
2018-06-25 19:08:16 +01:00
|
|
|
|
{
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Retrieves a list of options supported by the filesystem, with name, type and description</summary>
|
|
|
|
|
|
IEnumerable<(string name, Type type, string description)> SupportedOptions { get; }
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Supported namespaces</summary>
|
|
|
|
|
|
Dictionary<string, string> Namespaces { get; }
|
2019-04-17 00:11:28 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes whatever internal structures the filesystem plugin needs to be able to read files and directories
|
|
|
|
|
|
/// from the filesystem.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="imagePlugin"></param>
|
|
|
|
|
|
/// <param name="partition"></param>
|
|
|
|
|
|
/// <param name="encoding">Which encoding to use for this filesystem.</param>
|
|
|
|
|
|
/// <param name="options">Dictionary of key=value pairs containing options to pass to the filesystem</param>
|
|
|
|
|
|
/// <param name="namespace">Filename namespace</param>
|
|
|
|
|
|
ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
|
|
|
|
|
Dictionary<string, string> options, string @namespace);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Frees all internal structures created by <see cref="Mount" /></summary>
|
|
|
|
|
|
ErrorNumber Unmount();
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Maps a filesystem block from a file to a block from the underlying device.</summary>
|
|
|
|
|
|
/// <returns>Error number.</returns>
|
|
|
|
|
|
/// <param name="path">File path.</param>
|
|
|
|
|
|
/// <param name="fileBlock">File block.</param>
|
|
|
|
|
|
/// <param name="deviceBlock">Device block.</param>
|
|
|
|
|
|
ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Gets the attributes of a file or directory</summary>
|
|
|
|
|
|
/// <returns>Error number.</returns>
|
|
|
|
|
|
/// <param name="path">File path.</param>
|
|
|
|
|
|
/// <param name="attributes">File attributes.</param>
|
|
|
|
|
|
ErrorNumber GetAttributes(string path, out FileAttributes attributes);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Lists all extended attributes, alternate data streams and forks of the given file.</summary>
|
|
|
|
|
|
/// <returns>Error number.</returns>
|
|
|
|
|
|
/// <param name="path">Path.</param>
|
|
|
|
|
|
/// <param name="xattrs">List of extended attributes, alternate data streams and forks.</param>
|
|
|
|
|
|
ErrorNumber ListXAttr(string path, out List<string> xattrs);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Reads an extended attribute, alternate data stream or fork from the given file.</summary>
|
|
|
|
|
|
/// <returns>Error number.</returns>
|
|
|
|
|
|
/// <param name="path">File path.</param>
|
|
|
|
|
|
/// <param name="xattr">Extended attribute, alternate data stream or fork name.</param>
|
|
|
|
|
|
/// <param name="buf">Buffer.</param>
|
|
|
|
|
|
ErrorNumber GetXattr(string path, string xattr, ref byte[] buf);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Reads data from a file (main/only data stream or data fork).</summary>
|
|
|
|
|
|
/// <param name="path">File path.</param>
|
|
|
|
|
|
/// <param name="offset">Offset.</param>
|
|
|
|
|
|
/// <param name="size">Bytes to read.</param>
|
|
|
|
|
|
/// <param name="buf">Buffer.</param>
|
|
|
|
|
|
ErrorNumber Read(string path, long offset, long size, ref byte[] buf);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Lists contents from a directory.</summary>
|
|
|
|
|
|
/// <param name="path">Directory path.</param>
|
|
|
|
|
|
/// <param name="contents">Directory contents.</param>
|
|
|
|
|
|
ErrorNumber ReadDir(string path, out List<string> contents);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Gets information about the mounted volume.</summary>
|
|
|
|
|
|
/// <param name="stat">Information about the mounted volume.</param>
|
|
|
|
|
|
ErrorNumber StatFs(out FileSystemInfo stat);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Gets information about a file or directory.</summary>
|
|
|
|
|
|
/// <param name="path">File path.</param>
|
|
|
|
|
|
/// <param name="stat">File information.</param>
|
|
|
|
|
|
ErrorNumber Stat(string path, out FileEntryInfo stat);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
|
2022-03-06 13:29:30 +00:00
|
|
|
|
/// <summary>Solves a symbolic link.</summary>
|
|
|
|
|
|
/// <param name="path">Link path.</param>
|
|
|
|
|
|
/// <param name="dest">Link destination.</param>
|
|
|
|
|
|
ErrorNumber ReadLink(string path, out string dest);
|
2018-06-25 19:08:16 +01:00
|
|
|
|
}
|