. service tells you which device it couldn't stat
[minix3.git] / servers / mfs / misc.c
blob4f447366dc5a7dcc3e5298e990bccb7b273522ab
2 #include "fs.h"
3 #include <fcntl.h>
4 #include <minix/vfsif.h>
6 #include "buf.h"
7 #include "inode.h"
10 /*===========================================================================*
11 * fs_sync *
12 *===========================================================================*/
13 PUBLIC int fs_sync()
15 /* Perform the sync() system call. Flush all the tables.
16 * The order in which the various tables are flushed is critical. The
17 * blocks must be flushed last, since rw_inode() leaves its results in
18 * the block cache.
20 register struct inode *rip;
21 register struct buf *bp;
23 /* Write all the dirty inodes to the disk. */
24 for (rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
25 if (rip->i_count > 0 && rip->i_dirt == DIRTY) rw_inode(rip, WRITING);
27 /* Write all the dirty blocks to the disk, one drive at a time. */
28 for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++)
29 if (bp->b_dev != NO_DEV && bp->b_dirt == DIRTY)
30 flushall(bp->b_dev);
32 return(OK); /* sync() can't fail */
36 /*===========================================================================*
37 * fs_flush *
38 *===========================================================================*/
39 PUBLIC int fs_flush()
41 /* Flush the blocks of a device from the cache after writing any dirty blocks
42 * to disk.
44 dev_t dev;
46 dev= fs_m_in.REQ_DEV;
47 if (dev == fs_dev)
49 return EBUSY;
51 flushall(dev);
52 invalidate(dev);
54 return(OK);