2006-10-25 15:40:36 +02:00
|
|
|
#include "fs.h"
|
2010-05-05 13:35:04 +02:00
|
|
|
#include <assert.h>
|
2006-11-27 15:21:43 +01:00
|
|
|
#include <minix/vfsif.h>
|
2011-11-09 14:29:12 +01:00
|
|
|
#include <minix/bdev.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "inode.h"
|
2011-12-22 01:29:27 +01:00
|
|
|
#include "clean.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_sync *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_sync()
|
2006-10-25 15:40:36 +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.
|
|
|
|
*/
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
struct inode *rip;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
assert(lmfs_nr_bufs() > 0);
|
2010-05-05 13:35:04 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Write all the dirty inodes to the disk. */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
|
2011-12-22 01:29:27 +01:00
|
|
|
if(rip->i_count > 0 && IN_ISDIRTY(rip)) rw_inode(rip, WRITING);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
/* Write all the dirty blocks to the disk. */
|
|
|
|
lmfs_flushall();
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
return(OK); /* sync() can't fail */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-27 15:21:43 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* fs_flush *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_flush()
|
2006-11-27 15:21:43 +01:00
|
|
|
{
|
|
|
|
/* Flush the blocks of a device from the cache after writing any dirty blocks
|
|
|
|
* to disk.
|
|
|
|
*/
|
2014-04-29 16:15:37 +02:00
|
|
|
dev_t dev = fs_m_in.m_vfs_fs_flush.device;
|
2014-02-28 16:26:13 +01:00
|
|
|
if(dev == fs_dev && lmfs_bufs_in_use() > 0) return(EBUSY);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
lmfs_flushall();
|
|
|
|
lmfs_invalidate(dev);
|
2011-11-09 14:29:12 +01:00
|
|
|
|
2006-11-27 15:21:43 +01:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
2011-11-09 14:29:12 +01:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_new_driver *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_new_driver(void)
|
2011-11-09 14:29:12 +01:00
|
|
|
{
|
|
|
|
/* Set a new driver endpoint for this device. */
|
|
|
|
dev_t dev;
|
2011-11-30 19:05:26 +01:00
|
|
|
cp_grant_id_t label_gid;
|
|
|
|
size_t label_len;
|
|
|
|
char label[sizeof(fs_dev_label)];
|
|
|
|
int r;
|
2011-11-09 14:29:12 +01:00
|
|
|
|
2014-04-29 21:13:28 +02:00
|
|
|
dev = fs_m_in.m_vfs_fs_new_driver.device;
|
|
|
|
label_gid = fs_m_in.m_vfs_fs_new_driver.grant;
|
|
|
|
label_len = fs_m_in.m_vfs_fs_new_driver.path_len;
|
2011-11-09 14:29:12 +01:00
|
|
|
|
2011-11-30 19:05:26 +01:00
|
|
|
if (label_len > sizeof(label))
|
|
|
|
return(EINVAL);
|
|
|
|
|
|
|
|
r = sys_safecopyfrom(fs_m_in.m_source, label_gid, (vir_bytes) 0,
|
2012-06-16 03:46:15 +02:00
|
|
|
(vir_bytes) label, label_len);
|
2011-11-30 19:05:26 +01:00
|
|
|
|
|
|
|
if (r != OK) {
|
|
|
|
printf("MFS: fs_new_driver safecopyfrom failed (%d)\n", r);
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bdev_driver(dev, label);
|
2011-11-09 14:29:12 +01:00
|
|
|
|
|
|
|
return(OK);
|
|
|
|
}
|
2013-03-16 05:09:36 +01:00
|
|
|
|
|
|
|
int fs_bpeek(void)
|
|
|
|
{
|
|
|
|
return lmfs_do_bpeek(&fs_m_in);
|
|
|
|
}
|