Implemented missing methods, for full MFS read-only support.

This commit is contained in:
2016-08-01 17:59:22 +01:00
parent b60f650733
commit e37f50d5d3
10 changed files with 716 additions and 26 deletions

View File

@@ -32,6 +32,7 @@
// ****************************************************************************/
using System.Collections.Generic;
using System;
namespace DiscImageChef.Filesystems.AppleMFS
{
@@ -40,12 +41,145 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
public override Errno ListXAttr(string path, ref List<string> xattrs)
{
return Errno.NotImplemented;
if(!mounted)
return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
xattrs = new List<string>();
if(debug)
{
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
{
if(device.ImageInfo.readableSectorTags.Contains(ImagePlugins.SectorTagType.AppleSectorTag))
xattrs.Add("com.apple.macintosh.tags");
return Errno.NoError;
}
}
uint fileID;
MFS_FileEntry entry;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(entry.flRLgLen > 0)
{
xattrs.Add("com.apple.ResourceFork");
if(debug && device.ImageInfo.readableSectorTags.Contains(ImagePlugins.SectorTagType.AppleSectorTag))
xattrs.Add("com.apple.ResourceFork.tags");
}
if(!ArrayHelpers.ArrayIsNullOrEmpty(entry.flUsrWds))
xattrs.Add("com.apple.FinderInfo");
if(debug && device.ImageInfo.readableSectorTags.Contains(ImagePlugins.SectorTagType.AppleSectorTag) && entry.flLgLen > 0)
xattrs.Add("com.apple.macintosh.tags");
xattrs.Sort();
return Errno.NoError;
}
public override Errno GetXattr(string path, string xattr, ref byte[] buf)
{
return Errno.NotImplemented;
if(!mounted)
return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
if(debug)
{
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
{
if(device.ImageInfo.readableSectorTags.Contains(ImagePlugins.SectorTagType.AppleSectorTag) &&
string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) == 0)
{
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
{
buf = new byte[directoryTags.Length];
Array.Copy(directoryTags, 0, buf, 0, buf.Length);
return Errno.NoError;
}
if(string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0)
{
buf = new byte[bitmapTags.Length];
Array.Copy(bitmapTags, 0, buf, 0, buf.Length);
return Errno.NoError;
}
if(string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0)
{
buf = new byte[bootTags.Length];
Array.Copy(bootTags, 0, buf, 0, buf.Length);
return Errno.NoError;
}
if(string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
{
buf = new byte[mdbTags.Length];
Array.Copy(mdbTags, 0, buf, 0, buf.Length);
return Errno.NoError;
}
}
else
return Errno.NoSuchExtendedAttribute;
}
}
uint fileID;
MFS_FileEntry entry;
Errno error;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(entry.flRLgLen > 0 && string.Compare(xattr, "com.apple.ResourceFork", StringComparison.InvariantCulture) == 0)
{
error = ReadFile(path, out buf, true, false);
return error;
}
if(entry.flRLgLen > 0 && string.Compare(xattr, "com.apple.ResourceFork.tags", StringComparison.InvariantCulture) == 0)
{
error = ReadFile(path, out buf, true, true);
return error;
}
if(!ArrayHelpers.ArrayIsNullOrEmpty(entry.flUsrWds) && string.Compare(xattr, "com.apple.FinderInfo", StringComparison.InvariantCulture) == 0)
{
buf = new byte[16];
Array.Copy(entry.flUsrWds, 0, buf, 0, 16);
return Errno.NoError;
}
if(debug && device.ImageInfo.readableSectorTags.Contains(ImagePlugins.SectorTagType.AppleSectorTag) &&
string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) == 0)
{
error = ReadFile(path, out buf, false, true);
return error;
}
return Errno.NoSuchExtendedAttribute;
}
}
}