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
24 assert(lmfs_nr_bufs() > 0);
26 if (superblock
->s_rd_only
)
27 return(OK
); /* nothing to sync */
29 /* Write all the dirty inodes to the disk. */
30 for(rip
= &inode
[0]; rip
< &inode
[NR_INODES
]; rip
++)
31 if(rip
->i_count
> 0 && rip
->i_dirt
== IN_DIRTY
) rw_inode(rip
, WRITING
);
35 if (superblock
->s_dev
!= NO_DEV
) {
36 superblock
->s_wtime
= clock_time();
37 write_super(superblock
);
40 return(OK
); /* sync() can't fail */
44 /*===========================================================================*
46 *===========================================================================*/
49 /* Flush the blocks of a device from the cache after writing any dirty blocks
52 dev_t dev
= (dev_t
) fs_m_in
.REQ_DEV
;
54 if(dev
== fs_dev
) return(EBUSY
);
62 /*===========================================================================*
64 *===========================================================================*/
65 int fs_new_driver(void)
67 /* Set a new driver endpoint for this device. */
69 cp_grant_id_t label_gid
;
71 char label
[sizeof(fs_dev_label
)];
74 dev
= (dev_t
) fs_m_in
.REQ_DEV
;
75 label_gid
= (cp_grant_id_t
) fs_m_in
.REQ_GRANT
;
76 label_len
= (size_t) fs_m_in
.REQ_PATH_LEN
;
78 if (label_len
> sizeof(label
))
81 r
= sys_safecopyfrom(fs_m_in
.m_source
, label_gid
, (vir_bytes
) 0,
82 (vir_bytes
) label
, label_len
);
85 printf("ext2: fs_new_driver safecopyfrom failed (%d)\n", r
);
89 bdev_driver(dev
, label
);