Exemplo n.º 1
0
        static async Task Main(string[] args)
        {
            string type = args.Length > 0 ? args[0] : "hello";

            if (!Fuse.CheckDependencies())
            {
                Console.WriteLine(Fuse.InstallationInstructions);
                return;
            }

            IFuseFileSystem fileSystem;

            if (type == "hello")
            {
                fileSystem = new HelloFileSystem();
            }
            else if (type == "memory")
            {
                fileSystem = new MemoryFileSystem();
            }
            else if (type == "pokemon")
            {
                fileSystem = new PokemonFileSystem();
            }
            else
            {
                System.Console.WriteLine("Unknown file system type");
                return;
            }

            string mountPoint = $"/tmp/{type}fs";

            System.Console.WriteLine($"Mounting filesystem at {mountPoint}");

            Fuse.LazyUnmount(mountPoint);

            // Ensure mount point directory exists
            Directory.CreateDirectory(mountPoint);

            try
            {
                using (var mount = Fuse.Mount(mountPoint, fileSystem))
                {
                    await mount.WaitForUnmountAsync();
                }
            }
            catch (FuseException fe)
            {
                Console.WriteLine($"Fuse throw an exception: {fe}");

                Console.WriteLine("Try unmounting the file system by executing:");
                Console.WriteLine($"fuser -kM {mountPoint}");
                Console.WriteLine($"sudo umount -f {mountPoint}");
            }
        }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            if (args.Length < 2)
            {
                throw new Exception($"Usage: NeoFS narpv|neovirt mountpoint <fuse-args>");
            }

            var fileType   = args[0].ToLowerInvariant();
            var mountPoint = args[1];

            args = args.Skip(2).ToArray();

            var conn       = Environment.GetEnvironmentVariable("MONGO_URI");
            var Connection = new MongoClient(conn);

            var NeoDb = Connection.GetDatabase("NeoAlexandria");

            var narps = NeoDb.NARPs();

            if (!Fuse.CheckDependencies())
            {
                Console.WriteLine(Fuse.InstallationInstructions);
                return;
            }

            // Test to see if we can new a FuseFileInfo

            IFuseFileSystem fileSystem;

            switch (fileType)
            {
            case "neofs":

                var provisioner = new ProvisionFilesystem();
                fileSystem = provisioner.CreateFs(NeoDb, narps);

                break;

            case "neovirt":
                fileSystem = new NeoVirtFS.NeoVirtFS(NeoDb);
                break;

            default:
                throw new Exception($"Unknown filesystem: {fileType}");
            }

            System.Console.WriteLine($"Mounting filesystem at {mountPoint}");

            Fuse.LazyUnmount(mountPoint);

            // Ensure mount point directory exists
            Directory.CreateDirectory(mountPoint);

            try
            {
                var mo = new MountOptions
                {
                    SingleThread = false
                };

                // Debug = "-d"
                using (var mount = Fuse.Mount(mountPoint, fileSystem, mo, Arguments: new string[] { "-o", "allow_other" }))
                {
                    await mount.WaitForUnmountAsync();
                }
            }
            catch (FuseException fe)
            {
                Console.WriteLine($"Fuse throw an exception: {fe}");

                Console.WriteLine("Try unmounting the file system by executing:");
                Console.WriteLine($"fuser -kM {mountPoint}");
                Console.WriteLine($"sudo umount -f {mountPoint}");
            }
        }