public void Invoke() { Options options = Options.None; if (doNotVerifyHashes) { options |= Options.DoNotVerifyClusterHashes; } if (doNotVerifySignatures) { options |= Options.DoNotVerifyClusterSignatures; } Configuration.Options = options; CngKey encryptionKey = CryptoSettingsOptions.GetEncryptionKey(); CngKey decryptionKey = CryptoSettingsOptions.GetDecryptionKey(); CngKey signingKey = CryptoSettingsOptions.GetSigningKey(); Configuration.CryptoSettings = new CryptoSettings(decryptionKey, signingKey, encryptionKey); using (var pio = new PartitionIO(PartitionOptions.GetPartition())) using (var fs = FileSystem.Mount(pio)) { SRFSDokan d = new SRFSDokan(fs); d.Mount("S:\\"); } }
public void Invoke() { int blockSize = 512; Configuration.VolumeName = FilePath; if (BytesPerSlice > int.MaxValue) { throw new CommandLineArgumentException("Argument to -s is too large."); } int bytesPerSlice = (int)BytesPerSlice; Geometry g = new Geometry(bytesPerSlice, ReedSolomon.N, ReedSolomon.K, TrackCount); Configuration.Geometry = g; Configuration.FileSystemID = Guid.NewGuid(); Options options = Options.None; if (doNotVerifyHashes) { options |= Options.DoNotVerifyClusterHashes; } if (doNotVerifySignatures) { options |= Options.DoNotVerifyClusterSignatures; } Configuration.Options = options; CngKey encryptionKey = CryptoSettingsOptions.GetEncryptionKey(); CngKey decryptionKey = CryptoSettingsOptions.GetDecryptionKey(); CngKey signingKey = CryptoSettingsOptions.GetSigningKey(); Configuration.CryptoSettings = new CryptoSettings(decryptionKey, signingKey, encryptionKey); long size = g.CalculateFileSystemSize(blockSize); if (size > int.MaxValue) { throw new CommandLineArgumentException("File system size is too large."); } using (MemoryIO io = new MemoryIO((int)size, blockSize)) using (FileStream fio = new FileStream(FilePath, FileMode.Create, FileAccess.Write)) { using (var f = FileSystem.Create(io)) { } fio.Write(io.Bytes, 0, (int)io.SizeBytes); } }
public void Invoke() { Partition p = PartitionOptions.GetPartition(); if (BytesPerSlice > int.MaxValue) { throw new CommandLineArgumentException("Argument to -s is too large."); } int bytesPerSlice = (int)BytesPerSlice; long bytesAvailable = p.SizeBytes - FileSystemHeaderCluster.CalculateClusterSize(p.BytesPerBlock); Geometry g = new Geometry(bytesPerSlice, ReedSolomon.N, ReedSolomon.K, 1); long totalTracks = bytesAvailable / g.CalculateTrackSizeBytes(p.BytesPerBlock); if (totalTracks > int.MaxValue) { throw new CommandLineArgumentException("Too many chains, please use a larger value of n (Reed Solomon parameter) and/or bytesPerSlice."); } g = new Geometry(bytesPerSlice, ReedSolomon.N, ReedSolomon.K, (int)totalTracks); Configuration.Geometry = g; Configuration.VolumeName = VolumeName; Configuration.FileSystemID = Guid.NewGuid(); Options options = Options.None; if (doNotVerifyHashes) { options |= Options.DoNotVerifyClusterHashes; } if (doNotVerifySignatures) { options |= Options.DoNotVerifyClusterSignatures; } Configuration.Options = options; CngKey encryptionKey = CryptoSettingsOptions.GetEncryptionKey(); CngKey decryptionKey = CryptoSettingsOptions.GetDecryptionKey(); CngKey signingKey = CryptoSettingsOptions.GetSigningKey(); Configuration.CryptoSettings = new CryptoSettings(decryptionKey, signingKey, encryptionKey); using (var f = FileSystem.Create(new PartitionIO(p))) { } }
public void Invoke() { int blockSize = 512; Options options = Options.None; if (doNotVerifyHashes) { options |= Options.DoNotVerifyClusterHashes; } if (doNotVerifySignatures) { options |= Options.DoNotVerifyClusterSignatures; } Configuration.Options = options; CngKey encryptionKey = CryptoSettingsOptions.GetEncryptionKey(); CngKey decryptionKey = CryptoSettingsOptions.GetDecryptionKey(); CngKey signingKey = CryptoSettingsOptions.GetSigningKey(); Configuration.CryptoSettings = new CryptoSettings(decryptionKey, signingKey, encryptionKey); long size = new FileInfo(FilePath).Length; using (MemoryIO io = new MemoryIO((int)size, blockSize)) using (FileStream fio = new FileStream(FilePath, FileMode.Open)) { fio.Read(io.Bytes, 0, (int)io.SizeBytes); using (var fs = FileSystem.Mount(io)) { SRFSDokan d = new SRFSDokan(fs); d.Mount("S:\\"); } fio.Position = 0; fio.Write(io.Bytes, 0, (int)io.SizeBytes); } }
public void Invoke() { Options options = Options.None; if (doNotVerifyHashes) { options |= Options.DoNotVerifyClusterHashes; } if (doNotVerifySignatures) { options |= Options.DoNotVerifyClusterSignatures; } Configuration.Options = options; CngKey encryptionKey = CryptoSettingsOptions.GetEncryptionKey(); CngKey decryptionKey = CryptoSettingsOptions.GetDecryptionKey(); CngKey signingKey = CryptoSettingsOptions.GetSigningKey(); Configuration.CryptoSettings = new CryptoSettings(decryptionKey, signingKey, encryptionKey); using (var pio = new PartitionIO(PartitionOptions.GetPartition())) using (var fs = FileSystem.Mount(pio)) { for (int tn = Track; tn < Track + TrackCount; tn++) { Track t = new Track(fs, tn); Console.WriteLine($"Track Number: {t.Number}"); Console.WriteLine($"Used: {t.Used}"); Console.WriteLine($"Parity Written: {t.ParityWritten}"); Console.WriteLine($"Up-to-date: {t.UpToDate}"); Console.WriteLine(); Console.WriteLine($"Data Clusters: {t.DataClusters.ToRanges()}"); var c = from i in t.DataClusters where fs.GetClusterState(i).IsUsed() select i; Console.WriteLine($" Used ({c.Count()}): {c.ToRanges()}"); c = from i in t.DataClusters where fs.GetClusterState(i).IsModified() select i; Console.WriteLine($" Modified ({c.Count()}): {c.ToRanges()}"); c = from i in t.DataClusters where fs.GetClusterState(i).IsUnwritten() select i; Console.WriteLine($" Unwritten ({c.Count()}): {c.ToRanges()}"); Console.WriteLine(); Console.WriteLine($"Parity Clusters: {t.ParityClusters.ToRanges()}"); c = from i in t.ParityClusters where fs.GetClusterState(i).IsUnwritten() select i; Console.WriteLine($" Unwritten ({c.Count()}): {c.ToRanges()}"); if (CalculateParity) { t.UpdateParity(Force); } if (VerifyParity) { Console.WriteLine("Verifying Parity"); if (t.VerifyParity()) { Console.WriteLine("Verified OK"); } else { Console.WriteLine("Corrupt"); } } else if (Repair) { Console.WriteLine("Repairing"); if (t.Repair()) { Console.WriteLine("Repair OK"); } else { Console.WriteLine("Repair Failed"); } } if (CalculateParity || Repair) { fs.Flush(); } } } }
public void Invoke() { Options options = Options.None; if (doNotVerifyHashes) { options |= Options.DoNotVerifyClusterHashes; } if (doNotVerifySignatures) { options |= Options.DoNotVerifyClusterSignatures; } Configuration.Options = options; CngKey encryptionKey = CryptoSettingsOptions.GetEncryptionKey(); CngKey decryptionKey = CryptoSettingsOptions.GetDecryptionKey(); CngKey signingKey = CryptoSettingsOptions.GetSigningKey(); Configuration.CryptoSettings = new CryptoSettings(decryptionKey, signingKey, encryptionKey); using (var pio = new PartitionIO(PartitionOptions.GetPartition())) using (var fs = FileSystem.Mount(pio)) { int nClusters = fs.NumberOfDataClusters; ClusterState[] states = new ClusterState[nClusters]; for (int i = 0; i < nClusters; i++) { states[i] = ClusterState.None; } foreach (var f in fs.Files) { foreach (var i in getFileSequence(fs, f)) { states[i] = ClusterState.Used; } } var systemClusters = from x in Enumerable.Range(0, fs.NumberOfDataClusters) where fs.GetClusterState(x).IsSystem() select x; Console.WriteLine($"System Clusters: {systemClusters.ToRanges()}"); Console.WriteLine($" Cluster States Table: {fs.ClusterStatesTableClusters.ToRanges()}"); foreach (var i in fs.ClusterStatesTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine($" Next Cluster Table: {fs.NextClusterTableClusters.ToRanges()}"); foreach (var i in fs.NextClusterTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine($" Bytes Used Table: {fs.BytesUsedTableClusters.ToRanges()}"); foreach (var i in fs.BytesUsedTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine($" Verify Time Table: {fs.VerifyTimeTableClusters.ToRanges()}"); foreach (var i in fs.VerifyTimeTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine($" Directory Table: {fs.DirectoryTableClusters.ToRanges()}"); foreach (var i in fs.DirectoryTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine($" File Table: {fs.FileTableClusters.ToRanges()}"); foreach (var i in fs.FileTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine($" Access Table: {fs.AccessTableClusters.ToRanges()}"); foreach (var i in fs.AccessTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine($" Audit Table: {fs.AuditTableClusters.ToRanges()}"); foreach (var i in fs.AuditTableClusters) { states[i] = ClusterState.Used | ClusterState.System; } Console.WriteLine(); var dataClusters = from x in Enumerable.Range(0, fs.NumberOfDataClusters) where (fs.GetClusterState(x) & ClusterState.Data) != 0 select x; Console.WriteLine($"Data Clusters: {dataClusters.ToRanges()}"); var unwrittenClusters = from x in Enumerable.Range(0, fs.NumberOfDataClusters) where (fs.GetClusterState(x) & ClusterState.Unwritten) != 0 select x; Console.WriteLine($"Unwritten Clusters: {unwrittenClusters.ToRanges()}"); var usedClusters = from x in Enumerable.Range(0, fs.NumberOfDataClusters) where fs.GetClusterState(x).IsUsed() select x; Console.WriteLine($"Used Clusters: {usedClusters.ToRanges()}"); var modifiedClusters = from x in Enumerable.Range(0, fs.NumberOfDataClusters) where fs.GetClusterState(x).IsModified() select x; Console.WriteLine($"Modified Clusters: {modifiedClusters.ToRanges()}"); int n = fs.ClusterStates.Count(); var parityClusters = from x in Enumerable.Range(0, n) where fs.GetClusterState(x).IsParity() select x; Console.WriteLine($"Parity Clusters: {parityClusters.ToRanges()}"); var nullClusters = from x in Enumerable.Range(0, n) where (fs.GetClusterState(x) & ClusterState.Null) != 0 select x; Console.WriteLine($"Null Clusters: {nullClusters.ToRanges()}"); var m = from x in Enumerable.Range(0, fs.NumberOfDataClusters) where states[x].IsUsed() != fs.GetClusterState(x).IsUsed() select x; Console.WriteLine($"Mismatch: {m.ToRanges()}"); Console.WriteLine(); var usedTracks = from t in from x in Enumerable.Range(0, Configuration.Geometry.TrackCount) select new Track(fs, x) where t.Used select t.Number; Console.WriteLine($"Used Tracks: {usedTracks.ToRanges()}"); var upToDateTracks = from t in from x in Enumerable.Range(0, Configuration.Geometry.TrackCount) select new Track(fs, x) where t.UpToDate select t.Number; Console.WriteLine($"Up-to-date Tracks: {upToDateTracks.ToRanges()}"); } }