2005-04-21 16:53:53 +02:00
|
|
|
#include "fs.h"
|
2006-11-09 17:22:54 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
2010-05-05 13:35:04 +02:00
|
|
|
#include <stdlib.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/com.h>
|
2006-11-27 15:21:43 +01:00
|
|
|
#include <minix/u64.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "buf.h"
|
|
|
|
#include "inode.h"
|
|
|
|
#include "super.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <minix/vfsif.h>
|
2013-03-16 03:29:32 +01:00
|
|
|
#include <sys/param.h>
|
2010-06-01 14:35:33 +02:00
|
|
|
#include <assert.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-06-01 14:35:33 +02:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static struct buf *rahead(struct inode *rip, block_t baseblock, u64_t
|
2012-03-24 16:16:34 +01:00
|
|
|
position, unsigned bytes_ahead);
|
2012-03-25 20:25:53 +02:00
|
|
|
static int rw_chunk(struct inode *rip, u64_t position, unsigned off,
|
2012-03-24 16:16:34 +01:00
|
|
|
size_t chunk, unsigned left, int rw_flag, cp_grant_id_t gid, unsigned
|
|
|
|
buf_off, unsigned int block_size, int *completed);
|
2005-05-24 14:28:09 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
- 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
|
|
|
* fs_readwrite *
|
2005-04-21 16:53:53 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_readwrite(void)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2010-06-01 14:35:33 +02:00
|
|
|
int r, rw_flag, block_spec;
|
|
|
|
int regular;
|
- 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
|
|
|
cp_grant_id_t gid;
|
2006-10-25 15:40:36 +02:00
|
|
|
off_t position, f_size, bytes_left;
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned int off, cum_io, block_size, chunk;
|
2005-04-21 16:53:53 +02:00
|
|
|
mode_t mode_word;
|
2010-06-01 14:35:33 +02:00
|
|
|
int completed;
|
2006-10-25 15:40:36 +02:00
|
|
|
struct inode *rip;
|
2010-06-01 14:35:33 +02:00
|
|
|
size_t nrbytes;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
r = OK;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
- 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
|
|
|
/* Find the inode referred */
|
2010-06-01 14:35:33 +02:00
|
|
|
if ((rip = find_inode(fs_dev, (ino_t) fs_m_in.REQ_INODE_NR)) == NULL)
|
- 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
|
|
|
return(EINVAL);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
mode_word = rip->i_mode & I_TYPE;
|
|
|
|
regular = (mode_word == I_REGULAR || mode_word == I_NAMED_PIPE);
|
|
|
|
block_spec = (mode_word == I_BLOCK_SPECIAL ? 1 : 0);
|
|
|
|
|
|
|
|
/* Determine blocksize */
|
2010-06-01 14:35:33 +02:00
|
|
|
if (block_spec) {
|
|
|
|
block_size = get_block_size( (dev_t) rip->i_zone[0]);
|
|
|
|
f_size = MAX_FILE_POS;
|
|
|
|
} else {
|
|
|
|
block_size = rip->i_sp->s_block_size;
|
|
|
|
f_size = rip->i_size;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* Get the values from the request message */
|
2013-01-13 22:44:38 +01:00
|
|
|
switch(fs_m_in.m_type) {
|
|
|
|
case REQ_READ: rw_flag = READING; break;
|
|
|
|
case REQ_WRITE: rw_flag = WRITING; break;
|
|
|
|
case REQ_PEEK: rw_flag = PEEKING; break;
|
|
|
|
default: panic("odd request");
|
|
|
|
}
|
2010-06-01 14:35:33 +02:00
|
|
|
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
|
|
|
position = (off_t) fs_m_in.REQ_SEEK_POS_LO;
|
|
|
|
nrbytes = (size_t) fs_m_in.REQ_NBYTES;
|
2013-03-16 03:29:32 +01:00
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
lmfs_reset_rdwt_err();
|
2010-06-21 20:25:04 +02:00
|
|
|
|
2011-12-22 01:29:27 +01:00
|
|
|
/* If this is file i/o, check we can write */
|
2010-06-01 14:35:33 +02:00
|
|
|
if (rw_flag == WRITING && !block_spec) {
|
2011-12-22 01:29:27 +01:00
|
|
|
if(rip->i_sp->s_rd_only)
|
|
|
|
return EROFS;
|
|
|
|
|
- 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
|
|
|
/* Check in advance to see if file will grow too big. */
|
2010-06-01 14:35:33 +02:00
|
|
|
if (position > (off_t) (rip->i_sp->s_max_size - nrbytes))
|
- 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
|
|
|
return(EFBIG);
|
|
|
|
|
|
|
|
/* Clear the zone containing present EOF if hole about
|
|
|
|
* to be created. This is necessary because all unwritten
|
2010-06-01 14:35:33 +02:00
|
|
|
* blocks prior to the EOF must read as zeros.
|
|
|
|
*/
|
- 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(position > f_size) clear_zone(rip, f_size, 0);
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
2011-12-22 01:29:27 +01:00
|
|
|
|
|
|
|
/* If this is block i/o, check we can write */
|
|
|
|
if(block_spec && rw_flag == WRITING &&
|
|
|
|
(dev_t) rip->i_zone[0] == superblock.s_dev && superblock.s_rd_only)
|
|
|
|
return EROFS;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
cum_io = 0;
|
|
|
|
/* Split the transfer into chunks that don't span two blocks. */
|
2010-06-01 14:35:33 +02:00
|
|
|
while (nrbytes > 0) {
|
|
|
|
off = ((unsigned int) position) % block_size; /* offset in blk*/
|
|
|
|
chunk = min(nrbytes, block_size - off);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
- 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 (rw_flag == READING) {
|
|
|
|
bytes_left = f_size - position;
|
|
|
|
if (position >= f_size) break; /* we are beyond EOF */
|
2010-06-01 14:35:33 +02:00
|
|
|
if (chunk > (unsigned int) bytes_left) chunk = bytes_left;
|
- 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
|
|
|
}
|
|
|
|
|
|
|
|
/* Read or write 'chunk' bytes. */
|
2013-06-17 10:31:12 +02:00
|
|
|
r = rw_chunk(rip, ((u64_t)((unsigned long)position)), off, chunk,
|
2010-06-01 14:35:33 +02:00
|
|
|
nrbytes, rw_flag, gid, cum_io, block_size, &completed);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
- 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 (r != OK) break; /* EOF reached */
|
2012-10-16 17:40:39 +02:00
|
|
|
if (lmfs_rdwt_err() < 0) break;
|
2005-05-24 14:28:09 +02:00
|
|
|
|
- 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
|
|
|
/* Update counters and pointers. */
|
|
|
|
nrbytes -= chunk; /* bytes yet to be read */
|
|
|
|
cum_io += chunk; /* bytes read so far */
|
2010-06-01 14:35:33 +02:00
|
|
|
position += (off_t) chunk; /* position within the file */
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-08-07 14:38:35 +02:00
|
|
|
|
- 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
|
|
|
fs_m_out.RES_SEEK_POS_LO = position; /* It might change later and the VFS
|
|
|
|
has to know this value */
|
2007-08-07 14:38:35 +02:00
|
|
|
|
|
|
|
/* On write, update file size and access time. */
|
|
|
|
if (rw_flag == WRITING) {
|
- 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 (regular || mode_word == I_DIRECTORY) {
|
|
|
|
if (position > f_size) rip->i_size = position;
|
|
|
|
}
|
2007-08-07 14:38:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rip->i_seek = NO_SEEK;
|
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
if (lmfs_rdwt_err() != OK) r = lmfs_rdwt_err(); /* check for disk error */
|
|
|
|
if (lmfs_rdwt_err() == END_OF_FILE) r = OK;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
2011-12-22 01:29:27 +01:00
|
|
|
/* even on a ROFS, writing to a device node on it is fine,
|
|
|
|
* just don't update the inode stats for it. And dito for reading.
|
|
|
|
*/
|
|
|
|
if (r == OK && !rip->i_sp->s_rd_only) {
|
- 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 (rw_flag == READING) rip->i_update |= ATIME;
|
|
|
|
if (rw_flag == WRITING) rip->i_update |= CTIME | MTIME;
|
2011-12-22 01:29:27 +01:00
|
|
|
IN_MARKDIRTY(rip); /* inode is thus now dirty */
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
- 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
|
|
|
fs_m_out.RES_NBYTES = cum_io;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-05-24 14:28:09 +02:00
|
|
|
return(r);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2007-08-07 14:38:35 +02:00
|
|
|
/*===========================================================================*
|
- 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
|
|
|
* fs_breadwrite *
|
2007-08-07 14:38:35 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_breadwrite(void)
|
2007-08-07 14:38:35 +02:00
|
|
|
{
|
2010-06-01 14:35:33 +02:00
|
|
|
int r, rw_flag, completed;
|
2007-08-07 14:38:35 +02:00
|
|
|
cp_grant_id_t gid;
|
|
|
|
u64_t position;
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned int off, cum_io, chunk, block_size;
|
|
|
|
size_t nrbytes;
|
2011-12-22 01:29:27 +01:00
|
|
|
dev_t target_dev;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
|
|
|
/* Pseudo inode for rw_chunk */
|
|
|
|
struct inode rip;
|
|
|
|
|
|
|
|
r = OK;
|
2011-12-22 01:29:27 +01:00
|
|
|
|
|
|
|
target_dev = (dev_t) fs_m_in.REQ_DEV2;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
|
|
|
/* Get the values from the request message */
|
- 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
|
|
|
rw_flag = (fs_m_in.m_type == REQ_BREAD ? READING : WRITING);
|
2010-06-01 14:35:33 +02:00
|
|
|
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
|
|
|
|
position = make64((unsigned long) fs_m_in.REQ_SEEK_POS_LO,
|
|
|
|
(unsigned long) fs_m_in.REQ_SEEK_POS_HI);
|
|
|
|
nrbytes = (size_t) fs_m_in.REQ_NBYTES;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
2011-12-22 01:29:27 +01:00
|
|
|
block_size = get_block_size(target_dev);
|
|
|
|
|
|
|
|
/* Don't block-write to a RO-mounted filesystem. */
|
|
|
|
if(superblock.s_dev == target_dev && superblock.s_rd_only)
|
|
|
|
return EROFS;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
2011-12-22 01:29:27 +01:00
|
|
|
rip.i_zone[0] = (zone_t) target_dev;
|
2007-08-07 14:38:35 +02:00
|
|
|
rip.i_mode = I_BLOCK_SPECIAL;
|
|
|
|
rip.i_size = 0;
|
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
lmfs_reset_rdwt_err();
|
2007-08-07 14:38:35 +02:00
|
|
|
|
|
|
|
cum_io = 0;
|
|
|
|
/* Split the transfer into chunks that don't span two blocks. */
|
2010-06-01 14:35:33 +02:00
|
|
|
while (nrbytes > 0) {
|
- 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
|
|
|
off = rem64u(position, block_size); /* offset in blk*/
|
2010-06-01 14:35:33 +02:00
|
|
|
chunk = min(nrbytes, block_size - off);
|
2007-08-07 14:38:35 +02:00
|
|
|
|
- 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
|
|
|
/* Read or write 'chunk' bytes. */
|
2010-06-01 14:35:33 +02:00
|
|
|
r = rw_chunk(&rip, position, off, chunk, nrbytes, rw_flag, gid,
|
|
|
|
cum_io, block_size, &completed);
|
2007-08-07 14:38:35 +02:00
|
|
|
|
- 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 (r != OK) break; /* EOF reached */
|
2012-10-16 17:40:39 +02:00
|
|
|
if (lmfs_rdwt_err() < 0) break;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
- 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
|
|
|
/* Update counters and pointers. */
|
|
|
|
nrbytes -= chunk; /* bytes yet to be read */
|
|
|
|
cum_io += chunk; /* bytes read so far */
|
2010-06-01 14:35:33 +02:00
|
|
|
position = add64ul(position, chunk); /* position within the file */
|
2007-08-07 14:38:35 +02:00
|
|
|
}
|
|
|
|
|
- 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
|
|
|
fs_m_out.RES_SEEK_POS_LO = ex64lo(position);
|
|
|
|
fs_m_out.RES_SEEK_POS_HI = ex64hi(position);
|
2007-08-07 14:38:35 +02:00
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
if (lmfs_rdwt_err() != OK) r = lmfs_rdwt_err(); /* check for disk error */
|
|
|
|
if (lmfs_rdwt_err() == END_OF_FILE) r = OK;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
- 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
|
|
|
fs_m_out.RES_NBYTES = cum_io;
|
2007-08-07 14:38:35 +02:00
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* rw_chunk *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int rw_chunk(rip, position, off, chunk, left, rw_flag, gid,
|
2007-08-07 14:38:35 +02:00
|
|
|
buf_off, block_size, completed)
|
|
|
|
register struct inode *rip; /* pointer to inode for file to be rd/wr */
|
|
|
|
u64_t position; /* position within file to read or write */
|
|
|
|
unsigned off; /* off within the current block */
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned int chunk; /* number of bytes to read or write */
|
2007-08-07 14:38:35 +02:00
|
|
|
unsigned left; /* max number of bytes wanted after position */
|
2013-01-13 22:44:38 +01:00
|
|
|
int rw_flag; /* READING, WRITING or PEEKING */
|
2007-08-07 14:38:35 +02:00
|
|
|
cp_grant_id_t gid; /* grant */
|
|
|
|
unsigned buf_off; /* offset in grant */
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned int block_size; /* block size of FS operating on */
|
2007-08-07 14:38:35 +02:00
|
|
|
int *completed; /* number of bytes copied */
|
|
|
|
{
|
|
|
|
/* Read or write (part of) a block. */
|
|
|
|
|
2013-01-13 22:44:38 +01:00
|
|
|
register struct buf *bp = NULL;
|
2007-08-07 14:38:35 +02:00
|
|
|
register int r = OK;
|
|
|
|
int n, block_spec;
|
|
|
|
block_t b;
|
|
|
|
dev_t dev;
|
2013-03-16 03:29:32 +01:00
|
|
|
ino_t ino = VMC_NO_INODE;
|
|
|
|
u64_t ino_off = rounddown(position, block_size);
|
2007-08-07 14:38:35 +02:00
|
|
|
|
2013-01-13 22:44:38 +01:00
|
|
|
/* rw_flag:
|
|
|
|
* READING: read from FS, copy to user
|
|
|
|
* WRITING: copy from user, write to FS
|
|
|
|
* PEEKING: try to get all the blocks into the cache, no copying
|
|
|
|
*/
|
|
|
|
|
2007-08-07 14:38:35 +02:00
|
|
|
*completed = 0;
|
|
|
|
|
|
|
|
block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL;
|
|
|
|
|
|
|
|
if (block_spec) {
|
|
|
|
b = div64u(position, block_size);
|
|
|
|
dev = (dev_t) rip->i_zone[0];
|
- 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
|
|
|
} else {
|
2007-08-07 14:38:35 +02:00
|
|
|
if (ex64hi(position) != 0)
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("rw_chunk: position too high");
|
2013-03-16 03:29:32 +01:00
|
|
|
b = read_map(rip, (off_t) ex64lo(position), 0);
|
2007-08-07 14:38:35 +02:00
|
|
|
dev = rip->i_dev;
|
2013-03-16 03:29:32 +01:00
|
|
|
ino = rip->i_num;
|
|
|
|
assert(ino != VMC_NO_INODE);
|
2007-08-07 14:38:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!block_spec && b == NO_BLOCK) {
|
|
|
|
if (rw_flag == READING) {
|
|
|
|
/* Reading from a nonexistent block. Must read as all zeros.*/
|
2012-11-12 19:15:10 +01:00
|
|
|
r = sys_safememset(VFS_PROC_NR, gid, (vir_bytes) buf_off,
|
|
|
|
0, (size_t) chunk);
|
|
|
|
if(r != OK) {
|
|
|
|
printf("MFS: sys_safememset failed\n");
|
|
|
|
}
|
|
|
|
return r;
|
- 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
|
|
|
} else {
|
2013-01-13 22:44:38 +01:00
|
|
|
/* Writing to or peeking a nonexistent block.
|
|
|
|
* Create and enter in inode.
|
|
|
|
*/
|
2010-06-01 14:35:33 +02:00
|
|
|
if ((bp = new_block(rip, (off_t) ex64lo(position))) == NULL)
|
2007-08-07 14:38:35 +02:00
|
|
|
return(err_code);
|
|
|
|
}
|
2013-01-13 22:44:38 +01:00
|
|
|
} else if (rw_flag == READING || rw_flag == PEEKING) {
|
2007-08-07 14:38:35 +02:00
|
|
|
/* Read and read ahead if convenient. */
|
|
|
|
bp = rahead(rip, b, position, left);
|
- 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
|
|
|
} else {
|
2007-08-07 14:38:35 +02:00
|
|
|
/* Normally an existing block to be partially overwritten is first read
|
|
|
|
* in. However, a full block need not be read in. If it is already in
|
|
|
|
* the cache, acquire it, otherwise just acquire a free buffer.
|
|
|
|
*/
|
|
|
|
n = (chunk == block_size ? NO_READ : NORMAL);
|
2010-06-01 14:35:33 +02:00
|
|
|
if (!block_spec && off == 0 && (off_t) ex64lo(position) >= rip->i_size)
|
2007-08-07 14:38:35 +02:00
|
|
|
n = NO_READ;
|
2013-03-16 03:29:32 +01:00
|
|
|
if(block_spec) {
|
|
|
|
assert(ino == VMC_NO_INODE);
|
|
|
|
bp = get_block(dev, b, n);
|
|
|
|
} else {
|
|
|
|
assert(ino != VMC_NO_INODE);
|
|
|
|
assert(!(ino_off % block_size));
|
|
|
|
bp = lmfs_get_block_ino(dev, b, n, ino, ino_off);
|
|
|
|
}
|
2007-08-07 14:38:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* In all cases, bp now points to a valid buffer. */
|
2013-01-13 22:44:38 +01:00
|
|
|
assert(bp);
|
2007-08-07 14:38:35 +02:00
|
|
|
|
|
|
|
if (rw_flag == WRITING && chunk != block_size && !block_spec &&
|
2010-06-01 14:35:33 +02:00
|
|
|
(off_t) ex64lo(position) >= rip->i_size && off == 0) {
|
2007-08-07 14:38:35 +02:00
|
|
|
zero_block(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rw_flag == READING) {
|
|
|
|
/* Copy a chunk from the block buffer to user space. */
|
2010-06-08 15:58:01 +02:00
|
|
|
r = sys_safecopyto(VFS_PROC_NR, gid, (vir_bytes) buf_off,
|
2012-10-16 17:40:39 +02:00
|
|
|
(vir_bytes) (b_data(bp)+off), (size_t) chunk);
|
2013-01-13 22:44:38 +01:00
|
|
|
} else if(rw_flag == WRITING) {
|
2007-08-07 14:38:35 +02:00
|
|
|
/* Copy a chunk from user space to the block buffer. */
|
2010-06-08 15:58:01 +02:00
|
|
|
r = sys_safecopyfrom(VFS_PROC_NR, gid, (vir_bytes) buf_off,
|
2012-10-16 17:40:39 +02:00
|
|
|
(vir_bytes) (b_data(bp)+off), (size_t) chunk);
|
2011-12-22 01:29:27 +01:00
|
|
|
MARKDIRTY(bp);
|
2007-08-07 14:38:35 +02:00
|
|
|
}
|
- 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
|
|
|
|
2007-08-07 14:38:35 +02:00
|
|
|
n = (off + chunk == block_size ? FULL_DATA_BLOCK : PARTIAL_DATA_BLOCK);
|
|
|
|
put_block(bp, n);
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* read_map *
|
|
|
|
*===========================================================================*/
|
2013-03-16 03:29:32 +01:00
|
|
|
block_t read_map(rip, position, opportunistic)
|
2005-04-21 16:53:53 +02:00
|
|
|
register struct inode *rip; /* ptr to inode to map from */
|
|
|
|
off_t position; /* position in file whose blk wanted */
|
2013-03-16 03:29:32 +01:00
|
|
|
int opportunistic; /* if nonzero, only use cache for metadata */
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Given an inode and a position within the corresponding file, locate the
|
|
|
|
* block (not zone) number in which that position is to be found and return it.
|
|
|
|
*/
|
|
|
|
|
2010-06-01 14:35:33 +02:00
|
|
|
struct buf *bp;
|
|
|
|
zone_t z;
|
2012-01-16 15:46:47 +01:00
|
|
|
int scale, boff, index, zind;
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned int dzones, nr_indirects;
|
2005-04-21 16:53:53 +02:00
|
|
|
block_t b;
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned long excess, zone, block_pos;
|
2013-03-16 03:29:32 +01:00
|
|
|
int iomode = NORMAL;
|
|
|
|
|
|
|
|
if(opportunistic) iomode = PREFETCH;
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
scale = rip->i_sp->s_log_zone_size; /* for block-zone conversion */
|
|
|
|
block_pos = position/rip->i_sp->s_block_size; /* relative blk # in file */
|
|
|
|
zone = block_pos >> scale; /* position's zone */
|
|
|
|
boff = (int) (block_pos - (zone << scale) ); /* relative blk # within zone */
|
|
|
|
dzones = rip->i_ndzones;
|
|
|
|
nr_indirects = rip->i_nindirs;
|
|
|
|
|
|
|
|
/* Is 'position' to be found in the inode itself? */
|
|
|
|
if (zone < dzones) {
|
|
|
|
zind = (int) zone; /* index should be an int */
|
|
|
|
z = rip->i_zone[zind];
|
|
|
|
if (z == NO_ZONE) return(NO_BLOCK);
|
2010-06-01 14:35:33 +02:00
|
|
|
b = (block_t) ((z << scale) + boff);
|
2005-04-21 16:53:53 +02:00
|
|
|
return(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* It is not in the inode, so it must be single or double indirect. */
|
|
|
|
excess = zone - dzones; /* first Vx_NR_DZONES don't count */
|
|
|
|
|
|
|
|
if (excess < nr_indirects) {
|
|
|
|
/* 'position' can be located via the single indirect block. */
|
|
|
|
z = rip->i_zone[dzones];
|
|
|
|
} else {
|
|
|
|
/* 'position' can be located via the double indirect block. */
|
|
|
|
if ( (z = rip->i_zone[dzones+1]) == NO_ZONE) return(NO_BLOCK);
|
|
|
|
excess -= nr_indirects; /* single indir doesn't count*/
|
|
|
|
b = (block_t) z << scale;
|
2008-11-19 13:26:10 +01:00
|
|
|
ASSERT(rip->i_dev != NO_DEV);
|
2005-04-21 16:53:53 +02:00
|
|
|
index = (int) (excess/nr_indirects);
|
2012-01-16 15:46:47 +01:00
|
|
|
if ((unsigned int) index > rip->i_nindirs)
|
|
|
|
return(NO_BLOCK); /* Can't go beyond double indirects */
|
2013-03-16 03:29:32 +01:00
|
|
|
bp = get_block(rip->i_dev, b, iomode); /* get double indirect block */
|
|
|
|
if(opportunistic && lmfs_dev(bp) == NO_DEV) {
|
|
|
|
put_block(bp, INDIRECT_BLOCK);
|
|
|
|
return NO_BLOCK;
|
|
|
|
}
|
2012-10-16 17:40:39 +02:00
|
|
|
ASSERT(lmfs_dev(bp) != NO_DEV);
|
|
|
|
ASSERT(lmfs_dev(bp) == rip->i_dev);
|
2005-04-21 16:53:53 +02:00
|
|
|
z = rd_indir(bp, index); /* z= zone for single*/
|
|
|
|
put_block(bp, INDIRECT_BLOCK); /* release double ind block */
|
|
|
|
excess = excess % nr_indirects; /* index into single ind blk */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 'z' is zone num for single indirect block; 'excess' is index into it. */
|
|
|
|
if (z == NO_ZONE) return(NO_BLOCK);
|
|
|
|
b = (block_t) z << scale; /* b is blk # for single ind */
|
2013-03-16 03:29:32 +01:00
|
|
|
bp = get_block(rip->i_dev, b, iomode); /* get single indirect block */
|
|
|
|
if(opportunistic && lmfs_dev(bp) == NO_DEV) {
|
|
|
|
put_block(bp, INDIRECT_BLOCK);
|
|
|
|
return NO_BLOCK;
|
|
|
|
}
|
2012-01-16 15:46:47 +01:00
|
|
|
z = rd_indir(bp, (int) excess); /* get block pointed to */
|
2005-04-21 16:53:53 +02:00
|
|
|
put_block(bp, INDIRECT_BLOCK); /* release single indir blk */
|
|
|
|
if (z == NO_ZONE) return(NO_BLOCK);
|
2010-06-01 14:35:33 +02:00
|
|
|
b = (block_t) ((z << scale) + boff);
|
2005-04-21 16:53:53 +02:00
|
|
|
return(b);
|
|
|
|
}
|
|
|
|
|
2013-03-16 03:29:32 +01:00
|
|
|
struct buf *get_block_map(register struct inode *rip, u64_t position)
|
|
|
|
{
|
|
|
|
block_t b = read_map(rip, position, 0); /* get block number */
|
|
|
|
int block_size = get_block_size(rip->i_dev);
|
|
|
|
if(b == NO_BLOCK)
|
|
|
|
return NULL;
|
|
|
|
position = rounddown(position, block_size);
|
|
|
|
assert(rip->i_num != VMC_NO_INODE);
|
|
|
|
return lmfs_get_block_ino(rip->i_dev, b, NORMAL, rip->i_num, position);
|
|
|
|
}
|
- 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
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* rd_indir *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
zone_t rd_indir(bp, index)
|
2005-04-21 16:53:53 +02:00
|
|
|
struct buf *bp; /* pointer to indirect block */
|
|
|
|
int index; /* index into *bp */
|
|
|
|
{
|
|
|
|
/* Given a pointer to an indirect block, read one entry. The reason for
|
|
|
|
* making a separate routine out of this is that there are four cases:
|
|
|
|
* V1 (IBM and 68000), and V2 (IBM and 68000).
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct super_block *sp;
|
|
|
|
zone_t zone; /* V2 zones are longs (shorts in V1) */
|
|
|
|
|
2010-05-10 15:26:00 +02:00
|
|
|
if(bp == NULL)
|
|
|
|
panic("rd_indir() on NULL");
|
2006-01-11 18:14:51 +01:00
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
sp = get_super(lmfs_dev(bp)); /* need super block to find file sys type */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* read a zone from an indirect block */
|
|
|
|
if (sp->s_version == V1)
|
2012-10-16 17:40:39 +02:00
|
|
|
zone = (zone_t) conv2(sp->s_native, (int) b_v1_ind(bp)[index]);
|
2005-04-21 16:53:53 +02:00
|
|
|
else
|
2012-10-16 17:40:39 +02:00
|
|
|
zone = (zone_t) conv4(sp->s_native, (long) b_v2_ind(bp)[index]);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
if (zone != NO_ZONE &&
|
|
|
|
(zone < (zone_t) sp->s_firstdatazone || zone >= sp->s_zones)) {
|
|
|
|
printf("Illegal zone number %ld in indirect block, index %d\n",
|
|
|
|
(long) zone, index);
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("check file system");
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
- 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
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
return(zone);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* rahead *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static struct buf *rahead(rip, baseblock, position, bytes_ahead)
|
2005-04-21 16:53:53 +02:00
|
|
|
register struct inode *rip; /* pointer to inode for file to be read */
|
|
|
|
block_t baseblock; /* block at current position */
|
2006-11-27 15:21:43 +01:00
|
|
|
u64_t position; /* position within file */
|
2005-04-21 16:53:53 +02:00
|
|
|
unsigned bytes_ahead; /* bytes beyond position for immediate use */
|
|
|
|
{
|
|
|
|
/* Fetch a block from the cache or the device. If a physical read is
|
|
|
|
* required, prefetch as many more blocks as convenient into the cache.
|
|
|
|
* This usually covers bytes_ahead and is at least BLOCKS_MINIMUM.
|
|
|
|
* The device driver may decide it knows better and stop reading at a
|
|
|
|
* cylinder boundary (or after an error). Rw_scattered() puts an optional
|
|
|
|
* flag on all reads to allow this.
|
|
|
|
*/
|
|
|
|
/* Minimum number of blocks to prefetch. */
|
2012-10-16 17:40:39 +02:00
|
|
|
int nr_bufs = lmfs_nr_bufs();
|
2010-05-05 13:35:04 +02:00
|
|
|
# define BLOCKS_MINIMUM (nr_bufs < 50 ? 18 : 32)
|
2005-04-21 16:53:53 +02:00
|
|
|
int block_spec, scale, read_q_size;
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned int blocks_ahead, fragment, block_size;
|
2005-04-21 16:53:53 +02:00
|
|
|
block_t block, blocks_left;
|
|
|
|
off_t ind1_pos;
|
|
|
|
dev_t dev;
|
|
|
|
struct buf *bp;
|
2010-06-01 14:35:33 +02:00
|
|
|
static unsigned int readqsize = 0;
|
2008-11-19 13:26:10 +01:00
|
|
|
static struct buf **read_q;
|
2013-03-16 03:29:32 +01:00
|
|
|
u64_t position_running;
|
2008-11-19 13:26:10 +01:00
|
|
|
|
2010-05-05 13:35:04 +02:00
|
|
|
if(readqsize != nr_bufs) {
|
2010-06-01 14:35:33 +02:00
|
|
|
if(readqsize > 0) {
|
|
|
|
assert(read_q != NULL);
|
2010-05-05 13:35:04 +02:00
|
|
|
free(read_q);
|
2010-06-01 14:35:33 +02:00
|
|
|
}
|
2010-05-05 13:35:04 +02:00
|
|
|
if(!(read_q = malloc(sizeof(read_q[0])*nr_bufs)))
|
|
|
|
panic("couldn't allocate read_q");
|
|
|
|
readqsize = nr_bufs;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL;
|
- 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 (block_spec)
|
2005-04-21 16:53:53 +02:00
|
|
|
dev = (dev_t) rip->i_zone[0];
|
- 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
|
|
|
else
|
2005-04-21 16:53:53 +02:00
|
|
|
dev = rip->i_dev;
|
2013-03-16 03:29:32 +01:00
|
|
|
|
|
|
|
assert(dev != NO_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
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
block_size = get_block_size(dev);
|
|
|
|
|
|
|
|
block = baseblock;
|
2013-03-16 03:29:32 +01:00
|
|
|
|
|
|
|
fragment = position % block_size;
|
|
|
|
position -= fragment;
|
|
|
|
position_running = position;
|
|
|
|
bytes_ahead += fragment;
|
|
|
|
blocks_ahead = (bytes_ahead + block_size - 1) / block_size;
|
|
|
|
|
|
|
|
if(block_spec)
|
|
|
|
bp = get_block(dev, block, PREFETCH);
|
|
|
|
else
|
|
|
|
bp = lmfs_get_block_ino(dev, block, PREFETCH, rip->i_num, position);
|
|
|
|
|
2011-08-10 22:46:33 +02:00
|
|
|
assert(bp != NULL);
|
2012-10-16 17:40:39 +02:00
|
|
|
if (lmfs_dev(bp) != NO_DEV) return(bp);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* The best guess for the number of blocks to prefetch: A lot.
|
|
|
|
* It is impossible to tell what the device looks like, so we don't even
|
|
|
|
* try to guess the geometry, but leave it to the driver.
|
|
|
|
*
|
|
|
|
* The floppy driver can read a full track with no rotational delay, and it
|
|
|
|
* avoids reading partial tracks if it can, so handing it enough buffers to
|
|
|
|
* read two tracks is perfect. (Two, because some diskette types have
|
|
|
|
* an odd number of sectors per track, so a block may span tracks.)
|
|
|
|
*
|
|
|
|
* The disk drivers don't try to be smart. With todays disks it is
|
|
|
|
* impossible to tell what the real geometry looks like, so it is best to
|
|
|
|
* read as much as you can. With luck the caching on the drive allows
|
|
|
|
* for a little time to start the next read.
|
|
|
|
*
|
|
|
|
* The current solution below is a bit of a hack, it just reads blocks from
|
|
|
|
* the current file position hoping that more of the file can be found. A
|
|
|
|
* better solution must look at the already available zone pointers and
|
|
|
|
* indirect blocks (but don't call read_map!).
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (block_spec && rip->i_size == 0) {
|
2010-06-01 14:35:33 +02:00
|
|
|
blocks_left = (block_t) NR_IOREQS;
|
2005-04-21 16:53:53 +02:00
|
|
|
} else {
|
2010-06-01 14:35:33 +02:00
|
|
|
blocks_left = (block_t) (rip->i_size-ex64lo(position)+(block_size-1)) /
|
|
|
|
block_size;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Go for the first indirect block if we are in its neighborhood. */
|
|
|
|
if (!block_spec) {
|
|
|
|
scale = rip->i_sp->s_log_zone_size;
|
|
|
|
ind1_pos = (off_t) rip->i_ndzones * (block_size << scale);
|
2010-06-01 14:35:33 +02:00
|
|
|
if ((off_t) ex64lo(position) <= ind1_pos &&
|
|
|
|
rip->i_size > ind1_pos) {
|
2005-04-21 16:53:53 +02:00
|
|
|
blocks_ahead++;
|
|
|
|
blocks_left++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No more than the maximum request. */
|
|
|
|
if (blocks_ahead > NR_IOREQS) blocks_ahead = NR_IOREQS;
|
|
|
|
|
|
|
|
/* Read at least the minimum number of blocks, but not after a seek. */
|
|
|
|
if (blocks_ahead < BLOCKS_MINIMUM && rip->i_seek == NO_SEEK)
|
|
|
|
blocks_ahead = BLOCKS_MINIMUM;
|
|
|
|
|
|
|
|
/* Can't go past end of file. */
|
|
|
|
if (blocks_ahead > blocks_left) blocks_ahead = blocks_left;
|
|
|
|
|
|
|
|
read_q_size = 0;
|
|
|
|
|
|
|
|
/* Acquire block buffers. */
|
|
|
|
for (;;) {
|
2013-03-16 03:29:32 +01:00
|
|
|
block_t thisblock;
|
2005-04-21 16:53:53 +02:00
|
|
|
read_q[read_q_size++] = bp;
|
|
|
|
|
|
|
|
if (--blocks_ahead == 0) break;
|
|
|
|
|
|
|
|
/* Don't trash the cache, leave 4 free. */
|
2012-10-16 17:40:39 +02:00
|
|
|
if (lmfs_bufs_in_use() >= nr_bufs - 4) break;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
block++;
|
2013-03-16 03:29:32 +01:00
|
|
|
position_running += block_size;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2013-03-16 03:29:32 +01:00
|
|
|
if(!block_spec &&
|
|
|
|
(thisblock = read_map(rip, (off_t) ex64lo(position_running), 1)) != NO_BLOCK) {
|
|
|
|
bp = lmfs_get_block_ino(dev, thisblock, PREFETCH, rip->i_num, position_running);
|
|
|
|
} else {
|
|
|
|
bp = get_block(dev, block, PREFETCH);
|
|
|
|
}
|
2012-10-16 17:40:39 +02:00
|
|
|
if (lmfs_dev(bp) != NO_DEV) {
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Oops, block already in the cache, get out. */
|
|
|
|
put_block(bp, FULL_DATA_BLOCK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-10-16 17:40:39 +02:00
|
|
|
lmfs_rw_scattered(dev, read_q, read_q_size, READING);
|
2013-03-16 03:29:32 +01:00
|
|
|
|
|
|
|
if(block_spec)
|
|
|
|
return get_block(dev, baseblock, NORMAL);
|
|
|
|
return(lmfs_get_block_ino(dev, baseblock, NORMAL, rip->i_num, position));
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2006-11-09 17:22:54 +01:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_getdents *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_getdents(void)
|
2006-11-09 17:22:54 +01:00
|
|
|
{
|
2012-07-26 14:42:55 +02:00
|
|
|
#define GETDENTS_BUFSIZE (sizeof(struct dirent) + MFS_NAME_MAX + 1)
|
|
|
|
#define GETDENTS_ENTRIES 8
|
|
|
|
static char getdents_buf[GETDENTS_BUFSIZE * GETDENTS_ENTRIES];
|
2006-11-09 17:22:54 +01:00
|
|
|
register struct inode *rip;
|
2010-06-01 14:35:33 +02:00
|
|
|
int o, r, done;
|
|
|
|
unsigned int block_size, len, reclen;
|
2006-11-09 17:22:54 +01:00
|
|
|
ino_t ino;
|
|
|
|
cp_grant_id_t gid;
|
|
|
|
size_t size, tmpbuf_off, userbuf_off;
|
|
|
|
off_t pos, off, block_pos, new_pos, ent_pos;
|
|
|
|
struct buf *bp;
|
|
|
|
struct direct *dp;
|
|
|
|
struct dirent *dep;
|
|
|
|
char *cp;
|
|
|
|
|
2010-06-01 14:35:33 +02:00
|
|
|
ino = (ino_t) fs_m_in.REQ_INODE_NR;
|
|
|
|
gid = (gid_t) fs_m_in.REQ_GRANT;
|
|
|
|
size = (size_t) fs_m_in.REQ_MEM_SIZE;
|
|
|
|
pos = (off_t) fs_m_in.REQ_SEEK_POS_LO;
|
2006-11-09 17:22:54 +01:00
|
|
|
|
|
|
|
/* Check whether the position is properly aligned */
|
2010-06-01 14:35:33 +02:00
|
|
|
if( (unsigned int) pos % DIR_ENTRY_SIZE)
|
- 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
|
|
|
return(ENOENT);
|
2006-11-09 17:22:54 +01:00
|
|
|
|
2010-05-10 15:26:00 +02:00
|
|
|
if( (rip = get_inode(fs_dev, ino)) == NULL)
|
- 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
|
|
|
return(EINVAL);
|
2006-11-09 17:22:54 +01:00
|
|
|
|
- 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
|
|
|
block_size = rip->i_sp->s_block_size;
|
|
|
|
off = (pos % block_size); /* Offset in block */
|
|
|
|
block_pos = pos - off;
|
|
|
|
done = FALSE; /* Stop processing directory blocks when done is set */
|
2006-11-09 17:22:54 +01:00
|
|
|
|
- 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
|
|
|
tmpbuf_off = 0; /* Offset in getdents_buf */
|
2012-07-26 14:42:55 +02:00
|
|
|
memset(getdents_buf, '\0', sizeof(getdents_buf)); /* Avoid leaking any data */
|
- 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
|
|
|
userbuf_off = 0; /* Offset in the user's buffer */
|
2006-11-09 17:22:54 +01:00
|
|
|
|
|
|
|
/* The default position for the next request is EOF. If the user's buffer
|
- 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
|
|
|
* fills up before EOF, new_pos will be modified. */
|
|
|
|
new_pos = rip->i_size;
|
|
|
|
|
|
|
|
for(; block_pos < rip->i_size; block_pos += block_size) {
|
2013-03-16 03:29:32 +01:00
|
|
|
/* Since directories don't have holes, 'bp' cannot be NULL. */
|
|
|
|
bp = get_block_map(rip, block_pos); /* get a dir block */
|
2010-06-01 14:35:33 +02:00
|
|
|
assert(bp != NULL);
|
- 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
|
|
|
|
|
|
|
/* Search a directory block. */
|
|
|
|
if (block_pos < pos)
|
2012-10-16 17:40:39 +02:00
|
|
|
dp = &b_dir(bp)[off / DIR_ENTRY_SIZE];
|
- 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
|
|
|
else
|
2012-10-16 17:40:39 +02:00
|
|
|
dp = &b_dir(bp)[0];
|
|
|
|
for (; dp < &b_dir(bp)[NR_DIR_ENTRIES(block_size)]; dp++) {
|
2011-08-05 01:15:16 +02:00
|
|
|
if (dp->mfs_d_ino == 0)
|
- 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
|
|
|
continue; /* Entry is not in use */
|
|
|
|
|
|
|
|
/* Compute the length of the name */
|
2011-08-05 01:15:16 +02:00
|
|
|
cp = memchr(dp->mfs_d_name, '\0', sizeof(dp->mfs_d_name));
|
- 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 (cp == NULL)
|
2011-08-05 01:15:16 +02:00
|
|
|
len = sizeof(dp->mfs_d_name);
|
- 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
|
|
|
else
|
2011-08-05 01:15:16 +02:00
|
|
|
len = cp - (dp->mfs_d_name);
|
2006-11-09 17:22:54 +01:00
|
|
|
|
- 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
|
|
|
/* Compute record length */
|
|
|
|
reclen = offsetof(struct dirent, d_name) + len + 1;
|
|
|
|
o = (reclen % sizeof(long));
|
|
|
|
if (o != 0)
|
|
|
|
reclen += sizeof(long) - o;
|
|
|
|
|
2010-01-21 10:32:15 +01:00
|
|
|
/* Need the position of this entry in the directory */
|
2012-10-16 17:40:39 +02:00
|
|
|
ent_pos = block_pos + ((char *) dp - (char *) bp->data);
|
- 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-07-26 14:42:55 +02:00
|
|
|
if (userbuf_off + tmpbuf_off + reclen >= size) {
|
|
|
|
/* The user has no space for one more record */
|
|
|
|
done = TRUE;
|
|
|
|
|
|
|
|
/* Record the position of this entry, it is the
|
|
|
|
* starting point of the next request (unless the
|
|
|
|
* postion is modified with lseek).
|
|
|
|
*/
|
|
|
|
new_pos = ent_pos;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmpbuf_off + reclen >= GETDENTS_BUFSIZE*GETDENTS_ENTRIES) {
|
2010-06-08 15:58:01 +02:00
|
|
|
r = sys_safecopyto(VFS_PROC_NR, gid,
|
2010-06-01 14:35:33 +02:00
|
|
|
(vir_bytes) userbuf_off,
|
|
|
|
(vir_bytes) getdents_buf,
|
2012-06-16 03:46:15 +02:00
|
|
|
(size_t) tmpbuf_off);
|
2010-06-01 14:35:33 +02:00
|
|
|
if (r != OK) {
|
|
|
|
put_inode(rip);
|
|
|
|
return(r);
|
|
|
|
}
|
2006-11-09 17:22:54 +01:00
|
|
|
|
- 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
|
|
|
userbuf_off += tmpbuf_off;
|
|
|
|
tmpbuf_off = 0;
|
2012-07-26 14:42:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dep = (struct dirent *) &getdents_buf[tmpbuf_off];
|
|
|
|
dep->d_ino = dp->mfs_d_ino;
|
|
|
|
dep->d_off = ent_pos;
|
|
|
|
dep->d_reclen = (unsigned short) reclen;
|
|
|
|
memcpy(dep->d_name, dp->mfs_d_name, len);
|
|
|
|
dep->d_name[len] = '\0';
|
|
|
|
tmpbuf_off += reclen;
|
|
|
|
}
|
- 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-07-26 14:42:55 +02:00
|
|
|
put_block(bp, DIRECTORY_BLOCK);
|
|
|
|
if (done)
|
|
|
|
break;
|
- 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-07-26 14:42:55 +02:00
|
|
|
if (tmpbuf_off != 0) {
|
|
|
|
r = sys_safecopyto(VFS_PROC_NR, gid, (vir_bytes) userbuf_off,
|
2012-06-16 03:46:15 +02:00
|
|
|
(vir_bytes) getdents_buf, (size_t) tmpbuf_off);
|
2012-07-26 14:42:55 +02:00
|
|
|
if (r != OK) {
|
|
|
|
put_inode(rip);
|
|
|
|
return(r);
|
|
|
|
}
|
- 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-07-26 14:42:55 +02:00
|
|
|
userbuf_off += tmpbuf_off;
|
- 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-07-26 14:42:55 +02:00
|
|
|
if (done && userbuf_off == 0)
|
- 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
|
|
|
r = EINVAL; /* The user's buffer is too small */
|
|
|
|
else {
|
|
|
|
fs_m_out.RES_NBYTES = userbuf_off;
|
|
|
|
fs_m_out.RES_SEEK_POS_LO = new_pos;
|
2011-12-22 01:29:27 +01:00
|
|
|
if(!rip->i_sp->s_rd_only) {
|
|
|
|
rip->i_update |= ATIME;
|
|
|
|
IN_MARKDIRTY(rip);
|
|
|
|
}
|
- 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
|
|
|
r = OK;
|
2006-11-09 17:22:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
put_inode(rip); /* release the inode */
|
|
|
|
return(r);
|
|
|
|
}
|
2009-05-11 12:02:28 +02:00
|
|
|
|