Commit graph

44 commits

Author SHA1 Message Date
Ben Gras a89ec8bc3b can't get_block(NO_DEV) any more
. 'anonymous' cache blocks (retrieved with NO_DEV as dev
	  parameter) were used to implement read()s from holes in
	  inodes that should return zeroes
	. this is an awkward special case in the cache code though
	  and there's a more direct way to implement the same functionality:
	  instead of copying from a new, anonymous, zero block, to
	  the user target buffer, simply sys_safememset the user target
	  buffer directly. as this was the only use of this feature,
	  this is all that's needed to simplify the cache code a little.
2012-11-16 16:37:44 +01:00
Ben Gras bd3cde4571 Move primary cache code to libminixfs.
Add primary cache management feature to libminixfs as mfs and ext2
currently do separately, remove cache code from mfs and ext2, and make
them use the libminixfs interface. This makes all fields of the buf
struct private to libminixfs and FS clients aren't supposed to access
them at all. Only the opaque 'void *data' field (the FS block contents,
used to be called bp) is to be accessed by the FS client.

The main purpose is to implement the interface to the 2ndary vm cache
just once, get rid of some code duplication, and add a little
abstraction to reduce the code inertia of the whole caching business.

Some minor sanity checking and prohibition done by mfs in this code
as removed from the generic primary cache code as a result:
        - checking all inodes are not in use when allocating/resizing
          the cache
        - checking readonly filesystems aren't written to
        - checking the superblock isn't written to on mounted filesystems

The minixfslib code relies on fs_blockstats() in the client filesystem to
return some FS usage information.
2012-10-23 19:48:38 +02:00
Ben Gras e4ac80eb60 various warning/errorwarning fixes for gcc47
. warnings (sometimes promoted to errors) in servers/ and kernel/
 . -Os for ext2 boot module to make it small enough
2012-08-27 16:19:18 +02:00
David van Moolenbroek 5456f2728e ext2: resolve Coverity warnings 2012-08-14 09:11:19 +00:00
David van Moolenbroek d18f3a9bc9 ext2: remove -Werror from CFLAGS
This breaks the Coverity build at the moment.
2012-08-01 12:39:14 +00:00
Thomas Veerman 48237f1730 ext2: use new secondary cache method
This gets rid of the ! emitted by VM when using ext2
2012-07-30 09:44:58 +00:00
Thomas Veerman 6c597561bc EXT2: various fixes
.enable all compile time warnings and make them errors
.refactor functions with unused parameters
.fix null pointer dereference before checking for null
.proper variable initialization
.use safe string copy functions
.fix massive memory corruption bug in fs_getdents
2012-07-30 09:44:58 +00:00
Ben Gras 2bfeeed885 drop segment from safecopy invocations
. all invocations were S or D, so can safely be dropped
	  to prepare for the segmentless world
	. still assign D to the SCP_SEG field in the message
	  to make previous kernels usable
2012-06-16 16:22:51 +00:00
David van Moolenbroek 26f817243b VFS: reimplement truncate mtime/ctime fix
POSIX mandates that a file's modification and change time be left
untouched upon truncate/ftruncate iff the file size does not change.
However, an open(O_TRUNC) call must always update the modification and
change time of the file, even if it was already zero-sized. VFS uses
the file systems' truncate call to implement O_TRUNC. This patch
replaces git-255ae85, which did not take into account the open case.
The size check is now moved into VFS, so that individual file systems
need not check for this case anymore.
2012-04-20 11:35:59 +02:00
Ben Gras 204ae72525 retire _ANSI and <minix/ansi.h> 2012-03-25 21:58:27 +02:00
Ben Gras 7336a67dfe retire PUBLIC, PRIVATE and FORWARD 2012-03-25 21:58:14 +02:00
Ben Gras 6a73e85ad1 retire _PROTOTYPE
. only good for obsolete K&R support
	. also remove a stray ansi.h and the proto cmd
2012-03-25 16:17:10 +02:00
Arun Thomas ff56906879 Remove obsolete INSTALLFLAGS from makefiles 2012-02-16 23:26:38 +01:00
Thomas Veerman c89bc85009 Don't repeat out-of-space messages
This patch makes PFS, EXT2 and MFS print only once that they're out of
space. After freeing up space and running out of space again, the message
will be printed again also.
2011-12-21 10:47:28 +00:00
David van Moolenbroek db087efac4 VFS/FS: REQ_NEW_DRIVER now provides a label 2011-11-30 19:05:26 +01:00
David van Moolenbroek b4d9ac91ba FS servers: fix dependencies broken in git-af01bda 2011-11-23 17:03:16 +01:00
David van Moolenbroek b4d909d415 Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.

The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.

After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
  in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
  reintroduced

As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.

Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-23 14:06:37 +01:00
David van Moolenbroek af01bda509 libbdev: initial version
The "bdev" library provides basic primitives for file systems to talk
to block device drivers, hiding the details of the underlying protocol
and interaction model.

This version of libbdev is rather basic. It is planned to support the
following features in the long run:

 - asynchronous requests and replies;
 - recovery support for underlying block drivers;
 - retrying of failed I/O requests.

The commit also changes our block-based file systems (mfs, ext2, isofs)
to make use of libbdev.
2011-11-09 14:43:25 +01:00
David van Moolenbroek 2602861f23 Move optset.c into libsys; remove redundant copies 2011-11-07 16:16:08 +01:00
Ben Gras 98233fa144 ext2: replace debug printf by assert 2011-09-09 16:33:55 +00:00
Ben Gras 4857d5d554 add -lminixfs with fs support routines
. move cache size heuristic from mfs there
	  so mfs and ext2 can share it
	. add vfs credentials retrieving function, with
	  backwards compatability from previous struct
	  format, to be used by both ext2 and mfs
	. fix for ext2 - STATICINIT was fed no.
	  of bytes instead of no. of elements, overallocating
	  memory by a megabyte or two for the superblock
2011-09-08 16:52:13 +00:00
Thomas Veerman ce1a2793f9 Fix off-by-one error 2011-09-08 15:10:57 +00:00
Thomas Veerman d4b72e81b2 Cleanup servers to make GCC/Clang a little happier 2011-09-08 13:57:03 +00:00
Thomas Veerman f78fb05676 Check group range for sanity 2011-09-08 12:23:03 +00:00
Evgeniy Ivanov 4806f7c308 Fix ext2 symlink bug.
rip->i_size is a target length without trailing '\0'.

Reported by Ben Gras.
2011-08-29 21:54:25 +00:00
Thomas Veerman 8a73de51f1 Tell VFS how many requests an FS can handle concurrently 2011-08-26 12:47:43 +00:00
Ben Gras f984dbba70 increase system-wide filename limit to 255
. move mfs-specific struct, constants to mfs/, so
	  mfs-specific, on-disk format structs and consts are
	  fully isolated from generic structs and functions
	. removes de and readfs utils
2011-08-17 16:00:01 +00:00
Evgeniy Ivanov 13ded5339f Fix ext2 dentry allocation glitch.
When remove dentry, check if cached position is greater than removed
one.
2011-08-15 17:33:51 +00:00
Evgeniy Ivanov 55c6f3f507 Fix bugs in ext2 found by clang static analyzer 2011-08-12 12:38:53 +00:00
Thomas Veerman 7588db2691 Add support for VFS-FS transaction IDs 2011-07-27 15:49:42 +00:00
Evgeniy Ivanov 255ae85b1e Fix time modification on truncate()
POSIX truncate specification says "Upon successful completion, if
the *file size is changed*, this function shall mark for update the
st_ctime and st_mtime fields of the file." This patch prevents
changing of the date fields when the size stays the same.
2011-07-15 14:21:05 +00:00
Evgeniy Ivanov ef0a265086 New stat structure.
* VFS and installed MFSes must be in sync before and after this change *

Use struct stat from NetBSD. It requires adding new STAT, FSTAT and LSTAT
syscalls. Libc modification is both backward and forward compatible.

Also new struct stat uses modern field sizes to avoid ABI
incompatibility, when we update uid_t, gid_t and company.
Exceptions are ino_t and off_t in old libc (though paddings added).
2011-07-12 16:39:55 +02:00
Arun Thomas b956c8735e Fix GCC image building 2011-07-09 15:04:42 +02:00
Ben Gras a77c2973b3 fix clang warnings -R in kernel/ and servers/ 2011-06-09 16:09:13 +02:00
Ben Gras 314d09adf7 fix clang warnings in servers/ 2011-05-12 22:23:02 +02:00
David van Moolenbroek c51cd5fe91 Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.

From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:

- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
  when setting REP_ENDPT, matching requests in CANCEL calls, getting
  DEV_SELECT flags, and retrieving of the real user process's endpoint
  in DEV_OPEN.

The changes in this patch are binary backward compatible.
2011-04-11 17:35:05 +00:00
Ben Gras dc1cc91df1 <ansi.h> -> <minix/ansi.h> 2011-01-28 11:35:02 +00:00
Dirk Vogt 9ed280d1ec decouple file system server start/termination from mount/umount 2010-11-23 19:34:56 +00:00
Thomas Veerman af73996d51 Fix failing unmount attempt at shutdown after running test58 2010-09-17 09:34:36 +00:00
Thomas Veerman 0b00cf70b6 - Return ENOENT when trying to add files to removed (but open) directories.
- Add test58 to test this behavior.
2010-09-01 09:07:18 +00:00
Arun Thomas de231a713e Move MIN() and MAX() macros to sys/params.h 2010-08-21 13:10:41 +00:00
Erik van der Kouwe 0fc71a1154 Increase NR_INODES in the FS servers to match NR_VNODES in VFS 2010-08-05 11:37:37 +00:00
Erik van der Kouwe 912b4e0cb7 Return ENOSPC when out of inodes 2010-08-05 11:37:06 +00:00
Thomas Veerman dff0434eaf Add support for the ext2 file system. Contributed by Evgeniy Ivanov. 2010-08-02 11:44:45 +00:00