From 331372ecfe0e0d45f408856b30c642b60edea8fe Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 7 Feb 2026 01:55:24 +0000 Subject: [PATCH] [pfs] Implement statfs. --- Aaru.Filesystems/PFS/Super.cs | 56 +++++++++++++++++++++++++++ Aaru.Filesystems/PFS/Unimplemented.cs | 5 --- 2 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 Aaru.Filesystems/PFS/Super.cs diff --git a/Aaru.Filesystems/PFS/Super.cs b/Aaru.Filesystems/PFS/Super.cs new file mode 100644 index 000000000..83b697dc5 --- /dev/null +++ b/Aaru.Filesystems/PFS/Super.cs @@ -0,0 +1,56 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Super.cs +// Author(s) : Natalia Portillo +// +// Component : Professional File System 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; + +namespace Aaru.Filesystems; + +/// +public sealed partial class PFS +{ + /// + public ErrorNumber StatFs(out FileSystemInfo stat) + { + stat = null; + + if(!_mounted) return ErrorNumber.AccessDenied; + + stat = new FileSystemInfo + { + Blocks = _rootBlock.diskSize, + FilenameLength = (ushort)(_hasExtension ? _filenameSize : DNSIZE - 2), // Default 30 chars + FreeBlocks = _rootBlock.blocksfree, + FreeFiles = 0, // PFS doesn't have a fixed inode count + PluginId = Id, + Type = FS_TYPE + }; + + return ErrorNumber.NoError; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/PFS/Unimplemented.cs b/Aaru.Filesystems/PFS/Unimplemented.cs index f7f1ad1d5..fb2675476 100644 --- a/Aaru.Filesystems/PFS/Unimplemented.cs +++ b/Aaru.Filesystems/PFS/Unimplemented.cs @@ -29,7 +29,6 @@ using System; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; namespace Aaru.Filesystems; @@ -40,10 +39,6 @@ public sealed partial class PFS 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();