Commit graph

1183 commits

Author SHA1 Message Date
Tomas Hruby f19d8df184 VFS : simplification of handling asyn selects
- select_request_async() returns no ops by default

- wantops in do_select() always set correctly, do_select() does
  not need a special case for SUSPEND (and ugly code)
2012-03-02 15:44:48 +00:00
Tomas Hruby 369a12704f VFS - dev_style_asyn()
- dev_style_asyn() tests whether a device is asynchronous

 - simplifies code and helps readability
2012-03-02 15:44:47 +00:00
Tomas Hruby 35eb88461d VFS - cancel_nblock()
- duplicate code in dev_io() which sends CANCEL in case of a
  non-blocking operation moved to cancel_nblock()
2012-03-02 15:44:47 +00:00
Thomas Veerman eb4096ccd1 iso9660: link with libc
Prevents assert("inited") in _env.c (libc) from triggering.
2012-02-22 15:17:20 +00:00
Thomas Veerman 1efb51b1de VFS: improve crashed FS resource cleanup
When VFS detects that an FS has crashed and tries to clean up
resources, it marks fairly late in the process that a vmnt is not
to be used again (to send requests to). This allows a thread to
become blocked on a vmnt after all blocked threads were stopped, but
before it finds out it shouldn't try to send to that vmnt.
2012-02-22 13:54:35 +00:00
Thomas Veerman 5ff845212e VFS: remove unused variables 2012-02-21 10:21:05 +00:00
Thomas Veerman 0c1cd8720a VFS: fix last_dir not returning last directory
If the provided path was only a single component (i.e., without
slashes), then last_dir would return early and skip the symlink
detection (i.e., check whether the path ends in a symlink and resolve
that first before returning). This bug triggered an assert in open
which expects that an advance after an last_dir (with VMNT_WRITE lock)
does not yield another vmnt lock.
2012-02-21 10:21:05 +00:00
Thomas Veerman 230ea1ce13 VFS: remove erroneous assert
The assert was meant as an additional check to the assert in link.c:198.
The reasoning behind the assert in link.c:198 is that once you've
obtained a write lock on a vmnt, you can't get an additional read lock
on the same vmnt. However, that does not always hold for the assert in
path.c:281 where the situation could be that you've obtained a read lock
and managed to get another read lock (this is possible). In other words,
the assert in path.c:281 is not the right place to check for that
situation.
2012-02-20 09:17:42 +00:00
Thomas Veerman c540bcb001 VFS: various select fixes
- Fix locking bug when unable to send DEV_SELECT request. Upon failure
  VFS tried to cancel the select operation, but this failed due to trying
  to lock a filp that was already locked to send the request in the first
  place. Do_select_request now handles locking of filps itself instead of
  relying on the caller to do it.  This fixes a crash when killing INET.
- Fix failure to revive a process after a non-blocking select operation
  yielded no ready select operations when replying DEV_SEL_REPL1.
- Improve readability by using OK, SUSPEND, and standard error values as
  results instead of having separate macros in select.
- Don't print not having a driver for a major device; after killing a driver
  select will trigger this printf.
2012-02-17 21:09:07 +00:00
Arun Thomas 5d958f894f servers: fix clang warnings in iso9660fs and vm 2012-02-17 16:48:40 +01:00
Arun Thomas ff56906879 Remove obsolete INSTALLFLAGS from makefiles 2012-02-16 23:26:38 +01:00
Antoine Leca 3fb8cb760c More cleaning up 2012-02-15 19:04:58 +00:00
Ben Gras 47c1f10835 re-enable update-superblock check
This reverts commit cdbc4bfb13.
2012-02-15 03:46:01 +01:00
Ben Gras 2fe8fb192f Full switch to clang/ELF. Drop ack. Simplify.
There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
2012-02-14 14:52:02 +01:00
Thomas Veerman 80c4685324 VFS: replace VFS with AVFS 2012-02-13 16:53:21 +00:00
Thomas Veerman 0c99f4f4b7 AVFS: reinitialize lookup object before reuse 2012-02-10 09:50:21 +00:00
Thomas Veerman 972a791882 AVFS/APFS: small cleanup 2012-02-09 16:33:24 +00:00
Thomas Veerman abd6043a2f AVFS: fix various system call interruption issues
- When cancelling ioctls, VFS did not remember which file descriptor
   to cancel and sent bogus to the driver.
 - Select state was not cleaned up when select()ing process was
   interrupted.
 - Process trying to do a system call at the exact same time as a user
   trying to interrupt the process, could cause the system call worker
   thread to overwrite state belonging to the worker thread trying to
   exit the process. This led to hanging threads and eventual system hang
   when this happens often enough.
2012-02-09 14:24:28 +00:00
Thomas Veerman 4498750810 libchardriver: fix open reply for async devices 2012-02-09 14:17:54 +00:00
Ben Gras cc1ae59c9b -lminixutil link fixes
. not available and not needed for clang
2012-02-06 16:08:29 +01:00
Ben Gras 1eea0f5680 inet: strncmp() fix 2012-02-03 14:49:18 +01:00
Ben Gras cdbc4bfb13 temporarily disable update-superblock check
. incompatible with installboot -d FSDEV on mounted filesystems
	. should be re-enabled when netbsd boot loader is default
2012-02-02 15:04:51 +01:00
Thomas Veerman b33f504e8f APFS: fix link issue when compiling with Clang 2012-02-02 15:00:01 +00:00
Thomas Veerman a65ff8a1aa INET: fix 'improved' assert 2012-02-02 11:53:52 +00:00
Thomas Veerman 224a0f6e90 INET: fix a few GCC compilation warnings 2012-02-01 13:24:28 +00:00
Thomas Veerman 4d3a0887b4 AVFS: only put mount point when it was used as one
When a mount operation fails and the FS exits, free_proc could try and
clean up resources associated with the mount point before the mount
thread itself can do that. However, the clean up procedure should only
clean up resources that were actually in use.
2012-02-01 13:22:53 +00:00
Thomas Veerman a87ec6840f INET: remove erroneous assert
The queue may contain established connections which have
tc_connInprogress clear.
2012-01-30 16:09:08 +00:00
Thomas Veerman 1ff24e3f2f Don't panic on a misconfigured machine 2012-01-30 15:16:20 +00:00
Thomas Veerman 1fc399a5c1 Add permission test for bind and socket
Also, apply forbidden patch to VFS from AVFS (fixes hanging test56 if
it has the permission test).
2012-01-30 15:16:20 +00:00
Thomas Veerman 9330d92639 INET: drop privileges upon startup 2012-01-30 15:16:20 +00:00
Thomas Veerman becf700bc2 APFS: drop privileges upon startup
Move SERVICE_LOGIN to rs.h global header so it's accessible for all.
2012-01-30 15:16:20 +00:00
Thomas Veerman 9233fdb359 AVFS: make forbidden check for specific proc instead of fp 2012-01-30 15:16:20 +00:00
Thomas Veerman 0e537f1085 AVFS: initialize root FS before receiving new work 2012-01-30 15:16:20 +00:00
Thomas Veerman 0bd011affd PM: extend srv_fork to set a specific UID
Currently, all servers and drivers run as root as they are forks of
RS. srv_fork now tells PM with which credentials to run the resulting
fork. Subsequently, PM lets VFS now as well.

This patch also fixes the following bugs:
 - RS doesn't initialize the setugid variable during exec, causing the
   servers and drivers to run setuid rendering the srv_fork extension
   useless.
 - PM erroneously tells VFS to run processes setuid. This doesn't
   actually lead to setuid processes as VFS sets {r,e}uid and {r,e}gid
   properly before checking PM's approval.
2012-01-30 15:16:19 +00:00
Thomas Veerman e894c9e1b5 Don't print events that happen often 2012-01-19 17:06:14 +00:00
Thomas Veerman 700641afb8 lseek should not yield a negative file position 2012-01-19 16:48:01 +00:00
Thomas Veerman 5691dca9f4 Don't try to find file position beyond double indirect blocks 2012-01-19 16:47:47 +00:00
Thomas Veerman ddbdca6cdb Add support for survival of crashed FSs
When an FS crashes, VFS will clean up resources tied to that FS:
 - Pending requests to the FS are canceled (i.e., fail with EIO)
 - Threads waiting for a reply are stopped (i.e., fail with EIO)
 - Open files are marked invalid. Future operations on a file descriptor
   will cause EBADF errors.
 - vmnt entry is cleared, so in-flight system calls that got past the
   file descriptor check but not yet talking to the crashed FS, will
   fail with EIO.
 - The reference counter of the mount point is decreased, effectively
   removing the crashed FS from the file system tree. Descendants of
   this part of the tree are unreachable by means of a path, but can
   still be unmounted by feeding the block special file to unmount(2).

This patch also gets rid of the "not a known driver endpoint" messages
during shutdown.
2012-01-19 14:21:46 +00:00
Ben Gras dd59d50944 mfs: mark blocks clean when invalidated
. it could happen that newly filled blocks were still marked
	  dirty
	. causing unnecessary i/o and the new warning of the superblock
	  being written
2012-01-18 17:51:04 +01:00
Thomas Veerman a6d0ee24c3 Use correct value for _NSIG
User processes can send signals with number up to _NSIG. There are a few
signal numbers above that used by the kernel, but should explicitly not
be included in the range or range checks in PM will fail.

The system processes use a different version of sigaddset, sigdelset,
sigemptyset, sigfillset, and sigismember which does not include a range
check on signal numbers (as opposed to the normal functions used by normal
processes).

This patch unbreaks test37 when the boot image is compiled with GCC/Clang.
2012-01-16 11:42:29 +00:00
Thomas Veerman a282e942bf INET: initialize timer to not-in-use 2012-01-16 11:09:46 +00:00
Thomas Veerman f18dab92bf Remove unused variable 2012-01-16 10:12:29 +00:00
Thomas Veerman 078adc7ed7 Increase thread stack space for GCC compiled images 2012-01-16 10:12:29 +00:00
Thomas Veerman e6c98c3c55 AVFS: Return actual last dir when path is named by a symlink
Last_dir didn't consider paths that end in a symlink and hence didn't
actually return the last_dir when provided with one. For example,
/var/log is a symlink to /usr/log. Issuing `>/var/log' would trigger
an assert in AVFS, because /var/ is not the actual last directory; /usr/
is.

Last_dir now verifies the final component is not a symlink. If it is, it
follows the symlink and restarts finding of the last the directory.
2012-01-16 10:12:29 +00:00
David van Moolenbroek c89aaf7a87 vfs/avfs: renumber stat calls so as to be unique
The old stat call numbers are still supported for a while.
2012-01-14 00:27:07 +01:00
David van Moolenbroek 2c685f34e0 Cut PM out of the adddma/deldma/getdma call path 2012-01-14 00:27:06 +01:00
David van Moolenbroek 8cb7ba7951 Remove obsolete PROCSTAT/getsigset call. 2012-01-14 00:27:06 +01:00
Ben Gras 4668b84158 vm_remap_ro
- allows shared memory to be mapped in readonly

- ben@minix3.org & tom@minix3.org
2012-01-13 11:30:01 +00:00
Tomas Hruby 88f990e122 VM - vm_unmap() takes SELF as valid argument 2012-01-13 11:30:01 +00:00
Tomas Hruby 974452d4dd VM - clear vminhibit iff it was set 2012-01-13 11:30:01 +00:00
Thomas Veerman a4d01f8a83 Fix tll state bug
When a lock has read-serialized and read-only locks, releasing the read-
serialized lock would not set the state to read-only when no other locks
were pending.
2012-01-12 11:30:24 +00:00
Ben Gras 7cd4002083 vm: clear map cache after kernel requests
. fixes a dirty tlb situation (i.e. random crashes)
	  on some hardware, seemingly new intel architectures
	  (e.g. my desktop i7 machine)
2012-01-11 01:15:35 +01:00
Evgeniy Ivanov d6c5a1280e Convert s_block_size on MFSv3.
On MFSv3 s_block_size is stored on disk, hence bytes should be converted
on big endian.
2012-01-08 23:52:57 +04:00
David van Moolenbroek c25e2eb0cf avfs: fix for root file system not being unmounted
Also no longer have avfs crash whenever a file system server crashes.
2012-01-04 14:10:10 +01:00
David van Moolenbroek 3e46876a73 hgfs: fix atime/mtime attribute setting bug
Reported and investigated by Antoine Leca.
2011-12-23 19:02:57 +01:00
David van Moolenbroek 80b03d929d hgfs: resolve gcc -W warnings 2011-12-23 19:01:56 +01:00
David van Moolenbroek 472a91708a Move hgfs.h to minix includes directory 2011-12-23 19:01:14 +01:00
Ben Gras 59ff5cbd87 mfs: clean flag
. also implement now-possible fsck -p option
    	. allows unconditional fsck -p invocation at startup,
    	  only checking each filesystem if not marked clean
    	. mounting unclean is allowed but is forced readonly
    	. updating the superblock while mounted is now not
    	  allowed by mfs - must be done (e.g. by fsck.mfs)
    	  on an unmounted fs
	. clean flag is unset by mfs on mounting, and set by
	  mfs on clean unmounting (if clean flag was set at
	  mount time)

Signed-off-by: Ben Gras <ben@minix3.org>
2011-12-22 16:53:32 +01:00
Ben Gras 9a664b4984 mfs: restore readonly mounting
. use dirty marking hooks to check and warn
	  when inodes/bufs are marked dirty on a readonly
	  mounted fs
	. add readonly mount checks to restore readonly
	  mounting

Signed-off-by: Ben Gras <ben@minix3.org>
2011-12-22 01:29:27 +01:00
Ben Gras 9b7d357ca1 mfs: use macros to mark blocks and inodes dirty
. No functional change
	. Only serves to get hooks to do checks in
	. e.g. should things be marked dirty when we are
	  mounted readonly

Signed-off-by: Ben Gras <ben@minix3.org>
2011-12-22 01:29:27 +01:00
Ben Gras 34a8901eb8 vfs,avfs: verify an interpreter was found on #! line
. if not, NULL *interp is dereferenced
2011-12-21 23:44:13 +01:00
Thomas Veerman de5a9a3e8b AVFS: Use scratchpad instead of m_in to pass around file descriptors
Some code relies on having the file descriptor in m_in.fd. Consequently,
m_in is not only used to provide syscall parameters from user space to
VFS, but also as a global variable to store temporary data within VFS.
This has the ugly side effect that m_in gets overwritten during core
dumping.*

To work around this problem VFS now uses a so called "scratchpad" to
store temporary data that has to be globally accessible. This is a simple
table indexed by process number, just like fproc. The scratchpad allows
us to store the buffer pointer and buffer size for suspended system calls
(i.e., read, write, open, lock) instead of using fproc. This makes fproc
a bit smaller and fproc iterators a bit faster. Moreover, suspension of
processes becomes simpler altogether and suspended operations on pipes
are now less of a special case.

* This patch fixes a bug where due to unexpected m_in overwriting a
coredump would fail, and consequently resources are leaked. The coredump
was triggered with:
$ a() { a; }
$ a
2011-12-21 10:52:51 +00: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
Thomas Veerman 54c0eb9aa6 Compare read/write buf size against SSIZE_MAX instead of "< 0"
The nbyte in read(int fildes, void *buf, size_t nbyte) is unsigned,
so although technically we're doing the same comparison, this is more
in line with POSIX.

The comparison was moved to read_write as that routine is used within
VFS to let it VFS write out coredumps.
2011-12-21 10:46:09 +00:00
Thomas Veerman 9f9f893123 Mark filp as in use on fd dup'ing 2011-12-21 10:45:29 +00:00
Thomas Veerman 94da86cbee Discard process' pending request upon incoming PM request
When a process wants something done from VFS, but VFS has no worker
threads available, the request is stored and executed later. However,
when PM also sends a request for that process at the same time, discard
the pending request from the process and give priority to PM. The request
PM sends is either an EXIT or a DUMPCORE request, so we're not interested
in executing the pending request anyway.
2011-12-12 08:20:35 +00:00
David van Moolenbroek 35cf8beb33 procfs: add /proc/dmap 2011-12-11 22:35:33 +01:00
David van Moolenbroek aa712e7e73 IS: unbreak F6 2011-12-11 22:34:54 +01:00
David van Moolenbroek 6f374faca5 Add "expected size" parameter to getsysinfo()
This patch provides basic protection against damage resulting from
differently compiled servers blindly copying tables to one another.
In every getsysinfo() call, the caller is provided with the expected
size of the requested data structure. The callee fails the call if
the expected size does not match the data structure's actual size.
2011-12-11 22:34:14 +01:00
David van Moolenbroek 9701e9dfd2 Servers: cleanup of some gcc -W warnings 2011-12-11 22:33:37 +01:00
Thomas Veerman 26d359a30c Properly unlock on mount failure 2011-12-09 15:47:42 +00:00
Thomas Veerman 5cbbfc69e7 Change asserts with side effects into panics 2011-12-09 14:46:10 +00:00
Thomas Veerman 706873142e Fix dangling symlink resolving for AVFS and add test61 2011-12-09 10:34:23 +00:00
Thomas Veerman 0a61519eea Provide core dumping support for AVFS 2011-12-08 10:47:11 +00:00
David van Moolenbroek 9221586f37 vfs/avfs: req_newdriver should use fs_sendrec
Using sendrec directly only results in problems. While it is not
clear whether using fs_sendrec is the best option, it is at least
an improvement.

Also remove some legacy cruft.
2011-12-05 16:28:09 +01:00
David van Moolenbroek ba19c83fd6 RS: support for endpoint-changing driver restarts 2011-12-05 16:28:07 +01:00
David van Moolenbroek 01015cc0e2 init: write boot entry to root wtmp
This unbreaks the fsck check on startup.
2011-12-05 13:56:16 +01:00
David van Moolenbroek db087efac4 VFS/FS: REQ_NEW_DRIVER now provides a label 2011-11-30 19:05:26 +01:00
Thomas Veerman b4fb061802 Implement issetugid syscall
Implement issetugid syscall and provide a test. This gets rid of the
scary "Unsecure. Implement me" warning during compilation.
2011-11-28 10:03:43 +00:00
Ben Gras ef99a7a3dc vm: report cropped region sizes
. when reporting on regions, only report part of the
	  region (addr and length) that really has memory mapped
	  into it
	. to minimise core files
2011-11-26 15:12:17 +00:00
David van Moolenbroek a9f89a7290 vfs/avfs: map O_ACCMODE to R_BIT|W_BIT on recovery 2011-11-24 13:57:36 +01:00
David van Moolenbroek e8f944d3ca avfs: unbreak process termination on PM_DUMPCORE 2011-11-24 13:04:52 +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 1e1db53986 Introduce sys_getregs call, and let vfs use it 2011-11-22 02:07:33 +01:00
Adriana Szekeres c30f014a89 gcore command to coredump a process 2011-11-22 22:07:41 +01:00
Adriana Szekeres eaa29370f4 ELF core files 2011-11-22 22:07:40 +01:00
David van Moolenbroek f29ba928cc isofs: unbreak lseek 2011-11-22 11:46:55 +01:00
Ben Gras c24d15b2db pm: add mproc table sanity check feature
. make procfs check it
	. detects pm/procfs mismatches
	. was triggered by ack/clang pm/procfs:
	  add padding to mproc struct to align ack/clang layout
	  to fix this
2011-11-18 17:18:10 +01:00
David van Moolenbroek 85b8fbe72b More cleanup of minix/com.h. 2011-11-11 13:53:29 +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 0bb27bb0b1 Servers: remove ABI comment 2011-11-07 22:24:59 +01:00
David van Moolenbroek b02c260ecb Miscellaneous legacy cleanup 2011-11-07 22:20:55 +01:00
David van Moolenbroek 2602861f23 Move optset.c into libsys; remove redundant copies 2011-11-07 16:16:08 +01:00
Ben Gras c83a90e2f1 mfs: ditch global readahead 2011-11-06 19:15:12 +01:00
David van Moolenbroek 0812293b47 procfs: fix for PID reuse between updates
In certain cases, a process ID may be reused between two lazy updates
of procfs's PID table. If the new associated process slot has a lower
index than the old one, this will trigger an assert in vtreefs, as the
new PID name entry is added before the old one is removed. This patch
fixes the problem by always first removing old PID name entries before
adding new ones.

Bug reported by Stephen Hatton.
2011-11-01 23:50:55 +00:00
Arun Thomas 62841e2935 pm: remove dead minix_munmap functions 2011-11-02 18:43:59 +01:00
Thomas Veerman 65e54c23e3 PFS is also a system proc 2011-10-28 12:49:47 +00:00
Thomas Veerman febb4403ff Reenable backcall detection 2011-10-27 15:29:37 +00:00
Thomas Veerman 823e42c3e3 Make AVFS deal intelligently with back calling FSes
PUFFS file systems need to make back calls for every operation we
send to them. Consequently, they cannot handle block reads and writes
themselves. Instead, the root file system has to do it (for now).

When the mount operation causes an FS to make a back call, AVFS now
concludes that every block read and write for that FS has to go
through the root file system.
2011-10-27 15:29:23 +00:00
Antoine LECA b1c2329954 clean up PM_SCHEDULED 2011-10-25 16:37:21 +00:00
Thomas Veerman 9e21d55e37 err_code has to be preserved as well. Short term fix 2011-10-25 12:12:20 +00:00
Thomas Veerman 8c9e62b299 Revert to using flushtlb instead of invlpg
Somehow the usage of invlpg causes Minix to crash on Qemu. Reverting
temporarily until we have a proper fix.
2011-09-27 15:15:51 +00:00
Ben Gras 49532259e5 mfs: improve & simplify secondary cache logic
. fixes "!" errors when booting from cd
2011-09-23 15:02:20 +00:00
Ben Gras 833183a9e1 vm: undo accidental JUNKFREE on 2011-09-19 15:36:46 +00:00
Ben Gras 1dfd43ac27 boot e820 memory detection fixes 2011-09-19 13:36:03 +00:00
Arun Thomas cb54d96eec Remove legacy boot monitor vars 2011-09-16 20:10:47 +02:00
Thomas Veerman 90cde23c19 Cleanup more resources upon exit 2011-09-16 10:16:57 +00:00
Thomas Veerman 1c928cf61a Remove debug print 2011-09-16 10:16:32 +00:00
Thomas Veerman 200b9d7339 Unmap drivers upon exit 2011-09-16 10:16:00 +00:00
Thomas Veerman 203937456e Fix off-by-one errors and increase PATH_MAX to 1024
In some places it was assumed that PATH_MAX does not include a
terminating null character.

Increases PATH_MAX to 1024 to get in sync with NetBSD. Required some
rewriting in AVFS to keep memory usage low (the stack in use by a thread
is very small).
2011-09-12 09:00:24 +00: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
Arun Thomas 8a0901c4cb Add MKTRACE 2011-09-07 17:52:48 +02:00
Thomas Veerman 7db039347a Make AVFS resilient against failing back calls 2011-09-06 10:38:16 +00:00
Thomas Veerman 8a266a478e Increase gid_t and uid_t to 32 bits
Increase gid_t and uid_t to 32 bits and provide backwards compatibility
where needed.
2011-09-05 13:56:14 +00:00
Thomas Veerman fde9a258d0 Make dev_t 32-bits and provide backwards compatibility 2011-09-05 08:52:57 +00:00
Arun Thomas 4ca68d42a0 Add MKLIVEUPDATE and MKSTATECTL 2011-09-02 16:57:22 +02: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 7f24c2b3ca Unverbose mount 2011-08-26 15:49:37 +00:00
Thomas Veerman 78183bddff Let FSes exit themselves upon system shutdown
During shutdown all processes are semi-exited and FSes are unmounted.
This semi-exit causes trouble for FUSE mounts as they still need access
to file descriptors and working directory in order to unmount.
2011-08-26 15:17:53 +00:00
Thomas Veerman 8a73de51f1 Tell VFS how many requests an FS can handle concurrently 2011-08-26 12:47:43 +00:00
Thomas Veerman 30be017762 Store and use max concurrent requests 2011-08-26 12:47:43 +00:00
Thomas Veerman c78308f469 Increase max number of arguments 2011-08-22 13:44:24 +00:00
Thomas Veerman e09714ab53 Turn off block read debugs and turn on mount debugs 2011-08-22 13:24:35 +00:00
Thomas Veerman 4ee157f5ce Report error instead panicing 2011-08-22 13:08:38 +00:00
Thomas Veerman 1f28a4b83e Remove verbosity 2011-08-22 13:08:03 +00:00
Thomas Veerman 68011701bd Reduce block special file (thread) lock scope 2011-08-22 11:51:29 +00:00
Thomas Veerman 55d926cbaa Allow block special files to be file locked 2011-08-22 11:51:01 +00:00
Thomas Veerman ae2159c371 Fix locking issues with back calls from FSes 2011-08-19 14:17:35 +00:00
Ben Gras cc64313b80 is: stopgap for broken _USEVFS check 2011-08-17 16:27:46 +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
Thomas Veerman a18a007361 Range fix from PFS 2011-08-17 13:42:38 +00:00
Thomas Veerman a6bd3f4a22 Merge AVFS and APFS 2011-08-17 13:40:36 +00:00
Ben Gras ee48228aa0 pfs: fix range check
. debugged and fixed by Jan Wieck
2011-08-17 12:39:33 +00:00
Evgeniy Ivanov bc434254ea MFS: optimize dentry acllocation.
When search for free slot always cache position of last allocated slot,
so next time when need to allocate new slot, we can search from that
position.
2011-08-17 08:41:35 +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 426cddbb30 Add missing put_inode().
Fixes bug from a9a45cddc.
2011-08-15 16:20:06 +00:00
Ben Gras 35cc7fbeb8 kernel: invlpg facility
. only use for single-page invalidations initially
	. shows tiny but statistically significant performance
	  improvement; will be more helpful in certain VM debug
	  modes
2011-08-12 13:08:27 +00:00
Evgeniy Ivanov 55c6f3f507 Fix bugs in ext2 found by clang static analyzer 2011-08-12 12:38:53 +00:00
Arun Thomas 9602f63a72 pm: remove dead function 2011-08-11 17:51:27 +02:00
Evgeniy Ivanov a9a45cddc4 Fix bugs found in MFS by clang static analyzer. 2011-08-10 20:47:16 +00:00
Arun Thomas 86b061078b Build gcov code only if MKCOVERAGE is yes 2011-08-09 10:39:33 +02:00
Ben Gras d477a9ed82 vm/ipc: only report signals when it matters to ipc
. ipc wants to know about processes that get
	  signals, so that it can break blocking ipc operations
	. doing it for every single signal is wasteful
	  and causes the annoying 'no slot for signals' message
	. this fix tells vm on a per-process basis it (ipc)
	  wants to be notified, i.e. only when it does any ipc calls
	. move ipc config to separate config file while we're at it
2011-08-05 20:52:32 +00:00
Ben Gras c4ea2a195c getsid() implementation 2011-08-02 22:16:59 +02:00
Arun Thomas aaefc6f838 Add MKMCONTEXT option 2011-08-02 13:57:31 +02:00
Ben Gras 989934b37c rename -lutil to -lminixutil
. in preparation for netbsd -lutil
2011-08-01 14:32:14 +02:00
Thomas Veerman 7588db2691 Add support for VFS-FS transaction IDs 2011-07-27 15:49:42 +00:00
Thomas Veerman ece4c9d565 Add DEV_CLONE_A dev type 2011-07-27 12:23:03 +00:00
Arun Thomas 530bd5d486 vfs/rs: for ELF, sep_id should be 0 2011-07-26 15:21:07 +02:00
Ben Gras 3dd7649ae7 RS: fix bug that overflows r_argv[]
. reported and debugged by Arne Welzel
	. problem is if there are too many args
	. there is a check, but then unconditional NULL termination
2011-07-21 08:08:22 +02:00
Arun Thomas 3eb22ca4d1 MK option to build only system image programs 2011-07-20 09:57:46 +02:00
Erik van der Kouwe b1408f61b4 Sanity checks prevent VM panic for mmap, vm_remap and map_phys 2011-07-19 08:58:01 +02:00
Ben Gras 832f7f99fd vm: munmap fix leftover 2011-07-18 12:03:58 +02:00
Ben Gras 02081e4b62 rename mmap() and munmap()
. it's a good extra interface to have but doesn't
	  meet standardised functionality
	. applications (in pkgsrc) find it and expect
	  full functionality the minix mmap doesn't offter
	. on the whole probably better to hide these functions
	  (mmap and friends) until they are grown up; the base system
	  can use the new minix_* names
2011-07-16 13:01:19 +02:00
Ben Gras 85f6d866e6 rename mmap MAP_SHARED to MAP_IPC_SHARED
. MAP_SHARED was used to implement sysv shared memory
	. used to signal shareable memory region to VM
	. assumptions about this situation break when processes
	  use MAP_SHARED for its normal, standardised meaning
2011-07-15 18:10:50 +02: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
Thomas Veerman 902e0e27e0 Don't panic if owner has vanished before reply 2011-07-15 14:11:34 +00:00
Ben Gras 253c293213 mfs<->vfs stat fallback for old vfs 2011-07-12 18:09:52 +02: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 a9d15dd3e4 pm, vfs: don't print something for bogus calls 2011-07-05 13:21:48 +02:00
Ben Gras 9c01ceb576 introduce sqrt_approx() in -lsys
. use this to avoid -lm dependency in mfs
2011-07-04 02:51:12 +02:00
Ben Gras 86a226680b vfs: don't SUSPEND for unknown calls
. returning ENOSYS helps for implementing
	  new calls with forwards compatability
2011-07-02 17:19:13 +02:00
Arun Thomas 93ae43f577 boot: Add multiboot support
Not yet fully spec-compliant; work in progress
2011-06-24 17:21:51 +02:00
Gianluca Guida cc17b27a2b Build NetBSD libc library in world in ELF mode.
3 sets of libraries are built now:
  . ack: all libraries that ack can compile (/usr/lib/i386/)
  . clang+elf: all libraries with minix headers (/usr/lib/)
  . clang+elf: all libraries with netbsd headers (/usr/netbsd/)

Once everything can be compiled with netbsd libraries and headers, the
/usr/netbsd hierarchy will be obsolete and its libraries compiled with
netbsd headers will be installed in /usr/lib, and its headers
in /usr/include. (i.e. minix libc and current minix headers set
will be gone.)

To use the NetBSD libc system (libraries + headers) before
it is the default libc, see:
   http://wiki.minix3.org/en/DevelopersGuide/UsingNetBSDCode
This wiki page also documents the maintenance of the patch
files of minix-specific changes to imported NetBSD code.

Changes in this commit:
  . libsys: Add NBSD compilation and create a safe NBSD-based libc.
  . Port rest of libraries (except libddekit) to new header system.
  . Enable compilation of libddekit with new headers.
  . Enable kernel compilation with new headers.
  . Enable drivers compilation with new headers.
  . Port legacy commands to new headers and libc.
  . Port servers to new headers.
  . Add <sys/sigcontext.h> in compat library.
  . Remove dependency file in tree.
  . Enable compilation of common/lib/libc/atomic in libsys
  . Do not generate RCSID strings in libc.
  . Temporarily disable zoneinfo as they are incompatible with NetBSD format
  . obj-nbsd for .gitignore
  . Procfs: use only integer arithmetic. (Antoine Leca)
  . Increase ramdisk size to create NBSD-based images.
  . Remove INCSYMLINKS handling hack.
  . Add nbsd_include/sys/exec_elf.h
  . Enable ELF compilation with NBSD libc.
  . Add 'make nbsdsrc' in tools to download reference NetBSD sources.
  . Automate minix-port.patch creation.
  . Avoid using fstavfs() as it is *extremely* slow and unneeded.
  . Set err() as PRIVATE to avoid name clash with libc.
  . [NBSD] servers/vm: remove compilation warnings.
  . u32 is not a long in NBSD headers.
  . UPDATING info on netbsd hierarchy
  . commands fixes for netbsd libc
2011-06-24 11:46:30 +02:00
Erik van der Kouwe 6e0f3b3bda Split off sys_umap_remote from sys_umap
sys_umap now supports only:
- looking up the physical address of a virtual address in the address space
  of the caller;
- looking up the physical address of a grant for which the caller is the
  grantee.

This is enough for nearly all umap users. The new sys_umap_remote supports
lookups in arbitrary address spaces and grants for arbitrary grantees.
2011-06-10 14:28:20 +00:00
Ben Gras a77c2973b3 fix clang warnings -R in kernel/ and servers/ 2011-06-09 16:09:13 +02:00
Erik van der Kouwe c2da8cb535 Globally enable -Wall warnings for GCC 2011-06-08 19:21:03 +00:00
Erik van der Kouwe 0cb22acbda Fix VM -Wall warnings and enable -Werror 2011-06-01 11:30:58 +02:00
Tomas Hruby 5582aae6d6 LWIP - removed __unused where inappropriate 2011-05-25 09:41:19 +02:00
Ben Gras 314d09adf7 fix clang warnings in servers/ 2011-05-12 22:23:02 +02:00
Ben Gras 674cd6fd48 larger i/o buffer for exec()
. makes exec() for large executables (e.g. clang, gcc)
    significantly faster

Thanks to Antoine Leca.
2011-05-12 19:12:28 +02:00
Arun Thomas 350b60661a ELF multiboot support 2011-05-04 18:51:43 +02:00
Thomas Veerman aba392e630 Clean up and fix multiple bugs in select:
- Remove redundant code.
 - Always wait for the initial reply from an asynchronous select request,
   even if the select has been satisfied on another file descriptor or
   was canceled due to a serious error.
 - Restart asynchronous selects if upon reply from the driver turns out
   that there are deferred operations (and do not forget we're still
   interested in the results of the deferred operations).
 - Do not hang a non-blocking select when another blocking select on
   the same filp is still blocking.
 - Split blocking operations in read, write, and exceptions (i.e.,
   blocking on read does not imply the write will block as well).
 - Some loops would iterate over OPEN_MAX file descriptors instead of
   the "highest" file descriptor.
 - Use proper internal error return values.
 - A secondary reply from a synchronous driver is essentially the same
   as from an asynchronous driver (the only difference being how the 
   answer is received). Merge.
 - Return proper error code after a driver failure.
 - Auto-detect whether a driver is synchronous or asynchronous.
 - Remove some code duplication.
 - Clean up code (coding style, add missing comments, put all select
   related code together).
2011-04-13 13:25:34 +00:00
Thomas Veerman f0740680cd Do not print an error message when a binary is corrupt 2011-04-12 13:09:19 +00: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
Arun Thomas cd9b4b46f4 libexec: return physaddr info from ELF headers 2011-04-07 12:22:36 +00:00
Tomas Hruby b2c2dc72bc LWIP - Fix for dhcpd broadcast to work after boot
Dhcp only works if devices are configured with a broadcast source
address at the begining as it currently uses raw ip sockets and the
sockets sets the source address. It is a quick hack and proper hdcpd
fix is preferable
2011-04-07 07:44:27 +00:00
Tomas Hruby dca25a1b39 LWIP - the lwip server
The server implements inet-like interface to vfs and drivers. The core
functionality is contained in the liblwip.
2011-04-07 07:44:11 +00:00
David van Moolenbroek 28f2a169da VFS: bugfixes for handling block-special files:
- on driver restarts, reopen devices on a per-file basis, not per-mount
- do not assume that there is just one vnode per block-special device
- update block-special files in the uncommon mounting success paths, too
- upon mount, sync but also invalidate affected buffers on the root FS
- upon unmount, check whether a vnode is in use before updating it
2011-03-25 10:56:43 +00:00
David van Moolenbroek 14e641cb8c PFS: UDS code cleanup:
- coalesce lots of duplicate code
- avoid using errno as much as possible
- fix bugs in some error handling cases
2011-03-25 10:52:53 +00:00
Ben Gras 5f1ab506c8 remove some debugging output from vm/region.c
- don't print verbose process map when legitimate errors occur
2011-03-16 11:57:35 +00:00
Ben Gras c90cdadcfb auto-tune mfs cache size based on FS usage and remaining system memory 2011-02-28 14:19:19 +00:00
Arun Thomas 25a790a631 VM and kernel support for ELF 2011-02-26 23:00:55 +00:00
Dirk Vogt 77fa5b4116 incoporate davman into server/rs 2011-02-25 12:25:03 +00:00
Dirk Vogt 00dcbb9dc6 Added Device Manager (USB hotplug support) 2011-02-23 13:48:03 +00:00
Erik van der Kouwe 36f9c1155a Restart process after response from async driver on non-blocking select 2011-02-23 10:27:48 +00:00
Dirk Vogt 344c18cf73 procfs: only initialize the first time procfs is mounte 2011-02-22 18:03:33 +00:00
Ben Gras 32f3d9842d pm - sys_sigsend can fail legitimately
. specifically, if a signal handler can't be invoked due
    to process memory, EFAULT is returned from the kernel.
    don't panic() then.
2011-02-18 15:44:54 +00:00
Ben Gras 287fee89cb add NOASSERTS make flag that disables assert()s (NDEBUG=1).
. made some checks in vfs/vnode.c also respond to NDEBUG=1.
  . turned on in release builds
2011-02-16 18:58:30 +00:00
Ben Gras c7b2b11ec2 vm: only suspend and resume process with vmctls in pt_writemap in smp mode 2011-02-11 14:56:52 +00:00
Ben Gras ab73ac3b6f procfs - export extra kernel time accounting fields 2011-02-08 13:59:21 +00:00
Ben Gras 0a70e23d1d is - no more getlocktimings. 2011-02-04 13:34:43 +00:00
Ben Gras dc1cc91df1 <ansi.h> -> <minix/ansi.h> 2011-01-28 11:35:02 +00:00
Arun Thomas 6e86430130 Remove code for kernel task stack initialization
We no longer have kernel tasks, so this code is unnecessary
2011-01-27 12:18:33 +00:00
David van Moolenbroek 9b8f37bb27 RS: don't share executable images with a dead process 2011-01-07 17:10:12 +00:00