[HFS+] Implement StatFs.

This commit is contained in:
2026-02-02 14:00:29 +00:00
parent ea96d65411
commit 464bf4fef0
4 changed files with 71 additions and 6 deletions

View File

@@ -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;

View File

@@ -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
}
};
}
}

View 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;
}
}

View File

@@ -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();