Пример #1
0
    public fileSystem mount(int mode, string fsTypeName, string mountPoint, string[] args)
    {
        string workPath = "/";
        FileNode aNode;
        string[] pathArray = mountPoint.Split('/');
        int counter = 0;
        fileSystem toMount = null;
        /*
        if (fsTypeName == "localfs")
            toMount = new LocalFS();
        if (fsTypeName == "timefs")
            toMount = new ClockFS();
        if (fsTypeName == "winfs")
            toMount = new WinFS();
        if (fsTypeName == "sysfs")
            toMount = new SysFS(args[0]);
        if (fsTypeName == "homefs")
            toMount = new HomeFS();
        if (fsTypeName == "procfs")
            toMount = new ProcFS();
        if (fsTypeName == "xmppfs")
            toMount = new XMPPFS();
        */
        while (counter <= pathArray.Length - 2)
        {
            if (workPath == "/")
                workPath = workPath + pathArray[counter];
            else
                workPath = workPath + '/' + pathArray[counter];
            counter++;
        }

        aNode = this.walk(workPath);
        //parse list of available filesystems for the one we've been asked to mount
        //while (counter < vfsList.length && vfsList[counter].Name != fs_type)
        //{
        //    counter++;
        //}

        if (aNode.getType() == 1)//&& vfsList[counter].Name == fs_type)
        {
            var count = 0;
            if (aNode.getDirList().Count > 0)
            {
                while (count < aNode.getData().Length - 1 && aNode.getDirList()[count].getName() != pathArray[pathArray.Length - 1])
                {
                    count++;
                }
                aNode.getDirList();
            }

            FileNode newFile = new FileNode(pathArray[pathArray.Length - 1], fileTypes.Mount);

            newFile.addParent(aNode);
            aNode.addChild(newFile);

            if (aNode.countChildren() > 0)
            {
                newFile.setPrev(aNode.getDirList().ElementAt(aNode.countChildren() - 1));
            }

            if (aNode.countChildren() >= 2)
            {
                aNode.getDirList()[aNode.countChildren() - 2].setNext(newFile);
            }

            this.touched(aNode);
            newFile.setMount(toMount);
            return toMount.onmount(mountPoint);// serverAddress, fs_type, mountPoint, user, pass, argv));
           }
           else
            return null;
    }