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() { Partition p = PartitionOptions.GetPartition(); if (BytesPerSlice > int.MaxValue) { throw new CommandLineArgumentException("Argument to -s is too large."); } int bytesPerSlice = (int)BytesPerSlice; int fileSystemHeaderClusterSize = FileSystemHeaderCluster.CalculateClusterSize(p.BytesPerBlock); long bytesAvailable = p.SizeBytes - fileSystemHeaderClusterSize; 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 tracks, please use a larger value of Reed Solomon N and/or bytesPerCluster."); } g = new Geometry(bytesPerSlice, ReedSolomon.N, ReedSolomon.K, (int)totalTracks); Configuration.Geometry = g; Console.WriteLine($"Bytes per Cluster: {g.BytesPerCluster.ToFileSize()}"); Console.WriteLine($"Data Clusters per Track: {g.DataClustersPerTrack}"); Console.WriteLine($"Parity Clusters per Track: {g.ParityClustersPerTrack}"); Console.WriteLine($"Total Clusters per Track: {g.ClustersPerTrack}"); Console.WriteLine($"Resiliency: {(double)g.ParityClustersPerTrack / g.ClustersPerTrack:%#0.00}"); Console.WriteLine($"Total Tracks: {g.TrackCount}"); Console.WriteLine($"Bytes Used: {(g.CalculateFileSystemSize(p.BytesPerBlock)).ToFileSize()}"); Console.WriteLine($"Bytes Available: {((long)g.DataClustersPerTrack * g.TrackCount * (g.BytesPerCluster - FileDataCluster.FileBaseClusterHeaderLength)).ToFileSize()}"); Console.WriteLine($"Bytes Wasted: {(p.SizeBytes - g.CalculateFileSystemSize(p.BytesPerBlock)).ToFileSize()}"); }
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() { 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()}"); } }