[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] [PATCH] Sync devices when XHEject is called



Hi,

in the EmuTOS list has been discussed that removable drives (SD-Card,
USB memory sticks) can loose data when MiNT's block cache is in
writeback mode, even if the user use the desktop eject option (Thing
has it).

EmuTOS thread:
http://sourceforge.net/p/emutos/mailman/message/31884346/

Attached there is a patch to sync all devices if XHEject XHDI function
is caught by the MiNT's XHDI handle.

I've tried to sync only the device being removed, but the functions to
do so are only usable by file system drivers and the block cache code.

Alan if nobody has any objection please commit.


Commit message:


Sync devices when the function XHEject is caught by XHDI handler.
Index: xhdi.c
===================================================================
RCS file: /mint/freemint/sys/xhdi.c,v
retrieving revision 1.13
diff -u -8 -r1.13 xhdi.c
--- xhdi.c	13 Jan 2010 17:13:49 -0000	1.13
+++ xhdi.c	1 Feb 2014 17:34:22 -0000
@@ -47,17 +47,17 @@
 
 # include "arch/xhdi_emu.h"	/* xhdi_emu */
 # include "mint/proc.h"
 
 # include "cookie.h"		/* cookie handling */
 # include "info.h"		/* messages */
 # include "init.h"		/* boot_printf */
 # include "k_prot.h"		/* suser */
-
+# include "block_IO.h"		/* bio_sync_all */
 # include "proc.h"
 
 
 /*
  * internal usage
  */
 
 /* dummy routine */
@@ -208,16 +208,23 @@
 sys_xhdi (ushort op,
 		long a1, long a2, long a3, long a4,
 		long a5, long a6, long a7)
 {
 	/* version information */
 	if (op == 0)
 		return XHDI_installed;
 	
+	/* XHEject */
+	/* a2 contains do_eject parameter */
+	if (op == 5 && (a2 >> 16) == 1)
+	{
+		bio_sync_all ();
+	}
+
 	/* XHDrvMap */
 	if (op == 6)
 		return XHDI (6);
 	
 	/* all other functions are restricted to root processes */
 	if (!suser (get_curproc()->p_cred->ucr))
 		return EPERM;