/// <summary> /// 从存储介质中获取 inode /// </summary> /// <param name="vfs"></param> /// <param name="index"></param> /// <returns></returns> public static INode Load(VFSCore vfs, UInt32 index) { if (index >= vfs.GetSuperBlock().data.inodeCapacity) { throw new Exception("无效 inode 编号"); } INode inode = null; if (inodeInstances.ContainsKey(index)) { inode = inodeInstances[index]; return(inode); } else { _INode data = vfs.GetDevice().Read <_INode>(GetPosition(vfs, index)); inode = new INode(vfs, data, index); inodeInstances[index] = inode; } inode.data.accessTime = (UInt64)DateTime.Now.Ticks; inode.Save(); return(inode); }
/// <summary> /// 从存储介质上还原 SuperBlock /// </summary> /// <param name="vfs"></param> /// <returns></returns> public static SuperBlock Load(VFSCore vfs) { var _superBlock = vfs.GetDevice().Read <_SuperBlock>(0); return(new SuperBlock(vfs, _superBlock)); }
/// <summary> /// 将 superblock 写入存储介质 /// </summary> /// <param name="vfs"></param> public void Save() { vfs.GetDevice().Write(0, data); }
/// <summary> /// 将 inode 数据写入存储介质 /// </summary> /// <param name="vfs"></param> public void Save() { vfs.GetDevice().Write(GetPosition(), data); }
public DeviceAdapter.AbstractDevice GetDevice() { return(vfs.GetDevice()); }
/// <summary> /// 从存储介质上还原 SuperBlock /// </summary> /// <param name="vfs"></param> /// <returns></returns> public static SuperBlock Load(VFSCore vfs) { var _superBlock = vfs.GetDevice().Read<_SuperBlock>(0); return new SuperBlock(vfs, _superBlock); }
/// <summary> /// 从存储介质中获取 inode /// </summary> /// <param name="vfs"></param> /// <param name="index"></param> /// <returns></returns> public static INode Load(VFSCore vfs, UInt32 index) { if (index >= vfs.GetSuperBlock().data.inodeCapacity) { throw new Exception("无效 inode 编号"); } INode inode = null; if (inodeInstances.ContainsKey(index)) { inode = inodeInstances[index]; return inode; } else { _INode data = vfs.GetDevice().Read<_INode>(GetPosition(vfs, index)); inode = new INode(vfs, data, index); inodeInstances[index] = inode; } inode.data.accessTime = (UInt64)DateTime.Now.Ticks; inode.Save(); return inode; }