3 #include <minix/vfsif.h>
4 #include <minix/bdev.h>
8 /*===========================================================================*
10 *===========================================================================*/
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
20 assert(lmfs_nr_bufs() > 0);
22 /* Write all the dirty inodes to the disk. */
23 for(rip
= &inode
[0]; rip
< &inode
[NR_INODES
]; rip
++)
24 if(rip
->i_count
> 0 && IN_ISDIRTY(rip
)) rw_inode(rip
, WRITING
);
26 /* Write all the dirty blocks to the disk. */
29 return(OK
); /* sync() can't fail */
33 /*===========================================================================*
35 *===========================================================================*/
38 /* Flush the blocks of a device from the cache after writing any dirty blocks
41 dev_t dev
= (dev_t
) fs_m_in
.REQ_DEV
;
42 if(dev
== fs_dev
) return(EBUSY
);
51 /*===========================================================================*
53 *===========================================================================*/
54 int fs_new_driver(void)
56 /* Set a new driver endpoint for this device. */
58 cp_grant_id_t label_gid
;
60 char label
[sizeof(fs_dev_label
)];
63 dev
= (dev_t
) fs_m_in
.REQ_DEV
;
64 label_gid
= (cp_grant_id_t
) fs_m_in
.REQ_GRANT
;
65 label_len
= (size_t) fs_m_in
.REQ_PATH_LEN
;
67 if (label_len
> sizeof(label
))
70 r
= sys_safecopyfrom(fs_m_in
.m_source
, label_gid
, (vir_bytes
) 0,
71 (vir_bytes
) label
, label_len
);
74 printf("MFS: fs_new_driver safecopyfrom failed (%d)\n", r
);
78 bdev_driver(dev
, label
);