コード例 #1
0
        /// <summary>
        /// Initializes PciFS
        /// </summary>
        public static unsafe void Init()
        {
            m_container = new ContainerFS();
            RootPoint dev = new RootPoint("pci", m_container.Node);

            VFS.MountPointDevFS.AddEntry(dev);
        }
コード例 #2
0
ファイル: Disk.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// Mount root partition to VFS
        /// </summary>
        /// <param name="node">Partition node</param>
        /// <param name="name">Mount name</param>
        /// <param name="fsType">Filesystem type</param>
        /// <returns>Status</returns>
        public static DiskMountResult Mount(Node node, string name, string fsType)
        {
            IFilesystem fs = (IFilesystem)mFilesystems.Get(fsType);

            if (fs == null)
            {
                return(DiskMountResult.FS_TYPE_NOT_FOUND);
            }

            Node retNode = fs.Init(node);

            if (retNode == null)
            {
                return(DiskMountResult.INIT_FAIL);
            }

            RootPoint point = VFS.RootMountPoint.GetEntry(name);

            if (point != null)
            {
                return(DiskMountResult.MOUNT_POINT_ALREADY_USED);
            }

            RootPoint dev = new RootPoint(name, retNode);

            VFS.RootMountPoint.AddEntry(dev);

            return(DiskMountResult.SUCCESS);
        }
コード例 #3
0
ファイル: VFS.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// Get node by absolute path
        /// </summary>
        /// <param name="path">The absolute path</param>
        /// <returns>The node</returns>
        public static unsafe Node GetByAbsolutePath(string path, int offsetEnd)
        {
            int index      = path.IndexOf("://");
            int pathLength = path.Length;

            // Get the device name
            string deviceName = path.Substring(0, index);

            // Find first mount
            RootPoint point = RootMountPoint.GetEntry(deviceName);

            Heap.Free(deviceName);
            if (point == null)
            {
                return(null);
            }

            Node lastNode = point.Node;

            // Possibly add a slash
            bool addedSlash = (path[pathLength - 1] != '/');

            if (addedSlash)
            {
                path = String.Merge(path, "/");
            }

            int parts = String.Count(path, '/') - 2;

            parts -= offsetEnd;

            // Loop through the slashes
            int offset = index + 3;

            while (parts > 0 && lastNode != null)
            {
                int newOffset = path.IndexOf('/', offset);

                string part = path.Substring(offset, newOffset - offset);
                lastNode = lastNode.FindDir(lastNode, part);
                Heap.Free(part);

                offset = newOffset + 1;
                parts--;
            }

            if (addedSlash)
            {
                Heap.Free(path);
            }

            if (lastNode == null)
            {
                return(null);
            }

            return(lastNode.Clone());
        }
コード例 #4
0
ファイル: AudioFS.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// Initializes the audio filesystem
        /// </summary>
        public unsafe static void Init()
        {
            m_buffers   = new List();
            m_tmpBuffer = new ushort[BufferSize];
            m_container = new ContainerFS();

            RootPoint dev = new RootPoint("audio", m_container.Node);

            VFS.RootMountPoint.AddEntry(dev);
        }
コード例 #5
0
        /// <summary>
        /// Initializes Null device
        /// </summary>
        public unsafe static void Init()
        {
            Node node = new Node();

            node.Read = readImpl;
            node.Size = 0xFFFFFFFF;

            RootPoint dev = new RootPoint("random", node);

            VFS.MountPointDevFS.AddEntry(dev);
        }
コード例 #6
0
        /// <summary>
        /// Initializes DevFS
        /// </summary>
        public unsafe static void Init()
        {
            Node node = new Node();

            node.FindDir = rootFindDirImpl;
            node.ReadDir = rootReadDirImpl;
            node.Flags   = NodeFlags.DIRECTORY;

            RootPoint dev = new RootPoint("proc", node);

            VFS.RootMountPoint.AddEntry(dev);
        }
コード例 #7
0
        /// <summary>
        /// Initializes the networking info filesystem module
        /// </summary>
        public static unsafe void Init()
        {
            Node node = new Node();

            node.FindDir = findDirImpl;
            node.ReadDir = readDirImpl;
            node.Flags   = NodeFlags.DIRECTORY;

            RootPoint dev = new RootPoint("info", node);

            VFS.MountPointNetFS.AddEntry(dev);
        }
コード例 #8
0
ファイル: ContainerFS.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// FS finddir
        /// </summary>
        /// <param name="node">The node</param>
        /// <param name="name">The name to look for</param>
        /// <returns>The node</returns>
        private static unsafe Node findDirImpl(Node node, string name)
        {
            ContainerCookie cookie = (ContainerCookie)node.Cookie;
            RootPoint       root   = cookie.FS.GetEntry(name);

            if (root == null)
            {
                return(null);
            }

            return(root.Node);
        }
コード例 #9
0
ファイル: AudioFS.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// Set sound Device
        /// </summary>
        /// <param name="device"></param>
        public static void SetDevice(SoundDevice device)
        {
            // TODO: support multiple audio devices
            m_device = device;

            Node node = new Node();

            node.Open  = openImpl;
            node.Write = writeImpl;
            node.Close = closeImpl;

            RootPoint point = new RootPoint("default", node);

            m_container.AddEntry(point);
        }
コード例 #10
0
ファイル: PacketFS.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// Initializes a filesystem that is a container
        /// </summary>
        public static unsafe void Init()
        {
            m_children = new StringDictionary(8);
            m_mutex    = new Mutex();

            Node node = new Node();

            node.ReadDir = readDirImpl;
            node.FindDir = findDirImpl;
            node.Create  = Create;

            RootPoint dev = new RootPoint("packetfs", node);

            VFS.RootMountPoint.AddEntry(dev);
        }
コード例 #11
0
ファイル: ContainerFS.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// FS readdir
        /// </summary>
        /// <param name="node">The node</param>
        /// <param name="index">The index</param>
        /// <returns>The directory entry</returns>
        private static unsafe DirEntry *readDirImpl(Node node, uint index)
        {
            ContainerCookie cookie = (ContainerCookie)node.Cookie;
            RootPoint       dev    = cookie.FS.GetAt(index);

            if (dev == null)
            {
                return(null);
            }

            DirEntry *entry = (DirEntry *)Heap.Alloc(sizeof(DirEntry));

            String.CopyTo(entry->Name, dev.Name);

            return(entry);
        }
コード例 #12
0
        /// <summary>
        /// Load devices
        /// </summary>
        public static unsafe void LoadDevices()
        {
            for (int i = 0; i < Pci.DeviceNum; i++)
            {
                PciDevice dev  = Pci.Devices[i];
                string    name = GenerateNodeName(dev.Bus, dev.Slot, dev.Function);

                Node node = new Node();
                node.Size   = (uint)sizeof(PciFSInfo);
                node.Read   = readImpl;
                node.Flags  = NodeFlags.FILE | NodeFlags.DEVICE;
                node.Cookie = new PciDeviceCookie(dev);

                RootPoint point = new RootPoint(name, node);
                m_container.AddEntry(point);
            }
        }
コード例 #13
0
ファイル: VFS.cs プロジェクト: valentinbreiz/Sharpen
        /// <summary>
        /// Initializes VFS
        /// </summary>
        public static void Init()
        {
            // Container of all mountpoints
            RootMountPoint = new ContainerFS();

            // DevFS
            MountPointDevFS = new ContainerFS();
            RootPoint devMount = new RootPoint("devices", MountPointDevFS.Node);

            RootMountPoint.AddEntry(devMount);

            // NetFS
            MountPointNetFS = new ContainerFS();
            RootPoint netMount = new RootPoint("net", MountPointNetFS.Node);

            RootMountPoint.AddEntry(netMount);

            // Initialize other filesystems
            initFileSystems();

            Console.WriteLine("[VFS] Initialized");
        }
コード例 #14
0
ファイル: ContainerFS.cs プロジェクト: valentinbreiz/Sharpen
 /// <summary>
 /// Adds an entry
 /// </summary>
 /// <param name="entry">The entry</param>
 public void AddEntry(RootPoint entry)
 {
     m_children.Add(entry.Name, entry);
 }