/// <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); }
/// <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); }
/// <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()); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); } }
/// <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"); }
/// <summary> /// Adds an entry /// </summary> /// <param name="entry">The entry</param> public void AddEntry(RootPoint entry) { m_children.Add(entry.Name, entry); }