58b8ff5ffa
This fcntl requests all cached blocks associated with the minor device number associated with the regular file are invalidated. If the file is a block special, invalidate the blocks associated with that minor device instead. This is to be used for a test that tests unmapped file-mapped memory ranges whose blocks are not in the cache and therefore must be fetched from a FS. Change-Id: Ide914b2e88413aa90bd731ae587ca06fa5f13ebc
86 lines
2.1 KiB
C
86 lines
2.1 KiB
C
#include "fs.h"
|
|
#include <assert.h>
|
|
#include <minix/vfsif.h>
|
|
#include <minix/bdev.h>
|
|
#include "inode.h"
|
|
#include "clean.h"
|
|
|
|
/*===========================================================================*
|
|
* fs_sync *
|
|
*===========================================================================*/
|
|
int fs_sync()
|
|
{
|
|
/* 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;
|
|
|
|
assert(lmfs_nr_bufs() > 0);
|
|
|
|
/* Write all the dirty inodes to the disk. */
|
|
for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
|
|
if(rip->i_count > 0 && IN_ISDIRTY(rip)) rw_inode(rip, WRITING);
|
|
|
|
/* Write all the dirty blocks to the disk. */
|
|
lmfs_flushall();
|
|
|
|
return(OK); /* sync() can't fail */
|
|
}
|
|
|
|
|
|
/*===========================================================================*
|
|
* fs_flush *
|
|
*===========================================================================*/
|
|
int fs_flush()
|
|
{
|
|
/* Flush the blocks of a device from the cache after writing any dirty blocks
|
|
* to disk.
|
|
*/
|
|
dev_t dev = fs_m_in.REQ_DEV;
|
|
if(dev == fs_dev && lmfs_bufs_in_use() > 0) return(EBUSY);
|
|
|
|
lmfs_flushall();
|
|
lmfs_invalidate(dev);
|
|
|
|
return(OK);
|
|
}
|
|
|
|
|
|
/*===========================================================================*
|
|
* fs_new_driver *
|
|
*===========================================================================*/
|
|
int fs_new_driver(void)
|
|
{
|
|
/* Set a new driver endpoint for this device. */
|
|
dev_t dev;
|
|
cp_grant_id_t label_gid;
|
|
size_t label_len;
|
|
char label[sizeof(fs_dev_label)];
|
|
int r;
|
|
|
|
dev = fs_m_in.REQ_DEV;
|
|
label_gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
|
label_len = (size_t) fs_m_in.REQ_PATH_LEN;
|
|
|
|
if (label_len > sizeof(label))
|
|
return(EINVAL);
|
|
|
|
r = sys_safecopyfrom(fs_m_in.m_source, label_gid, (vir_bytes) 0,
|
|
(vir_bytes) label, label_len);
|
|
|
|
if (r != OK) {
|
|
printf("MFS: fs_new_driver safecopyfrom failed (%d)\n", r);
|
|
return(EINVAL);
|
|
}
|
|
|
|
bdev_driver(dev, label);
|
|
|
|
return(OK);
|
|
}
|
|
|
|
int fs_bpeek(void)
|
|
{
|
|
return lmfs_do_bpeek(&fs_m_in);
|
|
}
|