2010-08-02 13:44:45 +02:00
|
|
|
/* Created (MFS based):
|
|
|
|
* February 2010 (Evgeniy Ivanov)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include "inode.h"
|
|
|
|
#include "super.h"
|
2014-08-24 12:12:30 +02:00
|
|
|
#include <assert.h>
|
2010-08-02 13:44:45 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_sync *
|
|
|
|
*===========================================================================*/
|
2014-08-24 12:12:30 +02:00
|
|
|
void fs_sync(void)
|
2010-08-02 13:44:45 +02:00
|
|
|
{
|
|
|
|
/* Perform the sync() system call. Flush all the tables.
|
|
|
|
* The order in which the various tables are flushed is critical. The
|
|
|
|
* blocks must be flushed last, since rw_inode() leaves its results in
|
|
|
|
* the block cache.
|
|
|
|
*/
|
|
|
|
struct inode *rip;
|
|
|
|
|
|
|
|
if (superblock->s_rd_only)
|
2014-08-24 12:12:30 +02:00
|
|
|
return; /* nothing to sync */
|
2010-08-02 13:44:45 +02:00
|
|
|
|
|
|
|
/* Write all the dirty inodes to the disk. */
|
|
|
|
for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
|
2012-10-16 17:40:39 +02:00
|
|
|
if(rip->i_count > 0 && rip->i_dirt == IN_DIRTY) rw_inode(rip, WRITING);
|
2010-08-02 13:44:45 +02:00
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
lmfs_flushall();
|
2010-08-02 13:44:45 +02:00
|
|
|
|
|
|
|
if (superblock->s_dev != NO_DEV) {
|
2014-08-24 12:00:06 +02:00
|
|
|
superblock->s_wtime = clock_time(NULL);
|
2010-08-02 13:44:45 +02:00
|
|
|
write_super(superblock);
|
|
|
|
}
|
2011-11-09 14:29:12 +01:00
|
|
|
}
|