diff --git a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj index 80193c96e..c8f7db7dd 100644 --- a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj +++ b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj @@ -108,6 +108,7 @@ + diff --git a/DiscImageChef.Filesystems/VxFS.cs b/DiscImageChef.Filesystems/VxFS.cs new file mode 100644 index 000000000..b92618c80 --- /dev/null +++ b/DiscImageChef.Filesystems/VxFS.cs @@ -0,0 +1,321 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : VxFS.cs +// Author(s) : Natalia Portillo +// +// Component : Veritas File System plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Veritas file system and shows information. +// +// --[ 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-2016 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace DiscImageChef.Filesystems +{ + class VxFS : Filesystem + { + public VxFS() + { + Name = "Veritas filesystem"; + PluginUUID = new Guid("EC372605-7687-453C-8BEA-7E0DFF79CB03"); + } + + public VxFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + { + Name = "Veritas filesystem"; + PluginUUID = new Guid("EC372605-7687-453C-8BEA-7E0DFF79CB03"); + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct VxSuperBlock + { + /// Magic number + public uint vs_magic; + /// VxFS version + public int vs_version; + /// create time - secs + public uint vs_ctime; + /// create time - usecs + public uint vs_cutime; + /// unused + public int __unused1; + /// unused + public int __unused2; + /// obsolete + public int vs_old_logstart; + /// obsolete + public int vs_old_logend; + /// block size + public int vs_bsize; + /// number of blocks + public int vs_size; + /// number of data blocks + public int vs_dsize; + /// obsolete + public uint vs_old_ninode; + /// obsolete + public int vs_old_nau; + /// unused + public int __unused3; + /// obsolete + public int vs_old_defiextsize; + /// obsolete + public int vs_old_ilbsize; + /// size of immediate data area + public int vs_immedlen; + /// number of direct extentes + public int vs_ndaddr; + /// address of first AU + public int vs_firstau; + /// offset of extent map in AU + public int vs_emap; + /// offset of inode map in AU + public int vs_imap; + /// offset of ExtOp. map in AU + public int vs_iextop; + /// offset of inode list in AU + public int vs_istart; + /// offset of fdblock in AU + public int vs_bstart; + /// aufirst + emap + public int vs_femap; + /// aufirst + imap + public int vs_fimap; + /// aufirst + iextop + public int vs_fiextop; + /// aufirst + istart + public int vs_fistart; + /// aufirst + bstart + public int vs_fbstart; + /// number of entries in indir + public int vs_nindir; + /// length of AU in blocks + public int vs_aulen; + /// length of imap in blocks + public int vs_auimlen; + /// length of emap in blocks + public int vs_auemlen; + /// length of ilist in blocks + public int vs_auilen; + /// length of pad in blocks + public int vs_aupad; + /// data blocks in AU + public int vs_aublocks; + /// log base 2 of aublocks + public int vs_maxtier; + /// number of inodes per blk + public int vs_inopb; + /// obsolete + public int vs_old_inopau; + /// obsolete + public int vs_old_inopilb; + /// obsolete + public int vs_old_ndiripau; + /// size of indirect addr ext. + public int vs_iaddrlen; + /// log base 2 of bsize + public int vs_bshift; + /// log base 2 of inobp + public int vs_inoshift; + /// ~( bsize - 1 ) + public int vs_bmask; + /// bsize - 1 + public int vs_boffmask; + /// old_inopilb - 1 + public int vs_old_inomask; + /// checksum of V1 data + public int vs_checksum; + /// number of free blocks + public int vs_free; + /// number of free inodes + public int vs_ifree; + /// number of free extents by size + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public int[] vs_efree; + /// flags ?!? + public int vs_flags; + /// filesystem has been changed + public byte vs_mod; + /// clean FS + public byte vs_clean; + /// unused + public ushort __unused4; + /// mount time log ID + public uint vs_firstlogid; + /// last time written - sec + public uint vs_wtime; + /// last time written - usec + public uint vs_wutime; + /// FS name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public byte[] vs_fname; + /// FS pack name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public byte[] vs_fpack; + /// log format version + public int vs_logversion; + /// unused + public int __unused5; + /// OLT extent and replica + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public int[] vs_oltext; + /// OLT extent size + public int vs_oltsize; + /// size of inode map + public int vs_iauimlen; + /// size of IAU in blocks + public int vs_iausize; + /// size of inode in bytes + public int vs_dinosize; + /// indir levels per inode + public int vs_old_dniaddr; + /// checksum of V2 RO + public int vs_checksum2; + } + + /// + /// Identifier for VxFS + /// + const uint VxFS_MAGIC = 0xA501FCF5; + const uint VxFS_Base = 0x400; + + public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + { + if(partitionStart >= partitionEnd) + return false; + + ulong vmfsSuperOff = VxFS_Base / imagePlugin.ImageInfo.sectorSize; + byte[] sector = imagePlugin.ReadSector(partitionStart + vmfsSuperOff); + + uint magic = BitConverter.ToUInt32(sector, 0x00); + + return magic == VxFS_MAGIC; + } + + public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information) + { + ulong vmfsSuperOff = VxFS_Base / imagePlugin.ImageInfo.sectorSize; + byte[] sector = imagePlugin.ReadSector(partitionStart + vmfsSuperOff); + + VxSuperBlock vxSb = new VxSuperBlock(); + IntPtr vxSbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vxSb)); + Marshal.Copy(sector, 0, vxSbPtr, Marshal.SizeOf(vxSb)); + vxSb = (VxSuperBlock)Marshal.PtrToStructure(vxSbPtr, typeof(VxSuperBlock)); + Marshal.FreeHGlobal(vxSbPtr); + + StringBuilder sbInformation = new StringBuilder(); + + sbInformation.AppendLine("Veritas file system"); + + sbInformation.AppendFormat("Volume version {0}", vxSb.vs_version).AppendLine(); + sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname)).AppendLine(); + sbInformation.AppendFormat("Volume has {0} blocks of {1} bytes each", vxSb.vs_bsize, vxSb.vs_size).AppendLine(); + sbInformation.AppendFormat("Volume has {0} inodes per block", vxSb.vs_inopb).AppendLine(); + sbInformation.AppendFormat("Volume has {0} free inodes", vxSb.vs_ifree).AppendLine(); + sbInformation.AppendFormat("Volume has {0} free blocks", vxSb.vs_free).AppendLine(); + sbInformation.AppendFormat("Volume created on {0}", DateHandlers.UNIXUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)).AppendLine(); + sbInformation.AppendFormat("Volume last modified on {0}", DateHandlers.UNIXUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)).AppendLine(); + if(vxSb.vs_clean != 0) + sbInformation.AppendLine("Volume is dirty"); + + information = sbInformation.ToString(); + + xmlFSType = new Schemas.FileSystemType(); + xmlFSType.Type = "Veritas file system"; + xmlFSType.CreationDate = DateHandlers.UNIXUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime); + xmlFSType.CreationDateSpecified = true; + xmlFSType.ModificationDate = DateHandlers.UNIXUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime); + xmlFSType.ModificationDateSpecified = true; + xmlFSType.Clusters = vxSb.vs_size; + xmlFSType.ClusterSize = vxSb.vs_bsize; + xmlFSType.Dirty = vxSb.vs_clean != 0; + xmlFSType.FreeClusters = vxSb.vs_free; + xmlFSType.FreeClustersSpecified = true; + } + + public override Errno Mount() + { + return Errno.NotImplemented; + } + + public override Errno Mount(bool debug) + { + return Errno.NotImplemented; + } + + public override Errno Unmount() + { + return Errno.NotImplemented; + } + + public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock) + { + return Errno.NotImplemented; + } + + public override Errno GetAttributes(string path, ref FileAttributes attributes) + { + return Errno.NotImplemented; + } + + public override Errno ListXAttr(string path, ref List xattrs) + { + return Errno.NotImplemented; + } + + public override Errno GetXattr(string path, string xattr, ref byte[] buf) + { + return Errno.NotImplemented; + } + + public override Errno Read(string path, long offset, long size, ref byte[] buf) + { + return Errno.NotImplemented; + } + + public override Errno ReadDir(string path, ref List contents) + { + return Errno.NotImplemented; + } + + public override Errno StatFs(ref FileSystemInfo stat) + { + return Errno.NotImplemented; + } + + public override Errno Stat(string path, ref FileEntryInfo stat) + { + return Errno.NotImplemented; + } + + public override Errno ReadLink(string path, ref string dest) + { + return Errno.NotImplemented; + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index af068e238..fb80ea257 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ Supported file systems for identification and information only * Professional File System * SmartFileSystem * VMware file system (VMFS) +* Veritas file system Supported checksums =================== diff --git a/TODO b/TODO index 8f1ccb53e..3ebc5d30f 100644 --- a/TODO +++ b/TODO @@ -14,7 +14,6 @@ Filesystem plugins: --- Add support for ZFS --- Add support for UDF --- Add support for CramFS ---- Add support for VxFS --- Add support for NwFS --- Add support for Squashfs --- Add support for X-Box filesystems