forget difference between big and small commands - obsolete with vm.
[minix.git] / servers / mfs / misc.c
blobf94d8dbbaad6c5c5580328af425fb352b59e1f8e
1 #include "fs.h"
2 #include <fcntl.h>
3 #include <minix/vfsif.h>
4 #include "buf.h"
5 #include "inode.h"
8 /*===========================================================================*
9 * fs_sync *
10 *===========================================================================*/
11 PUBLIC int fs_sync()
13 /* Perform the sync() system call. Flush all the tables.
14 * The order in which the various tables are flushed is critical. The
15 * blocks must be flushed last, since rw_inode() leaves its results in
16 * the block cache.
18 struct inode *rip;
19 struct buf *bp;
21 /* Write all the dirty inodes to the disk. */
22 for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
23 if(rip->i_count > 0 && rip->i_dirt == DIRTY) rw_inode(rip, WRITING);
25 /* Write all the dirty blocks to the disk, one drive at a time. */
26 for(bp = &buf[0]; bp < &buf[NR_BUFS]; bp++)
27 if(bp->b_dev != NO_DEV && bp->b_dirt == DIRTY)
28 flushall(bp->b_dev);
30 return(OK); /* sync() can't fail */
34 /*===========================================================================*
35 * fs_flush *
36 *===========================================================================*/
37 PUBLIC int fs_flush()
39 /* Flush the blocks of a device from the cache after writing any dirty blocks
40 * to disk.
42 dev_t dev;
44 dev = fs_m_in.REQ_DEV;
45 if(dev == fs_dev) return(EBUSY);
47 flushall(dev);
48 invalidate(dev);
50 return(OK);