1 /* Created (MFS based):
2 * February 2010 (Evgeniy Ivanov)
7 #include <minix/vfsif.h>
8 #include <minix/bdev.h>
12 /*===========================================================================*
14 *===========================================================================*/
17 /* Perform the sync() system call. Flush all the tables.
18 * The order in which the various tables are flushed is critical. The
19 * blocks must be flushed last, since rw_inode() leaves its results in
28 if (superblock
->s_rd_only
)
29 return(OK
); /* nothing to sync */
31 /* Write all the dirty inodes to the disk. */
32 for(rip
= &inode
[0]; rip
< &inode
[NR_INODES
]; rip
++)
33 if(rip
->i_count
> 0 && rip
->i_dirt
== DIRTY
) rw_inode(rip
, WRITING
);
35 /* Write all the dirty blocks to the disk, one drive at a time. */
36 for(bp
= &buf
[0]; bp
< &buf
[nr_bufs
]; bp
++)
37 if(bp
->b_dev
!= NO_DEV
&& bp
->b_dirt
== DIRTY
)
40 if (superblock
->s_dev
!= NO_DEV
) {
41 superblock
->s_wtime
= clock_time();
42 write_super(superblock
);
45 return(OK
); /* sync() can't fail */
49 /*===========================================================================*
51 *===========================================================================*/
54 /* Flush the blocks of a device from the cache after writing any dirty blocks
57 dev_t dev
= (dev_t
) fs_m_in
.REQ_DEV
;
59 if(dev
== fs_dev
) return(EBUSY
);
67 /*===========================================================================*
69 *===========================================================================*/
70 int fs_new_driver(void)
72 /* Set a new driver endpoint for this device. */
74 cp_grant_id_t label_gid
;
76 char label
[sizeof(fs_dev_label
)];
79 dev
= (dev_t
) fs_m_in
.REQ_DEV
;
80 label_gid
= (cp_grant_id_t
) fs_m_in
.REQ_GRANT
;
81 label_len
= (size_t) fs_m_in
.REQ_PATH_LEN
;
83 if (label_len
> sizeof(label
))
86 r
= sys_safecopyfrom(fs_m_in
.m_source
, label_gid
, (vir_bytes
) 0,
87 (vir_bytes
) label
, label_len
);
90 printf("ext2: fs_new_driver safecopyfrom failed (%d)\n", r
);
94 bdev_driver(dev
, label
);