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 assert(lmfs_nr_bufs() > 0); 19 20 /* Write all the dirty inodes to the disk. */ 21 for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++) 22 if(rip->i_count > 0 && IN_ISDIRTY(rip)) rw_inode(rip, WRITING); 23 24 /* Write all the dirty blocks to the disk. */ 25 lmfs_flushall(); 26 } 27