mirror of
https://github.com/aaru-dps/Aaru.git
synced 2026-02-04 09:04:35 +00:00
[HFS+] Implement StatFs.
This commit is contained in:
@@ -30,6 +30,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.AaruMetadata;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
@@ -43,13 +44,15 @@ public sealed partial class AppleHFSPlus : IReadOnlyFilesystem
|
||||
|
||||
/// <summary>Catalog B-Tree header information</summary>
|
||||
BTHeaderRec _catalogBTreeHeader;
|
||||
|
||||
/// <summary>Media image plugin reference</summary>
|
||||
/// <summary>Cached directory entries by CNID, each entry keyed by filename</summary>
|
||||
Dictionary<uint, Dictionary<string, CatalogEntry>> _directoryCaches;
|
||||
|
||||
/// <summary>Extents Overflow File B-Tree header information</summary>
|
||||
BTHeaderRec _extentsFileHeader;
|
||||
|
||||
/// <summary>Filesystem information</summary>
|
||||
FileSystemInfo _fileSystemInfo;
|
||||
|
||||
/// <summary>Media image plugin reference</summary>
|
||||
IMediaImage _imagePlugin;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ using System.Text;
|
||||
using Aaru.CommonTypes.AaruMetadata;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Helpers;
|
||||
using Aaru.Logging;
|
||||
using Partition = Aaru.CommonTypes.Partition;
|
||||
@@ -528,5 +529,21 @@ public sealed partial class AppleHFSPlus
|
||||
// Create volume serial from Finder info fields
|
||||
if(_volumeHeader.drFndrInfo6 != 0 && _volumeHeader.drFndrInfo7 != 0)
|
||||
Metadata.VolumeSerial = $"{_volumeHeader.drFndrInfo6:X8}{_volumeHeader.drFndrInfo7:X8}";
|
||||
|
||||
// Create FileSystemInfo for StatFs
|
||||
_fileSystemInfo = new FileSystemInfo
|
||||
{
|
||||
Type = Metadata.Type,
|
||||
Blocks = _volumeHeader.totalBlocks,
|
||||
Files = _volumeHeader.fileCount,
|
||||
FreeBlocks = _volumeHeader.freeBlocks,
|
||||
FilenameLength = 255, // HFS+ supports up to 255 character UTF-16 names
|
||||
PluginId = Id,
|
||||
Id = new FileSystemId
|
||||
{
|
||||
IsLong = true,
|
||||
Serial64 = (ulong)_volumeHeader.drFndrInfo6 << 32 | _volumeHeader.drFndrInfo7
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
49
Aaru.Filesystems/AppleHFSPlus/Super.cs
Normal file
49
Aaru.Filesystems/AppleHFSPlus/Super.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Super.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Apple Hierarchical File System Plus plugin.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2026 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
// Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html
|
||||
/// <summary>Implements detection of Apple Hierarchical File System Plus (HFS+)</summary>
|
||||
public sealed partial class AppleHFSPlus
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber StatFs(out FileSystemInfo stat)
|
||||
{
|
||||
stat = null;
|
||||
|
||||
if(!_mounted) return ErrorNumber.AccessDenied;
|
||||
|
||||
stat = _fileSystemInfo;
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@
|
||||
using System;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
@@ -42,9 +41,6 @@ public sealed partial class AppleHFSPlus
|
||||
public ErrorNumber Unmount() => throw new NotImplementedException();
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber StatFs(out FileSystemInfo stat) => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadLink(string path, out string dest) => throw new NotImplementedException();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user