Beispiel #1
0
        static int RawDiskSeekTest(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[diskName]", ConsoleService.Prompt, "Physical disk name: ", ConsoleService.EvalNotEmpty, null),
            };

            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string diskName = vl.DefaultParam.StrValue;

            using var rawFs = new LocalRawDiskFileSystem();
            using var disk  = rawFs.Open($"/{diskName}");

            int           size     = 4096;
            long          diskSize = disk.Size;
            Memory <byte> tmp      = new byte[size];

            int numSeek = 0;

            long startTick = Time.HighResTick64;

            long last = 0;

            while (true)
            {
                long pos = (Util.RandSInt63() % (diskSize - (long)size)) / 4096L * 4096L;

                disk.ReadRandom(pos, tmp);
                numSeek++;

                if ((numSeek % 10) == 0)
                {
                    long now = Time.HighResTick64;

                    if (now > startTick)
                    {
                        if (last == 0 || (last + 1000) <= now)
                        {
                            last = now;

                            double secs = (double)(now - startTick) / 1000.0;

                            double averageSeekTime = secs / (double)numSeek;

                            Con.WriteLine(averageSeekTime.ToString("F6"));

                            if (now >= (startTick + (10 * 1000)))
                            {
                                break;
                            }
                        }
                    }
                }
            }

            Con.WriteLine();

            return(0);
        }
Beispiel #2
0
        static void RawDiskEnum()
        {
            using (var rawFs = new LocalRawDiskFileSystem())
            {
                Con.WriteLine();

                var items = rawFs.EnumDirectory("/");

                foreach (var item in items.Where(x => x.IsFile))
                {
                    Con.WriteLine($"{item.Name}    -  {item.Size._ToString3()} bytes");
                }

                Con.WriteLine();
            }
        }
Beispiel #3
0
        static int RawDiskRestore(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[diskName]", ConsoleService.Prompt, "Physical disk name: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("src",        ConsoleService.Prompt, "Source file name: ",   ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("truncate"),
            };

            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string diskName    = vl.DefaultParam.StrValue;
            string dstFileName = vl["src"].StrValue;
            long   truncate    = vl["truncate"].StrValue._ToLong();

            if (truncate <= 0)
            {
                truncate = -1;
            }
            else
            {
                truncate = (truncate + 4095L) / 4096L * 4096L;
            }

            using (var rawFs = new LocalRawDiskFileSystem())
            {
                using (var disk = rawFs.Open($"/{diskName}", writeMode: true))
                {
                    using (var file = Lfs.Open(dstFileName, flags: FileFlags.AutoCreateDirectory))
                    {
                        using (var reporter = new ProgressReporter(new ProgressReporterSetting(ProgressReporterOutputs.Console, toStr3: true), null))
                        {
                            FileUtil.CopyBetweenFileBaseAsync(file, disk, truncateSize: truncate, param: new CopyFileParams(asyncCopy: true, bufferSize: 16 * 1024 * 1024), reporter: reporter)._GetResult();
                        }
                    }
                }
            }

            return(0);
        }
Beispiel #4
0
 public Win32LocalRawDiskVfsFile(LocalRawDiskFileSystem fileSystem, RawDiskItemData itemData) : base(fileSystem, itemData)
 {
 }