Sfoglia il codice sorgente

Added a Sync message to disks + a Sync command to Partitions. These request writing back to hardware any block cached by the disk itself.

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7454 8c9fc860-2736-0410-a75d-ab315db34111
eth.tmartiel 7 anni fa
parent
commit
f680580e28
3 ha cambiato i file con 37 aggiunte e 1 eliminazioni
  1. 1 0
      source/Disks.Mod
  2. 23 1
      source/Partitions.Mod
  3. 13 0
      source/PartitionsLib.Mod

+ 1 - 0
source/Disks.Mod

@@ -114,6 +114,7 @@ TYPE
 	END Device;
 
 	EjectMsg* = RECORD (Message) END;	(** eject the media *)
+	SyncMsg* = RECORD (Message) END;	(** sync driver caches *)
 	LockMsg* = RECORD (Message) END;	(** disallow manual ejection *)
 	UnlockMsg* = RECORD (Message) END;	(** allow manual ejection *)
 	SavePowerMsg* = RECORD (Message) END;	(** spin down the device *)

+ 23 - 1
source/Partitions.Mod

@@ -19,6 +19,7 @@ MODULE Partitions; (** AUTHOR "staubesv"; PURPOSE "Commandline front-end for Par
  *
  *	Partitions.Check dev#part ~						Perform a read test on the specified partition
  *	Partitions.Eject dev ~								Eject medium of the specified device
+ *	Partitions.Sync dev ~								Synchronize device caches to medium
  *
  * 	Partitions.Safe~ 									Disallow extremely critical operations
  * 	Partitions.Unsafe~								Allow extermely critical operations
@@ -545,10 +546,31 @@ BEGIN
 			context.error.String("Device "); context.error.String(name); context.error.String(" not found"); context.error.Ln;
 		END;
 	ELSE
-		context.error.String("Exspected parameters: dev"); context.error.Ln;
+		context.error.String("Expected parameters: dev"); context.error.Ln;
 	END;
 END Eject;
 
+(** Sync device to medium *)
+PROCEDURE Sync*(context: Commands.Context); (** dev ~ *)
+VAR
+	plugin: Plugins.Plugin;
+	dev: Disks.Device;
+	name: ARRAY 32 OF CHAR;
+	temp: ARRAY 256 OF CHAR;
+BEGIN
+	IF context.arg.GetString(name) THEN
+		plugin := Disks.registry.Get(name);
+		IF plugin # NIL THEN
+			dev := plugin (Disks.Device);
+			Lib.Sync(dev, temp); context.out.String(temp); context.out.Ln;
+		ELSE
+			context.error.String("Device "); context.error.String(name); context.error.String(" not found"); context.error.Ln;
+		END;
+	ELSE
+		context.error.String("Expected parameters: dev"); context.error.Ln;
+	END;
+END Sync;
+
 PROCEDURE Unsafe*(context : Commands.Context); (** ~ *)
 BEGIN
 	Lib.safe := FALSE;

+ 13 - 0
source/PartitionsLib.Mod

@@ -3800,6 +3800,19 @@ BEGIN
 	END;
 END Eject;
 
+PROCEDURE Sync*(dev: AosDisks.Device; VAR result: ARRAY OF CHAR);
+VAR msg: AosDisks.SyncMsg; res: LONGINT; temp: ARRAY 256 OF CHAR;
+BEGIN
+	ASSERT(dev # NIL);
+	COPY(dev.name, result);
+	dev.Handle(msg, res);
+	IF res = AosDisks.Ok THEN
+		Strings.Append(result, " synchronized");
+	ELSE
+		GetErrorMsg(" synchronization failed: ", res, temp); Strings.Append(result, temp);
+	END;
+END Sync;
+
 PROCEDURE ShowAosFSLimits*;
 CONST Unit = 1024*1024*1024;
 VAR string : ARRAY 32 OF CHAR;