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

Re: Sync() and shutdown() system call



Hi again!

Here is a preliminary patch for minixfs pl10, and a short program, which
can be compiled as /usr/etc/halt or /usr/etc/reboot.

Here the patch:

diff -uw old/config.h ./config.h
--- old/config.h	Tue Nov  1 01:02:06 1994
+++ ./config.h	Mon Oct 31 23:46:56 1994
@@ -20,6 +20,11 @@
 #define NORMAL 		1	/* sync() on all but writes */
 #define ROBUST		2	/* sync() on everything ***slow*** */
 
+/* uk: define this to let syncing be done by MiNT's sysupdate daemon
+ *     through Sync() system call, set CACHE_MODE TURBO.
+ */
+#define SYSUPDATE
+
 #define SYNC_TIME	5	/* sync time is seconds */
 
 #define MAX_RWS		1024	/* Maximum sectors to read/write atomically */
diff -uw old/filesys.h ./filesys.h
--- old/filesys.h	Tue Nov  1 01:02:22 1994
+++ ./filesys.h	Tue Nov  1 01:13:36 1994
@@ -158,6 +158,7 @@
 #define FS_NOXBIT	0x04	/* if a file can be read, it can be executed */
 #define	FS_LONGPATH	0x08	/* file system understands "size" argument to
 				   "getname" */
+#define FS_DO_SYNC  0x20  /* file system has sync function */
 
 	long	(*root) P_((_wORD drv, fcookie *fc));
 	long	(*lookup) P_((fcookie *dir, char *name, fcookie *fc));
@@ -191,6 +192,7 @@
 	long	(*dskchng) P_((_wORD drv));
 	long	(*release) P_((fcookie *fc));
 	long	(*dupcookie) P_((fcookie *dest, fcookie *src));
+	void  (*sync) P_((void));
 } FILESYS;
 
 /*
diff -uw old/minixfs.c ./minixfs.c
--- old/minixfs.c	Sun Oct 30 22:51:18 1994
+++ ./minixfs.c	Mon Oct 31 23:48:34 1994
@@ -6,7 +6,11 @@
 
 FILESYS minix_filesys = {
 	(FILESYS *) 0,
+#ifdef SYSUPDATE
+	FS_CASESENSITIVE | FS_LONGPATH | FS_DO_SYNC,
+#else
 	FS_CASESENSITIVE | FS_LONGPATH,
+#endif
 	m_root, m_lookup, m_creat, m_getdev,
 	m_getxattr, m_chattr, m_chown,
 	m_chmode, m_mkdir,
@@ -17,7 +21,10 @@
 	m_wlabel, m_rlabel,
 	m_symlink, m_readlink,
 	m_hardlink, m_fscntl, m_dskchng,
-	m_release,m_dupcookie
+	m_release,m_dupcookie,
+#ifdef SYSUPDATE
+	l_sync
+#endif
 };
 
 extern DEVDRV minix_dev;



Here is the program:

/* file:  reboot.c
 *        shut down the system
 *
 * If REBOOT is defined, restart the system after shutdown, otherwise
 * just halt the system so that it can be switched off securely.
 *
 * Ulrich Kuehn, 02-Nov-94
 */

#include <mintbind.h>
#include <stdio.h>


#ifndef Shutdown
#ifdef __GNUC__  /* temorary hack for gnu c */
#define Shutdown(a)  (long) trap_1_wl((short)0x151, (long)(a))
#endif
#endif


int
main()
{
#ifdef REBOOT
	long v = 1;
#else
	long v = 0;
#endif

	if (!Shutdown(v))
		printf("Cannot shut down the system.\n");
	return 1;
}


Ciao,
Ulrich

--
+---------------+----------------------------+-----------------------+
| Ulrich Kuehn  | Internet:                  | Life is uncertain --  |
| Cand.Math.Inf | kuehn@math.uni-muenster.de | eat the dessert first |
+---------------+----------------------------+-----------------------+