misc.c 747 B

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