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