xref: /minix/minix/fs/ext2/misc.c (revision 0a6a1f1d)
1 /* Created (MFS based):
2  *   February 2010 (Evgeniy Ivanov)
3  */
4 
5 #include "fs.h"
6 #include "inode.h"
7 #include "super.h"
8 #include <assert.h>
9 
10 /*===========================================================================*
11  *				fs_sync					     *
12  *===========================================================================*/
13 void fs_sync(void)
14 {
15 /* Perform the sync() system call.  Flush all the tables.
16  * The order in which the various tables are flushed is critical.  The
17  * blocks must be flushed last, since rw_inode() leaves its results in
18  * the block cache.
19  */
20   struct inode *rip;
21 
22   if (superblock->s_rd_only)
23 	return; /* nothing to sync */
24 
25   /* Write all the dirty inodes to the disk. */
26   for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
27 	if(rip->i_count > 0 && rip->i_dirt == IN_DIRTY) rw_inode(rip, WRITING);
28 
29   lmfs_flushall();
30 
31   if (superblock->s_dev != NO_DEV) {
32 	superblock->s_wtime = clock_time(NULL);
33 	write_super(superblock);
34   }
35 }
36