Implements path resolution functionality for the Mosa.VFS.VirtualFileSystem.
Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="access"></param>
        /// <param name="share"></param>
        /// <returns></returns>
        public static object Open(string path, System.IO.FileAccess access, System.IO.FileShare share)
        {
            DirectoryEntry entry = PathResolver.Resolve(rootNode, ref path);

            /* HINT:
             *
             * 1. Do we really need to pass the FileShare flags down to the inode?
             * 2. Shouldn't we have some sort of lock deamon governing shared access?
             *
             * Ansers:
             * 1. Yes.
             * 2. Yes and no. A lock deamon would only work for local filesystems. For imported
             *    ones we need to notify the server of the sharing lock anyway, so that the IVfsNode
             *    (acting as a client to the server) is the best place to do it without giving the
             *    lock deamon knowledge of all file sharing protocols (afp, smb, ftp, name it.)
             * 3. The inode may reject the file sharing requests. We do want to represent devices
             *    and sync objects in the VFS, which means *they* need to decide if the flags are
             *    applicable.
             *
             */

            // FIXME: Perform access checks on the DirectoryEntry/IVfsNode.
            AccessMode modeFlags = AccessMode.Exists;

            switch (access)
            {
            case System.IO.FileAccess.Read:
                modeFlags = AccessMode.Read;
                break;

            case System.IO.FileAccess.Write:
                modeFlags = AccessMode.Write;
                break;

            case System.IO.FileAccess.ReadWrite:
                modeFlags = AccessMode.Read | AccessMode.Write;
                break;
            }

            AccessCheck.Perform(entry, modeFlags, AccessCheckFlags.None);

            return(entry.Node.Open(access, share));
        }
Example #2
0
        /// <summary>
        /// Mounts a new file system.
        /// </summary>
        /// <param name="source">The source of the filesystem. This is usually a device name, but can also be another directory.</param>
        /// <param name="target">The path including the name of the mount point, where to mount the new filesystem.</param>
        public static void Mount(string source, string target)
        {
            // Retrieve the parent directory of the mount
            DirectoryEntry parent = PathResolver.Resolve(rootNode, ref target, PathResolutionFlags.RetrieveParent);

            if (parent == null)
            {
                throw new System.ArgumentException();
            }

            IFileSystem root = FileSystemFactory.CreateFileSystem(source);

            if (root == null)
            {
                throw new System.ArgumentException();
            }

            PathSplitter path = new PathSplitter(target);

            DirectoryEntry.Allocate(parent, path.Last, root.Root);
        }
Example #3
0
 /// <summary>
 /// Changes the current directory in the thread execution block.
 /// </summary>
 /// <param name="path">The path to change to. This path may be relative or absolute.</param>
 public static void ChangeDirectory(string path)
 {
     DirectoryEntry entry = PathResolver.Resolve(rootNode, ref path);
     // FIXME: Set the current directory in the thread execution block
 }