xref: /minix3/minix/fs/mfs/misc.c (revision 9866ad31fd560d01cf4e2a1c4ceaf27050cda8f6)
1433d6423SLionel Sambuc #include "fs.h"
2433d6423SLionel Sambuc #include "inode.h"
3433d6423SLionel Sambuc #include "clean.h"
4433d6423SLionel Sambuc 
5433d6423SLionel Sambuc /*===========================================================================*
6433d6423SLionel Sambuc  *				fs_sync					     *
7433d6423SLionel Sambuc  *===========================================================================*/
fs_sync(void)8*ccaeedb2SDavid van Moolenbroek void fs_sync(void)
9433d6423SLionel Sambuc {
10433d6423SLionel Sambuc /* Perform the sync() system call.  Flush all the tables.
11433d6423SLionel Sambuc  * The order in which the various tables are flushed is critical.  The
12433d6423SLionel Sambuc  * blocks must be flushed last, since rw_inode() leaves its results in
13433d6423SLionel Sambuc  * the block cache.
14433d6423SLionel Sambuc  */
15433d6423SLionel Sambuc   struct inode *rip;
16433d6423SLionel Sambuc 
17433d6423SLionel Sambuc   /* Write all the dirty inodes to the disk. */
18433d6423SLionel Sambuc   for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
19433d6423SLionel Sambuc 	  if(rip->i_count > 0 && IN_ISDIRTY(rip)) rw_inode(rip, WRITING);
20433d6423SLionel Sambuc 
21433d6423SLionel Sambuc   /* Write all the dirty blocks to the disk. */
22433d6423SLionel Sambuc   lmfs_flushall();
23433d6423SLionel Sambuc }
24