diff --git a/Aaru.Filesystems/BFS/Super.cs b/Aaru.Filesystems/BFS/Super.cs new file mode 100644 index 000000000..e3e3afbf4 --- /dev/null +++ b/Aaru.Filesystems/BFS/Super.cs @@ -0,0 +1,77 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Super.cs +// Author(s) : Natalia Portillo +// +// Component : BeOS filesystem 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2026 Natalia Portillo +// ****************************************************************************/ + +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Structs; +using Aaru.Logging; + +namespace Aaru.Filesystems; + +// Information from Practical Filesystem Design, ISBN 1-55860-497-9 +/// +public sealed partial class BeFS +{ + /// Returns filesystem statistics + /// + /// Provides information about the BeFS volume including total blocks, free blocks, + /// block size, and other filesystem metadata from the cached superblock. + /// + /// Output filesystem information + /// Error code indicating success or failure + /// + public ErrorNumber StatFs(out FileSystemInfo stat) + { + stat = null; + + if(!_mounted) return ErrorNumber.AccessDenied; + + AaruLogging.Debug(MODULE_NAME, "StatFs: returning filesystem statistics"); + + // Calculate free blocks + long freeBlocks = _superblock.num_blocks - _superblock.used_blocks; + + // Create filesystem info from superblock data + stat = new FileSystemInfo + { + Blocks = (ulong)_superblock.num_blocks, + FreeBlocks = (ulong)freeBlocks, + FilenameLength = 255, + Type = FS_TYPE, + Files = 0, // Not tracked in BeFS superblock + FreeFiles = 0 // Not tracked in BeFS superblock + }; + + AaruLogging.Debug(MODULE_NAME, + "StatFs complete: totalBlocks={0}, freeBlocks={1}, blockSize={2}", + stat.Blocks, + stat.FreeBlocks, + _superblock.block_size); + + return ErrorNumber.NoError; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/BFS/Unimplemented.cs b/Aaru.Filesystems/BFS/Unimplemented.cs index 66e0a3370..bdbb0d75e 100644 --- a/Aaru.Filesystems/BFS/Unimplemented.cs +++ b/Aaru.Filesystems/BFS/Unimplemented.cs @@ -30,7 +30,6 @@ using System; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; namespace Aaru.Filesystems; @@ -44,10 +43,6 @@ public sealed partial class BeFS public ErrorNumber Unmount() => throw new NotImplementedException(); - /// - public ErrorNumber StatFs(out FileSystemInfo stat) => throw new NotImplementedException(); - - /// public ErrorNumber ReadLink(string path, out string dest) => throw new NotImplementedException();