VirtualFileSystem.INode.Create C# (CSharp) Méthode

Create() public static méthode

创建一个新的 inode
public static Create ( VFSCore vfs, UInt32 index, UInt32 flags, UInt32 owner ) : INode
vfs VFSCore
index System.UInt32
flags System.UInt32
owner System.UInt32
Résultat INode
        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;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// 分配、初始化一个新的 inode
        /// </summary>
        /// <returns></returns>
        public INode AllocateINode(UInt32 flags, UInt32 owner)
        {
            // 查找位图,寻找一个可用的 index
            UInt32 freeIndex = GetFreeINodeIndex();

            if (freeIndex == UInt32.MaxValue)
            {
                throw new Exception("inode 数量已满");
            }

            // 创建
            INode inode = INode.Create(this, freeIndex, flags, owner);

            // 置位
            SetBitmapAllocated(superBlock.pInodeBitVectors, inodeBitmaps, freeIndex);

            // 更新计数器
            superBlock.data.inodeAllocated++;
            superBlock.Save();

            return(inode);
        }