From f47947f09af1f26ebc97868985ddedaa6bb366a1 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 22 Jul 2016 00:44:52 +0100 Subject: [PATCH] Modified FileAttributes enum so it correctly works as a flag. Removed DevicePath from FileEntryInfo structure. Added filesystem ID as a union struct of uint32, uint64 and guid. Added NoData and NoSuchExtendedAttribute errors. --- DiscImageChef.Filesystems/Structs.cs | 136 +++++++++++++++++---------- 1 file changed, 84 insertions(+), 52 deletions(-) diff --git a/DiscImageChef.Filesystems/Structs.cs b/DiscImageChef.Filesystems/Structs.cs index ca895a5a..cdb3e10a 100644 --- a/DiscImageChef.Filesystems/Structs.cs +++ b/DiscImageChef.Filesystems/Structs.cs @@ -36,110 +36,113 @@ // ****************************************************************************/ // //$Id$ using System; +using System.Runtime.InteropServices; +using System.Security.Policy; + namespace DiscImageChef.Filesystems { /// /// File attributes. /// [Flags] - public enum FileAttributes + public enum FileAttributes : ulong { /// File is an alias (Mac OS) - Alias, + Alias = 0x01, /// Indicates that the file can only be writable appended - AppendOnly, + AppendOnly = 0x02, /// File is candidate for archival/backup - Archive, + Archive = 0x04, /// File is a block device - BlockDevice, + BlockDevice = 0x08, /// File is stored on filesystem block units instead of device sectors - BlockUnits, + BlockUnits = 0x10, /// Directory is a bundle or file contains a BNDL resource - Bundle, + Bundle = 0x20, /// File is a char device - CharDevice, + CharDevice = 0x40, /// File is compressed - Compressed, + Compressed = 0x80, /// File is compressed and should not be uncompressed on read - CompressedRaw, + CompressedRaw = 0x100, /// File has compression errors - CompressionError, + CompressionError = 0x200, /// Compressed file is dirty - CompressionDirty, + CompressionDirty = 0x400, /// File is a device - Device, + Device = 0x800, /// File is a directory - Directory, + Directory = 0x1000, /// File is encrypted - Encrypted, + Encrypted = 0x2000, /// File is stored on disk using extents - Extents, + Extents = 0x4000, /// File is a FIFO - FIFO, + FIFO = 0x8000, /// File is a normal file - File, + File = 0x10000, /// File is a Mac OS file containing desktop databases that has already been added to the desktop database - HasBeenInited, + HasBeenInited = 0x20000, /// File contains an icon resource / EA - HasCustomIcon, + HasCustomIcon = 0x40000, /// File is a Mac OS extension or control panel lacking INIT resources - HasNoINITs, + HasNoINITs = 0x80000, /// File is hidden/invisible - Hidden, + Hidden = 0x100000, /// File cannot be written, deleted, modified or linked to - Immutable, + Immutable = 0x200000, /// Directory is indexed using hashed trees - IndexedDirectory, + IndexedDirectory = 0x400000, /// File contents are stored alongside its inode (or equivalent) - Inline, + Inline = 0x800000, /// File contains integrity checks - IntegrityStream, + IntegrityStream = 0x1000000, /// File is on desktop - IsOnDesk, + IsOnDesk = 0x2000000, /// File changes are written to filesystem journal before being written to file itself - Journaled, + Journaled = 0x4000000, /// Access time will not be modified - NoAccessTime, + NoAccessTime = 0x8000000, /// File will not be subject to copy-on-write - NoCopyOnWrite, + NoCopyOnWrite = 0x10000000, /// File will not be backed up - NoDump, + NoDump = 0x20000000, /// File contents should not be scrubed - NoScrub, + NoScrub = 0x40000000, /// File contents should not be indexed - NotIndexed, + NotIndexed = 0x80000000, /// File is offline - Offline, + Offline = 0x100000000, /// File is password protected, but contents are not encrypted on disk - Password, + Password = 0x200000000, /// File is read-only - ReadOnly, + ReadOnly = 0x400000000, /// File is a reparse point - ReparsePoint, + ReparsePoint = 0x800000000, /// When file is removed its content will be overwritten with zeroes - Secured, + Secured = 0x1000000000, /// File contents are sparse - Sparse, + Sparse = 0x2000000000, /// File is a shadow (OS/2) - Shadow, + Shadow = 0x4000000000, /// File is shared - Shared, + Shared = 0x8000000000, /// File is a stationery - Stationery, + Stationery = 0x10000000000, /// File is a symbolic link - Symlink, + Symlink = 0x20000000000, /// File writes are synchronously written to disk - Sync, + Sync = 0x40000000000, /// File belongs to the operating system - System, + System = 0x80000000000, /// If file end is a partial block its contend will be merged with other files - TailMerged, + TailMerged = 0x100000000000, /// File is temporary - Temporary, + Temporary = 0x200000000000, /// Subdirectories inside of this directory are not related and should be allocated elsewhere - TopDirectory, + TopDirectory = 0x400000000000, /// If file is deleted, contents should be stored, for a possible future undeletion - Undeletable + Undeletable = 0x800000000000 } /// @@ -178,8 +181,6 @@ namespace DiscImageChef.Filesystems /// File last modification date public DateTime LastWriteTime { get { return mtimeUtc.ToLocalTime(); } set { mtimeUtc = value.ToUniversalTime(); } } - /// Path of device that contains this file - public string DevicePath; /// inode number for this file public ulong Inode; /// POSIX permissions/mode for this file @@ -202,6 +203,11 @@ namespace DiscImageChef.Filesystems public class FileSystemInfo { + public FileSystemInfo() + { + Id = new FileSystemId(); + } + /// Filesystem type public string Type; /// ID of plugin for this file @@ -217,7 +223,25 @@ namespace DiscImageChef.Filesystems /// Maximum length of filenames on this filesystem public ushort FilenameLength; /// Filesystem ID - public Guid Id; + public FileSystemId Id; + } + + [StructLayout(LayoutKind.Explicit)] + public struct FileSystemId + { + [FieldOffset(0)] + public bool IsInt; + [FieldOffset(1)] + public bool IsLong; + [FieldOffset(2)] + public bool IsGuid; + + [FieldOffset(3)] + public UInt32 Serial32; + [FieldOffset(3)] + public UInt64 Serial64; + [FieldOffset(3)] + public Guid uuid; } /// @@ -241,6 +265,10 @@ namespace DiscImageChef.Filesystems IsDirectory = -21, /// Name is too long NameTooLong = -36, + /// There is no data available + NoData = 61, + /// There is no such attribute + NoSuchExtendedAttribute = NoData, /// No such device NoSuchDevice = -19, /// No such file or directory @@ -267,6 +295,10 @@ namespace DiscImageChef.Filesystems EISDIR = IsDirectory, /// Name is too long ENAMETOOLONG = NameTooLong, + /// There is no such attribute + ENOATTR = NoSuchExtendedAttribute, + /// There is no data available + ENODATA = NoData, /// No such device ENODEV = NoSuchDevice, /// No such file or directory