Exemplo n.º 1
0
        public RPCResult <bool> Mount(string mount_path, string src)
        {
            /* Open source file */
            tysos.lib.File f_src = OpenFile(src, System.IO.FileMode.Open,
                                            System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite,
                                            System.IO.FileOptions.None).Sync();
            if (f_src == null || f_src.Error != tysos.lib.MonoIOError.ERROR_SUCCESS)
            {
                System.Diagnostics.Debugger.Log(0, null, "Mount: couldn't open source: " + src);
                return(false);
            }

            tysos.lib.File.Property driver = f_src.GetPropertyByName("driver");
            if (driver == null)
            {
                System.Diagnostics.Debugger.Log(0, null, "Mount: no driver specified in properties of " + src);
                return(false);
            }
            string protocol = driver.Value as string;

            if (protocol == null || protocol == "")
            {
                System.Diagnostics.Debugger.Log(0, null, "Mount: driver property of " + src + " is invalid");
                return(false);
            }

            return(Mount(mount_path, f_src, protocol));
        }
Exemplo n.º 2
0
        public RPCResult <tysos.Interfaces.IFileSystem> CreateFSHandler(tysos.lib.File src)
        {
            // Get the modules associated with the handler
            tysos.lib.File.Property m_param =
                src.GetPropertyByName("mods");
            if (m_param == null)
            {
                throw new Exception("src does not contain 'mods' property");
            }

            List <tysos.lib.File.Property> mods = m_param.Value as
                                                  List <tysos.lib.File.Property>;

            if (mods == null)
            {
                throw new Exception("mods is of inappropriate type");
            }

            modfs fs = new modfs(mods);

            // Fork off a separate process to handle this instance of the driver
            tysos.Process p = tysos.Process.CreateProcess("modfs: " + src.Name,
                                                          new System.Threading.ThreadStart(fs.MessageLoop), new object[] { fs });
            p.Start();

            System.Diagnostics.Debugger.Log(0, "modfs", "Created FS handler\n");
            return(fs);
        }
Exemplo n.º 3
0
        public RPCResult <tysos.Interfaces.IFileSystem> CreateFSHandler(tysos.lib.File src)
        {
            // Get the properties of the source file
            tysos.lib.File.Property[] props = src.GetAllProperties();
            if (props == null)
            {
                props = new tysos.lib.File.Property[] { }
            }
            ;

            // Ensure the device is a pciide device
            tysos.lib.File.Property driver = src.GetPropertyByName("driver");
            if (driver == null || driver.Value == null || !(driver.Value is string) || ((string)driver.Value).Equals("pciide") == false)
            {
                System.Diagnostics.Debugger.Log(0, "pciide", "driver property is invalid");
                return(null);
            }

            // Get the subdriver
            string subdriver_str = "";

            tysos.lib.File.Property subdriver = src.GetPropertyByName("subdriver");
            if (subdriver != null && subdriver.Value != null && (subdriver.Value is string))
            {
                subdriver_str = subdriver.Value as string;
            }

            System.Diagnostics.Debugger.Log(0, "pciide", "subdriver " + subdriver_str + " not found");

            pciide.DriverType dt = pciide.DriverType.Unknown;
            if (subdriver_str == "legacy")
            {
                dt = pciide.DriverType.Legacy;
            }
            else if (subdriver_str == "pcinative")
            {
                dt = pciide.DriverType.PCINative;
            }

            pciide fs = new pciide(props, dt);

            tysos.Process p = tysos.Process.CreateProcess("pciide: " + src.Name,
                                                          new System.Threading.ThreadStart(fs.MessageLoop), new object[] { fs });
            p.Start();

            return(fs);
        }
    }
Exemplo n.º 4
0
        public RPCResult <tysos.Interfaces.IFileSystem> CreateFSHandler(tysos.lib.File src)
        {
            // Get the properties of the source file
            tysos.lib.File.Property[] props = src.GetAllProperties();
            if (props == null)
            {
                props = new tysos.lib.File.Property[] { }
            }
            ;

            // Ensure the device is a PCI device
            tysos.lib.File.Property driver = src.GetPropertyByName("driver");
            if (driver == null || driver.Value == null || !(driver.Value is string) || ((string)driver.Value).Equals("pci") == false)
            {
                System.Diagnostics.Debugger.Log(0, "pci", "driver property is invalid");
                return(null);
            }

            // Get the subdriver
            string subdriver_str = "";

            tysos.lib.File.Property subdriver = src.GetPropertyByName("subdriver");
            if (subdriver != null && subdriver.Value != null && (subdriver.Value is string))
            {
                subdriver_str = subdriver.Value as string;
            }

            if (subdriver_str == "hostbridge")
            {
                // Create and execute a handler in a separate address space
                hostbridge    fs = new hostbridge(props);
                tysos.Process p  = tysos.Process.CreateProcess("pci: " + src.Name,
                                                               new System.Threading.ThreadStart(fs.MessageLoop), new object[] { fs });
                p.Start();

                System.Diagnostics.Debugger.Log(0, "pci", "Created FS handler\n");
                return(fs);
            }

            System.Diagnostics.Debugger.Log(0, "pci", "subdriver " + subdriver_str + " not found");
            return(null);
        }
    }
Exemplo n.º 5
0
        public RPCResult <tysos.Interfaces.IFileSystem> CreateFSHandler(tysos.lib.File src)
        {
            // Get the properties of the source file
            tysos.lib.File.Property[] props = src.GetAllProperties();
            if (props == null)
            {
                props = new tysos.lib.File.Property[] { }
            }
            ;

            // Create and execute a handler in a separate address space
            acpipc fs = new acpipc(props);

            tysos.Process p = tysos.Process.CreateProcess("acpipc: " + src.Name,
                                                          new System.Threading.ThreadStart(fs.MessageLoop), new object[] { fs });
            p.Start();

            System.Diagnostics.Debugger.Log(0, "acpipc", "Created FS handler\n");
            return(fs);
        }
    }
Exemplo n.º 6
0
        private void getFSE(string[] split_path, int cur_depth, List <string> ret,
                            tysos.lib.File cur_dir_f, List <string> cur_path, int attrs, int mask)
        {
            // Get the children of the current node
            if (cur_dir_f == null || cur_dir_f.Error != tysos.lib.MonoIOError.ERROR_SUCCESS)
            {
                System.Diagnostics.Debugger.Log(0, null, "getFSE: cur_dir_f is null");
                return;
            }
            tysos.lib.File.Property children = cur_dir_f.GetPropertyByName("Children");
            if (children == null)
            {
                System.Diagnostics.Debugger.Log(0, null, "getFSE: GetPropertyByName(\"Children\") returned null");
                return;
            }

            // Iterate through each, seeing if they match the current part of the name
            IList <string> children_list = children.Value as IList <string>;

            if (children_list == null)
            {
                System.Diagnostics.Debugger.Log(0, null, "getFSE: children.Value is not of type " +
                                                "IList<string> (instead is " + children.Value.GetType().FullName + ")");
                ulong v0 = libsupcs.CastOperations.ReinterpretAsUlong(children.Value);
                ulong v1 = libsupcs.CastOperations.ReinterpretAsUlong(children.Value.GetType());
                ulong v2 = libsupcs.CastOperations.ReinterpretAsUlong(typeof(IList <string>));
                System.Diagnostics.Debugger.Log(0, null, "getFSE: " + v1.ToString("X16") + " (" + v0.ToString("X16") + ") vs " + v2.ToString("X16"));
                return;
            }
            foreach (string child in children_list)
            {
                //tysos.Syscalls.DebugFunctions.DebugWrite("getFSE: examining child: " + child + "\n");

                if (match(child, split_path[cur_depth], true))
                {
                    //tysos.Syscalls.DebugFunctions.DebugWrite("match successful\n");

                    /* Build the absolute path to the child */
                    StringBuilder cur_child_path = new StringBuilder();
                    foreach (string parent in cur_path)
                    {
                        cur_child_path.Append("/");
                        cur_child_path.Append(parent);
                    }
                    cur_child_path.Append("/");
                    cur_child_path.Append(child);

                    /* Open the file to get its properties */
                    tysos.lib.File child_dir = OpenFile(cur_child_path.ToString(),
                                                        System.IO.FileMode.Open, System.IO.FileAccess.Read,
                                                        System.IO.FileShare.ReadWrite,
                                                        System.IO.FileOptions.None).Sync();
                    if (child_dir == null || child_dir.Error != tysos.lib.MonoIOError.ERROR_SUCCESS)
                    {
                        System.Diagnostics.Debugger.Log(0, null, "getFSE: OpenFile(" + cur_child_path.ToString() + ") failed");
                        return;
                    }
                    int int_attrs = child_dir.IntProperties;

                    /* If this is the deepest depth to check, then all matching
                     * children are valid and should be added to ret */
                    if (cur_depth == split_path.Length - 1)
                    {
                        //tysos.Syscalls.DebugFunctions.DebugWrite("adding: " + cur_child_path.ToString() + "\n");

                        if ((int_attrs & mask) == attrs)
                        {
                            ret.Add(cur_child_path.ToString());
                        }
                    }
                    else
                    {
                        /* We are not yet at the deepest search path yet -
                         * recurse into the next directory if it is one */
                        System.IO.FileAttributes child_attrs = (System.IO.FileAttributes)int_attrs;
                        if ((child_attrs & System.IO.FileAttributes.Directory) != 0)
                        {
                            /* This is a directory - recurse into it */
                            cur_path.Add(child);
                            getFSE(split_path, cur_depth + 1, ret, child_dir, cur_path, attrs, mask);
                            cur_path.RemoveAt(cur_path.Count - 1);
                        }

                        CloseFile(child_dir);
                    }
                }
                else
                {
                    // tysos.Syscalls.DebugFunctions.DebugWrite("match unsuccessful\n");
                }
            }
        }