Example #1
0
        /// <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);
        }
Example #2
0
        public INode(VFSCore vfs, _INode data, UInt32 index = UInt32.MaxValue)
        {
            this.vfs   = vfs;
            this.data  = data;
            this.index = index;

            UInt32 blockSize     = vfs.GetSuperBlock().data.blockSize;
            UInt32 IndexPerBlock = blockSize / sizeof(UInt32);

            BoundLv0 = 12 * blockSize;
            BoundLv1 = BoundLv0 + IndexPerBlock * blockSize;
        }
Example #3
0
        /// <summary>
        /// 创建一个新的 inode
        /// </summary>
        /// <param name="vfs"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static INode Create(VFSCore vfs, UInt32 index, UInt32 flags, UInt32 owner)
        {
            if (index >= vfs.GetSuperBlock().data.inodeCapacity)
            {
                throw new Exception("无效 inode 编号");
            }

            _INode data  = new _INode(flags, owner);
            INode  inode = new INode(vfs, data, index);

            inode.Save();
            inodeInstances[index] = inode;

            return(inode);
        }
Example #4
0
        /// <summary>
        /// 创建一个新的 inode
        /// </summary>
        /// <param name="vfs"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static INode Create(VFSCore vfs, UInt32 index, UInt32 flags, UInt32 owner)
        {
            if (index >= vfs.GetSuperBlock().data.inodeCapacity)
            {
                throw new Exception("无效 inode 编号");
            }

            _INode data = new _INode(flags, owner);
            INode inode = new INode(vfs, data, index);
            inode.Save();
            inodeInstances[index] = inode;

            return inode;
        }
Example #5
0
        public INode(VFSCore vfs, _INode data, UInt32 index = UInt32.MaxValue)
        {
            this.vfs = vfs;
            this.data = data;
            this.index = index;

            UInt32 blockSize = vfs.GetSuperBlock().data.blockSize;
            UInt32 IndexPerBlock = blockSize / sizeof(UInt32);
            BoundLv0 = 12 * blockSize;
            BoundLv1 = BoundLv0 + IndexPerBlock * blockSize;
        }