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;
|
|
|
|
struct buf *bp;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-05-05 13:35:04 +02:00
|
|
|
assert(nr_bufs > 0);
|
|
|
|
assert(buf);
|
|
|
|
|
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
|
|
|
|
|
|
|
/* Write all the dirty blocks to the disk, one drive at a time. */
|
2010-05-05 13:35:04 +02:00
|
|
|
for(bp = &buf[0]; bp < &buf[nr_bufs]; bp++)
|
2011-12-22 01:29:27 +01:00
|
|
|
if(bp->b_dev != NO_DEV && ISDIRTY(bp))
|
- 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
|
|
|
flushall(bp->b_dev);
|
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.
|
|
|
|
*/
|
2010-06-01 14:35:33 +02:00
|
|
|
dev_t dev = (dev_t) fs_m_in.REQ_DEV;
|
- 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
|
|
|
if(dev == fs_dev) return(EBUSY);
|
|
|
|
|
2006-11-27 15:21:43 +01:00
|
|
|
flushall(dev);
|
|
|
|
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
|
|
|
|
|
|
|
dev = (dev_t) fs_m_in.REQ_DEV;
|
2011-11-30 19:05:26 +01:00
|
|
|
label_gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
|
|
|
label_len = (size_t) fs_m_in.REQ_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);
|
|
|
|
}
|