xref: /minix/minix/fs/mfs/misc.c (revision 0a6a1f1d)
1 #include "fs.h"
2 #include "inode.h"
3 #include "clean.h"
4 #include <assert.h>
5 
6 /*===========================================================================*
7  *				fs_sync					     *
8  *===========================================================================*/
9 void fs_sync(void)
10 {
11 /* Perform the sync() system call.  Flush all the tables.
12  * The order in which the various tables are flushed is critical.  The
13  * blocks must be flushed last, since rw_inode() leaves its results in
14  * the block cache.
15  */
16   struct inode *rip;
17 
18   /* Write all the dirty inodes to the disk. */
19   for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
20 	  if(rip->i_count > 0 && IN_ISDIRTY(rip)) rw_inode(rip, WRITING);
21 
22   /* Write all the dirty blocks to the disk. */
23   lmfs_flushall();
24 }
25