Commit graph

443 commits

Author SHA1 Message Date
David van Moolenbroek 4b12166f26 VFS: workaround to allow TIOCSCTTY on PTYs
Fix /dev/tty-related issues in tmux(1) by hardcoding the PTY major
in VFS in addition to the TTY major.  Even though this is exactly
what we did NOT want to have to do, the actual fix for this issue
is going to take a little longer.

Change-Id: I24c75eaf688b9ebd28e931f2e445b8442cfdac78
2015-09-01 11:42:03 +00:00
David van Moolenbroek 29e004d23b VFS: make message pointer management more robust
The previous approach of storing pointers to messages structures for
thread-blocking sendrec operations relied on several assumptions,
which if violated could lead to odd cases of memory corruption.
With this patch, VFS resets pointers right after use, avoiding that
any dangling pointers are accidentally dereferenced later.  This
approach was already used in some cases, but not all of them.

Change-Id: I752d994ea847b46228bd2ccf4e537deceb78fbaf
2015-08-31 12:58:39 +00:00
David van Moolenbroek 56ac45c10b VFS: check X bit, not R bit, opening executables
For dynamically linked executables, the interpreter is passed a
file descriptor of the binary being executed.  To this end, VFS
opens the target executable, but opening the file fails if it is
not readable, even when it is executable.  With this patch, when
opening the executable, it verifies the X bit rather than the R
bit on the file, thus allowing the execution of dynamically
linked binaries that are executable but not readable.

Add test86 to verify correctness.

Change-Id: If3514add6a33b33d52c05a0a627d757bff118d77
2015-08-31 12:55:55 +00:00
David van Moolenbroek 9f15e7b366 VFS: tweak coredump wrapper code
Change-Id: I6c1f50910d906b25f6df2b48f2cbfb899850924e
2015-08-31 12:55:48 +00:00
David van Moolenbroek 253dbfc285 VFS: resolve noassert warning
Change-Id: I647f5a7b3c2935be3df032873705be83de9aaffb
2015-08-31 12:55:43 +00:00
David van Moolenbroek 6c31058de4 sched: simplify
- do not use timers when there is only ever one timer;
- do not include kernel header files for no reason;
- do not reply to notifications ever.

Change-Id: I5817e22c1b46c4e30e5135069df318af0b4f87fd
2015-08-31 12:55:30 +00:00
David van Moolenbroek 736b88cf53 DS: fix regex memory leaks
The regcomp(3) calls had no matching regfree(3) calls.

Change-Id: I5250d62e6ab22821aff18bcdc336cb485df6868e
2015-08-31 12:55:18 +00:00
David van Moolenbroek 4472b590c7 libminixfs: rework prefetch API
This patch changes the prefetch API so that file systems must now
provide a set of block numbers, rather than a set of buffers.  The
result is a leaner and more well-defined API; linear computation of
the range of blocks to prefetch; duplicates no longer interfering
with the prefetch process; guaranteed inclusion of the block needed
next into the prefetch range; and, limits and policy decisions better
established by libminixfs now actually being moved into libminixfs.

Change-Id: I7e44daf2d2d164bc5e2f1473ad717f3ff0f0a77f
2015-08-14 18:39:30 +00:00
David van Moolenbroek 6c46a77d95 libminixfs: better support for read errors and EOF
- The lmfs_get_block*(3) API calls may now return an error.  The idea
  is to encourage a next generation of file system services to do a
  better job at dealing with block read errors than the MFS-derived
  implementations do.  These existing file systems have been changed
  to panic immediately upon getting a block read error, in order to
  let unchecked errors cause corruption.  Note that libbdev already
  retries failing I/O operations a few times first.

- The libminixfs block device I/O module (bio.c) now deals properly
  with end-of-file conditions on block devices.  Since a device or
  partition size may not be a multiple of the root file system's block
  size, support for partial block retrival has been added, with a new
  internal lmfs_get_partial_block(3) call.  A new test program,
  test85, tests the new handling of EOF conditions when reading,
  writing, and memory-mapping a block device.

Change-Id: I05e35b6b8851488328a2679da635ebba0c6d08ce
2015-08-14 18:39:26 +00:00
David van Moolenbroek 1311233cfb libminixfs: keep track of block usage
This patch changes the libminixfs API and implementation such that the
library is at all times aware of how many total and used blocks there
are in the file system.  This removes the last upcall of libminixfs
into file systems (fs_blockstats).  In the process, make this part of
the libminixfs API a little prettier and more robust.  Change file
systems accordingly.  Since this change only adds to MFS being unable
to deal with zones and blocks having different sizes, fail to mount
such file systems immediately rather than triggering an assert later.

Change-Id: I078e589c7e1be1fa691cf391bf5dfddd1baf2c86
2015-08-14 18:39:21 +00:00
David van Moolenbroek 0314acfb2d libminixfs: miscellaneous API cleanup
Mostly removal of unused parameters from calls.

Change-Id: I0eb7b568265d1669492d958e78b9e69d7cf6fc05
2015-08-14 18:39:00 +00:00
David van Moolenbroek b8f6d4a649 libminixfs: do not flush blocks that are in use
This removes an implicit requirement for the way the libminixfs API is
to be used, namely that a block is to be marked as dirty only once its
contents have been fully updated, within a single get_block/put_block
window.  The requirement may not be appropriate for all file systems.

Change-Id: I6a129d51b1a5e9aec1572039dc7c1c82dd795db5
2015-08-13 13:46:52 +00:00
David van Moolenbroek cb9453ca63 libminixfs: add support for peeking blocks
With this change, the lmfs_get_block*(3) functions allow the caller to
specify that it only wants the block if it is in the cache or the
secondary VM cache.  If the block is not found there, the functions
return NULL.  Previously, the PREFETCH method would be used to this
end instead, which was both abuse in name and less efficient.

Change-Id: Ieb5a15b67fa25d2008a8eeef9d126ac908fc2395
2015-08-13 13:46:50 +00:00
David van Moolenbroek d75faf18d9 libminixfs: add support for memory-mapped holes
When VM asks a file system to provide a block to satisfy a page fault
on a file memory mapping, the file system previously had no way to
inform VM that the block is a hole, since there is no corresponding
block on the underlying device.  To work around this, MFS and ext2
would actually allocate a block for the hole when asked by VM, which
not only defeats the point of holes in the first place, but also does
not work on read-only file systems.  With this patch, a new libminixfs
call allows the file system to inform VM about holes.  This issue does
raise the question as to whether the VM cache is using the right data
structures, since there are now two places where we have to fake a
device offset.  This will have to be revisited in the future.

The patch changes file systems accordingly, and adds a test to test74.

Change-Id: Ib537d56b3f30a8eb05bc1f63c92b5c7428d18f4c
2015-08-13 13:46:48 +00:00
David van Moolenbroek e94f856b38 libminixfs/VM: fix memory-mapped file corruption
This patch employs one solution to resolve two independent but related
issues.  Both issues are the result of one fundamental aspect of the
way VM's memory mapping works: VM uses its cache to map in blocks for
memory-mapped file regions, and for blocks already in the VM cache, VM
does not go to the file system before mapping them in.  To preserve
consistency between the FS and VM caches, VM relies on being informed
about all updates to file contents through the block cache.  The two
issues are both the result of VM not being properly informed about
such updates:

 1. Once a file system provides libminixfs with an inode association
    (inode number + inode offset) for a disk block, this association
    is not broken until a new inode association is provided for it.
    If a block is freed and reallocated as a metadata (non-inode)
    block, its old association is maintained, and may be supplied to
    VM's secondary cache.  Due to reuse of inodes, it is possible
    that the same inode association becomes valid for an actual file
    block again.  In that case, when that new file is memory-mapped,
    under certain circumstances, VM may end up using the metadata
    block to satisfy a page fault on the file, due to the stale inode
    association.  The result is a corrupted memory mapping, with the
    application seeing data other than the current file contents
    mapped in at the file block.

 2. When a hole is created in a file, the underlying block is freed
    from the device, but VM is not informed of this update, and thus,
    if VM's cache contains the block with its previous inode
    association, this block will remain there.  As a result, if an
    application subsequently memory-maps the file, VM will map in the
    old block at the position of the hole, rather than an all-zeroes
    block.  Thus, again, the result is a corrupted memory mapping.

This patch resolves both issues by making the file system inform the
minixfs library about blocks being freed, so that libminixfs can
break the inode association for that block, both in its own cache and
in the VM cache.  Since libminixfs does not know whether VM has the
block in its cache or not, it makes a call to VM for each block being
freed.  Thus, this change introduces more calls to VM, but it solves
the correctness issues at hand; optimizations may be introduced
later.  On the upside, all freed blocks are now marked as clean,
which should result in fewer blocks being written back to the device,
and the blocks are removed from the caches entirely, which should
result in slightly better cache usage.

This patch is necessary but not sufficient to resolve the situation
with respect to memory mapping of file holes in general.  Therefore,
this patch extends test 74 with a (rather particular but effective)
test for the first issue, but not yet with a test for the second one.

This fixes #90.

Change-Id: Iad8b134d2f88a884f15d3fc303e463280749c467
2015-08-13 13:46:46 +00:00
David van Moolenbroek b65ad59e08 libminixfs: add support for 64-bit block numbers
There are currently no devices out there that require this change.
The change is merely needed to support subsequent changes.

Change-Id: I64214c5f46ff4a2260815d15c15e4a17709b9036
2015-08-13 13:46:44 +00:00
David van Moolenbroek bd851af48f VFS: merge scratchpad into fproc
There is no reason to keep these tightly coupled data structures
separate.  Moreover, there is no reason to have a union of file
descriptor and file pointer, since the second can be derived from
the first.  The result are somewhat cleaner VFS internals.

Change-Id: I854da7d8291177878eecfc3077ef0a9e0cc82aaa
2015-08-13 13:45:02 +00:00
David van Moolenbroek 162f54c289 service(8): no need to include kernel headers
Change-Id: I8fb7a1a58457909b7759a74925a12cf9b11261f0
2015-08-13 13:44:57 +00:00
David van Moolenbroek e9cd054009 Restore and expand NONE_MAJOR comment
This fixes #50.

Change-Id: I318d08e8c57c12cfd409700b14c88a90c81a1715
2015-08-13 13:44:52 +00:00
David van Moolenbroek ec725af4c5 lwip: no need to retrieve own endpoint
Change-Id: I86bd20be9b1aec4116edbe112eb562737860568f
2015-08-08 16:57:14 +00:00
David van Moolenbroek efa7e3e6d2 Kernel: correctly set USE_ defines from Makefile
Without defining these to 1, #if statements on them will fail.

Change-Id: Ifc4824a6ffacc4bebcfd6f1110c864d7eb16401a
2015-08-08 16:56:37 +00:00
David van Moolenbroek a082b2af62 libsys: add Tomas Hruby's asynsend barrier
This barrier ensures that all fields of an asynchronously sent
message are properly initialized before the message is marked as
valid.

Change-Id: I7b9590c11c4e040c8f992f1dd2581e54201bf214
2015-08-08 16:56:20 +00:00
David van Moolenbroek 3091b8cf26 Kernel: fix async message failure handling crash
If an asynchronous message is delivered during an ipc_receive(2) call,
but a failure occurred while copying out the status to the sending
process, then the receiving process would be left in an inconsistent
state, leading to a kernel crash shortly after.

For now, we fix this by altogether ignoring errors while copying out
the status field to the sending process.  While this resolves the
kernel crash, it is hardly ideal, since it will likely cause the same
message to be delivered repeatedly.  It would be better to disable
asynchronous communication from the sender process altogether, but this
solution requires more changes and thus more testing.

Change-Id: Ib00bf01ad29cdd10a5dee731d4788254d9037a76
2015-08-08 16:55:52 +00:00
David van Moolenbroek e10ce184e4 libsys: make tickdelay(3) more reliable
Previously, there was a tiny chance that tickdelay(3) would return
early or that it would fail to reinstate a previous alarm.

- sys_setalarm(2) now returns TMR_NEVER instead of 0 for the time
  left if no previous alarm was set;
- sys_setalarm(2) now also returns the current time, to allow the
  caller to determine whether it got an alarm notification for the
  alarm it set or for a previous alarm that has just gone off;
- tickdelay(3) now makes use of these facilities.

Change-Id: Id4f8fe19a61ca8574f43131964e6f0317f613f49
2015-08-08 16:55:23 +00:00
David van Moolenbroek 8731fd1c47 audio: use standard Makefile structure
The previous approach of including libraries through the parent
directory's Makefile.inc created linking issues, with libchardriver
not finding snprintf in certain cases.  The new approach of including
libraries through the driver's only Makefile is the one used by all
other drivers.

Change-Id: I96e6308e12e54f0fce8ecf58bd061269860d4355
2015-08-08 16:55:03 +00:00
David van Moolenbroek ea69bfc71d tests: resolve new compiler warnings
Change-Id: I57f6602a9fe9e8524f7da4320b0d1a46889b90d6
2015-07-28 14:18:35 +00:00
Jean-Baptiste Boric 1facb0487c libc: add posix_spawn family of functions
The implementation is taken from newlib (BSD licensed) and test84 is based
on NetBSD's t_spawn.c

Change-Id: Ia4e9dd5204a0b4ef241a451978057e11fb29e3d6
2015-07-28 14:18:03 +00:00
Jacob Adams 7b2da7b2c7 update_bootcfg(8): Add actually useful information
Change-Id: I3f1aa2141827b3dc4072f2e8cedeecb40006e626
2015-07-28 10:03:50 +00:00
Jacob Adams e01448dd84 Close #83 with fix suggested
Change-Id: I83975a0963d09eab73df62adf81ce8027ca41bb0
2015-07-28 09:58:12 +00:00
Leonardo Fogel 4796287659 eMMC: add support to 8-bit mode.
Change-Id: I0470130eb5f8de319cd55c448a9aa1b9131e8e07
2015-07-26 15:53:37 +00:00
David van Moolenbroek 3e07920fe2 Import NetBSD syslogd(8)
The primary reason for the import is a likely GPL taint of the
original MINIX3 syslogd.  As a result, this import may still
have some rough edges.

Change-Id: I5c8d26eca10fc2dd50ecc9eab44a1d483cf068a9
2015-07-26 11:57:04 +00:00
David van Moolenbroek 818c405ae1 LOG: fix bugs in userland write handler
- report correct number of bytes written;
- correctly return partial writes on failure;
- do not overwrite result if there is a pending read.

Change-Id: I92aeeaee1eccb47c2aa2b6666a2f560c3cb17f42
2015-07-26 11:56:36 +00:00
Erik van der Kouwe c97d4ff6e5 test83: add test to send strange/wrong UDP and TCP packets
Change-Id: I73444d2753adab140a4f8e6bee2db32282044888
2015-07-22 22:25:09 +02:00
Erik van der Kouwe 17fbdaf514 test82: share support functions in common.[ch] for test83
Change-Id: I3dfeacc3c2c143d3b696efa39a6f257d38281742
2015-07-22 22:24:22 +02:00
David van Moolenbroek da32b6c32e orinoco: retire
This code is MPL-licensed and thus does not belong in the MINIX3
source tree.

Change-Id: I10388b05e90e83b95414cf9b469e50f49bc1db31
2015-07-20 16:55:15 +00:00
David van Moolenbroek 424cad2cd6 VFS: add support for F_DUPFD_CLOEXEC
Change-Id: Ibe422c6c99fe5fd1385884843ff9e15111810309
2015-07-20 13:55:10 +00:00
David van Moolenbroek 6d315cbf9e benchmarks: remove unixbench
This code appears to be GPL-licensed and thus does not belong in
the MINIX3 source tree.

Change-Id: I9e88c3ffd8eae8697b629899dba9728863a4413a
2015-07-20 11:05:28 +00:00
David van Moolenbroek 65b4a7fa8d mkfs.mfs: remove Linux mount check
This code is GPL-licensed and thus does not belong in the MINIX3
source tree.

Change-Id: Ie154f8a4b536df53b840e535283996b545f2bafc
2015-07-20 10:59:49 +00:00
David van Moolenbroek 4a1befb81d tests: remove IPC test set
This code appears to be GPL-licensed and thus does not belong in
the MINIX3 source tree.

Change-Id: I1d1060cd159322398284c6bb9716541819706e95
2015-07-19 17:58:10 +00:00
David van Moolenbroek 85fb986ba7 inet: fix state transitions in driver receipt code
This resolves a problem with ioctl(NIOCGETHSTAT) hanging forever
as identified by Erik van der Kouwe, and possibly many other corner
cases.

Change-Id: I2350c882dc6a0862e16454ec6b6c320d78780bcd
2015-07-17 18:44:39 +00:00
Erik van der Kouwe 86e41e22cf Add test82 (HTTP)
This test connects to a remote HTTP server to retrieve files, using various
chunk sizes and concurrency settings to exercise the network stack. The test
is only performed is USENETWORK=yes. This test requires the following URLs to
remain available: http://test82.minix3.org/test1.txt and
 http://test82.minix3.org/test2.bin. The former contains a 'Hello world'
message followed by a newline, the latter all 16-bit values in increasing
order, using big-endian notation.

Change-Id: I696106482fb1658f9657be2b6845a1b37a3d6172
2015-07-08 09:54:56 +02:00
Erik van der Kouwe 294d159017 Add new tests 80 (TCP) and 81 (UDP)
These new tests are largely based on the code from test 56 (UDS). Common code
is moved into a separate file common-socket.c. In some instances the tests
are too strict for TCP/UDP sockets, which may not always react instantly to
whatever happens on the other side (even locally). For these cases, the
ignore_* fields in struct socket_test_info indicate that there needs to be
an exception. There are also tests where it seems the functionality of inet
is either incorrect or incomplete with regard to the POSIX standard. In these
cases, the bug_* fields are used to document the issues while avoiding
failure of the test.

Change-Id: Ia860deb4559d42608790451936b1aade866faebc
2015-07-08 09:46:56 +02:00
Erik van der Kouwe 3e8d796eaa test48: skip some redundant combinations of parameters
Change-Id: I8ebecf4f61a99c653fd6dc0ae9510d5fd154dd4e
2015-07-08 09:32:17 +02:00
Erik van der Kouwe 3433559c50 test48: move can_use_network function to common code for reuse
Change-Id: I66a5f36f05fa4c4413b3b62c555fa58fbe5d73ea
2015-07-08 09:30:15 +02:00
Erik van der Kouwe c4182e08ab tests: change u32_t to uint32_t for portability
Change-Id: I8ea57fff72c3b3ed02cc9d82ee295069ca299ed9
2015-07-08 09:27:30 +02:00
Erik van der Kouwe 95b9ecf995 test48: Introduce USENETWORK variable.
This patch introduces USENETWORK environment variable to determine whether to
use the network or not, instead of the unreliable ping test; set to 'yes' to
enable network usage.                                                                      

Change-Id: I9e26fa95b5b990fd94f5978db8de0dd73496d314
2015-07-03 09:50:00 +02:00
Erik van der Kouwe 4d5b0de1fb test48: update lookup name from static.minix3.org to test48.minix3.org
Change-Id: Ie8553bee529aeba66a438eab90177551ec44bc07
2015-07-02 19:01:21 +02:00
Lionel Sambuc f837aff6e8 memory: announce presence during startup
Change-Id: Id4724c444bdca9f72fca05edb55d7614eb5c8286
2015-06-29 10:58:01 +00:00
Lionel Sambuc 68afc7715b uds: announce presence during startup
Change-Id: Ibaf2e08e80e2b0c4cf4108fff3866a2bd430ec47
2015-06-29 10:57:54 +00:00
Lionel Sambuc 67b4718325 log: announce presence during startup
Set its restart policy to "reset".

Change-Id: I54f350d9d0d9bc571abd9630f27f4c961c7c0778
2015-06-29 10:57:38 +00:00
Cristiano Giuffrida 64d15bd98e libvtreefs: allow highly dynamic directories
Change-Id: Ibf76262f943ef1a5f529384ebd4a06a2cc5897c1
2015-06-29 10:57:31 +00:00
Cristiano Giuffrida c21aa858e2 libvtreefs: dynamically allocate long inode names
Extended by David van Moolenbroek to continue using static buffers
for short inode names, so as to prevent important file system
services such as procfs from running out of memory at runtime.

Change-Id: I6f841741ee9944fc87dbdb78b5cdaa2abee9da76
2015-06-29 10:57:24 +00:00
Cristiano Giuffrida 5a7def9a94 libvtreefs: fix naming bug
Change-Id: Ib8767cfef4206ed491855bace6dd8bd58b45b8ce
2015-06-29 10:56:59 +00:00
Cristiano Giuffrida a8f606defa procfs: add service pid information
Change-Id: I163ca4c6c6db45cca41515644ac6c2acd0807ee8
2015-06-29 10:56:53 +00:00
David van Moolenbroek f5321d8d55 procfs: do not list inactive services
Each /proc/service entry must have a unique label.  With cloning,
multiple RS services may have the same label.  Since we are not
actually interested in inactive services (for now), eliminate those
entries, leaving only the active service which will then indeed have
a unique label in the list.  This resolves a procfs crash.

Change-Id: I0de7ef8fd186ab13f3e22e46416504fd981c09aa
2015-06-29 10:56:43 +00:00
David van Moolenbroek 0eabb93c0c procfs: retrieve both RS tables from RS at once
Previously, procfs would retrieve the rproc and rprocpub tables from
RS in two separate calls.  This allowed for a race condition where the
tables could change in between the calls, resulting in a panic in
procfs under certain circumstances.  RS now implements a new method
for getsysinfo that allows the retrieval of both tables at once.

Change-Id: I5ec22d25898361270c90e805a43fc6d76ad9e29d
2015-06-29 10:56:30 +00:00
David van Moolenbroek da21d85025 Add PTYFS, Unix98 pseudo terminal support
This patch adds support for Unix98 pseudo terminals, that is,
posix_openpt(3), grantpt(3), unlockpt(3), /dev/ptmx, and /dev/pts/.
The latter is implemented with a new pseudo file system, PTYFS.

In effect, this patch adds secure support for unprivileged pseudo
terminal allocation, allowing programs such as tmux(1) to be used by
non-root users as well.  Test77 has been extended with new tests, and
no longer needs to run as root.

The new functionality is optional.  To revert to the old behavior,
remove the "ptyfs" entry from /etc/fstab.

Technical nodes:

o The reason for not implementing the NetBSD /dev/ptm approach is that
  implementing the corresponding ioctl (TIOCPTMGET) would require
  adding a number of extremely hairy exceptions to VFS, including the
  PTY driver having to create new file descriptors for its own device
  nodes.

o PTYFS is required for Unix98 PTYs in order to avoid that the PTY
  driver has to be aware of old-style PTY naming schemes and even has
  to call chmod(2) on a disk-backed file system.  PTY cannot be its
  own PTYFS since a character driver may currently not also be a file
  system.  However, PTYFS may be subsumed into a DEVFS in the future.

o The Unix98 PTY behavior differs somewhat from NetBSD's, in that
  slave nodes are created on ptyfs only upon the first call to
  grantpt(3).  This approach obviates the need to revoke access as
  part of the grantpt(3) call.

o Shutting down PTY may leave slave nodes on PTYFS, but once PTY is
  restarted, these leftover slave nodes will be removed before they
  create a security risk.  Unmounting PTYFS will make existing PTY
  slaves permanently unavailable, and absence of PTYFS will block
  allocation of new Unix98 PTYs until PTYFS is (re)mounted.

Change-Id: I822b43ba32707c8815fd0f7d5bb7a438f51421c1
2015-06-23 17:43:46 +00:00
David van Moolenbroek 0a2a08739e libfsdriver: clear VM cache only if used
As part of its built-in mmap emulation support for "none" file system
services, libfsdriver clears the VM cache upon exit.  However, for
trivial file systems which do not even support reading from files, the
the VM cache need to be cleared either.  With this patch, the VM cache
is cleared only when modified, so that such trivial file systems need
not be given CLEARCACHE permission.

Change-Id: I518c092443455302b9b9728f10a3f894d2c8036b
2015-06-23 14:38:54 +00:00
David van Moolenbroek 3f30eb69f0 libfsdriver: default to noop for putnode
While putnode requests should always succeed, very simple file system
services may not care about reference counts and thus about putnode
requests at all.  For this reason, we now default to an OK response if
no fdr_putnode implementation is given.

Change-Id: I01f6421abf4546a1f69d8c21900a92d6acc45745
2015-06-23 14:38:28 +00:00
David van Moolenbroek 22840dea11 libfsdriver: preinitialize stat.st_ino
The stat.st_ino field must always be filled with the inode number
given as part of the fdr_stat request anyway, so libfsdriver can
simply fill in the number and allow the file system not to bother.

Change-Id: Ia7a849d0b23dfc83010df0d48fa26e4225427694
2015-06-23 14:38:04 +00:00
Leonardo Fogel 07cbc27cb0 Add a driver for the eMMC on the BeagleBone Black
Change-Id: I30ab36ac048c65538718e372db9502fb8f51d41f
2015-06-21 11:04:16 +00:00
David van Moolenbroek 5055c7ea51 VFS: fix pipe resumption delay bug
Commit 723e513 erroneously removed a yield() call from VFS which was
necessary to get resumed pipe read/write threads to run before VFS
blocks on receive().  The removal caused those threads to run only
once VFS received another message, effectively slowing down activity
on pipes to a crawl in some cases.

Instead of readding the yield() call, this patch restructures the
get_work() code to go back through the main message loop even when no
new work is received, thus ensuring that newly started threads are
always activated without requiring a special case.

This fixes #65.

Change-Id: I59b7fb9e403d87dba1a5deecb04539cc37517742
2015-06-19 22:13:34 +00:00
rlfnb e1e2bc96d2 handle lack of pckbd more gracefully
kb_init() panics, if no keyboard controller is found during self-test.
Instead of panic, the driver should quit the init process and tell it the SEF .

Change-Id: Icdfb7125f5d4062f46cfbbdbbb9e54ac4b273642
2015-06-15 17:11:29 +02:00
David van Moolenbroek af4345b097 isofs: do not link against libc
This change requires a small patch to libc, in order to avoid that
libminc has to pull in a large chunk of libc just for mktime(3).

Change-Id: I48e598b3716eff626cac461f78a41e32334e6b28
2015-06-07 17:01:45 +00:00
David van Moolenbroek 44707c1900 inet: do not link against libc
This should make its printed errors show up again.

Change-Id: I6839a584dc2a544bae7973ded3ab1dacf04e4ec0
2015-06-07 14:38:12 +00:00
David van Moolenbroek dfc3261535 PFS, inet: use static UID to drop privileges
Previously, services would obtain the user ID of "service" through
getpwnam(3).  While this approach is conceptually better, it also
imposes linking against libc which in turn causes problems with
printf(3), which already led to PFS no longer dropping privileges at
all.  For now, we hardcode SERVICE_UID and use that instead.

In the future, two changes should allow removal of SERVICE_UID again:
- "service edit" should cause RS to request that a service (such as
  PFS) drop privileges through SEF, using the user ID resolved by
  service(8), or something similar;
- a future devfs should make it possible for inet to start without
  root privileges altogether.

Change-Id: Ie02a1e888cde325806fc0ae76909943ac42c9b96
2015-06-06 21:42:48 +00:00
David van Moolenbroek 7eb698ea4a VFS: during initial mount, receive but block work
For VFS, initialization is a special case for processing work: PFS
and the ramdisk MFS must be fully mounted before VFS can process any
other requests, in particular from init(8). This case was handled by
receiving reply messages only from the FS service being mounted, but
this effectively disallowed PFS from calling setuid(2) at startup.

This patch lets VFS receive all messages during the mounting process,
but defer processing any new requests. As a result, the FS services
have a bit more freedom in what they can do during startup.

Change-Id: I18275f458952a8d790736a9c9559b27bbef97b7b
2015-06-06 18:45:23 +00:00
David van Moolenbroek 179bddcf5d VFS: fix error behavior for partial pipe writes
This patch fixes two related issues:

- If a large (>PIPE_BUF) pipe write is processed partially, only to be
  followed by a write error condition, then the process is left in an
  incorrect state, possibly causing VFS to crash on a subsequent call.

- If such a partially processed large pipe write ends up resulting in
  an EPIPE error, no corresponding SIGPIPE signal is generated.

The corrected behavior is tested in test68.

Change-Id: I5540e61ab6bcc60a31201485eda04bc49ece2ca8
2015-06-05 18:40:57 +00:00
Jacob Adams d9494baa34 cawf: Update K&R function declarations
Change-Id: Ib18171089c7b389f7f2643d7298f9659e882f65c
2015-05-18 15:20:39 +02:00
Jacob Adams c6748a4a93 cawf: Fix buffer scope
Change-Id: I03f9066c20da142034626b07d0b07c446075b8af
2015-05-18 15:20:36 +02:00
Jacob Adams c14bb31e67 sprofalyze: Fix minor typo
Change-Id: I0a419833fb2f438808613737680ace7246713ee9
2015-05-18 13:54:19 +02:00
Jacob Adams be4841096d Add manpage for sprofdiff
Change-Id: Ifa98ab133ef818d21921f05db650069448ea52ff
2015-05-18 13:52:13 +02:00
Jacob Adams 2a6b817353 Add manpage for sprofalyze
Change-Id: I206a5878e8f788ea4ff742453148462959263a6a
2015-05-18 13:41:29 +02:00
Jacob Adams c19d619d42 Importing bin/dd
Change-Id: Ibdfed821aa834419c9713dc80f698c8ed74ff269
2015-04-15 13:50:57 +02:00
Jacob Adams 3a1943c1c1 devmand: properly prevent overflow
closes #22

Change-Id: Ia10f352a7ff5b05b1095dbb65d36316f9165a6f0
2015-04-15 08:28:59 +02:00
Jacob Adams 1cd28eb8e4 libc: Fix incomplete fprintf
Closes #23

Change-Id: Ibe6362de0d2d1d94442401b92bc126e63bf9f9b0
2015-03-31 15:45:48 +02:00
Thomas Cort 79444d163d mined: increase the size of the tgetent() buffer.
From the termcap section of the GNU termutils manual:

"There is no way you can tell how much space is needed, so the convention
is to allocate a buffer 2048 characters long and assume that is enough.
(Formerly the convention was to allocate 1024 characters and assume that
was enough. But one day, for one kind of terminal, that was not
enough.)"

Change-Id: Ia5937366ae89e886dbaef7d180bee40669d0c488
2015-03-28 08:39:19 +01:00
Thomas Cort 93cdb3a735 mined: move to minix/usr.bin/mined
As suggested in issue #43.

Historic Locations:

Prior to this commit

  minix/commands/mined

Prior to commit 433d6423c3

  commands

Change-Id: I374ab3ff0e3b9e47779fc21e80b47fda87698242
2015-03-28 08:39:10 +01:00
Thomas Cort e6df9032b3 mined: remove !__STDC__ code blocks.
__STDC__ is used to mitigate the differences between K&R C and the
ANSI C standard. Nearly every compiler now supports ANSI C, so
there is no need to support non-standard compilers.

Change-Id: Ifc3381ecf1c43dfde9004bee48552d8b3ac4dcdc
2015-03-28 08:38:56 +01:00
Thomas Cort f3734d6b31 mined.h: use '\a' instead of ascii code for bell.
Makes the code slightly more portable and readable.

Change-Id: I45bbecb6dc1c320c9412eeeaf598116c2ce1aac5
2015-03-28 08:38:48 +01:00
Thomas Cort e978660932 mined: built without UNIX defined.
* Remove undef NULL, EOF, getchar, putchar
* Rename putchar, getchar, _putchar, _getchar to putch, getch, _putch,
  _getch to avoid conflict with libc functions.
* Rename UP() to UP1() (for UP 1 line) to avoid conflict with UP
  definition in termcap.h. Rename DN1 LF1 RT1 for consistency.
* Add termcap.h for prototypes for tputs and friends.
* Add libterminfo references to Makefile
* Add return value to _putch() to make it work as tputs expects.
* Make putch() call _putch()
* Remove UNIX ifdefs and all code in the !UNIX branches.

closes #43

Change-Id: I0a6f7298aa8b12a74225badc88d3c236a02669ea
2015-03-28 08:38:33 +01:00
Thomas Cort fc850d580c man: clean-out man1x category.
Removes the following man pages:

* awk.1x -- for a version of awk we no longer have
* kermit.1x -- seems gone altogether
* macros.1x -- not useful for anyone anymore

Moves the following man pages:

* mined.1x -- Moved to minix/commands/mined/mined.1
and reformatted to use the mdoc macros instead of the
Minix macros so that it displays properly.

Removes /usr/man/man1x from the directory tree.

closes #44

Change-Id: I59b8bd54cf5cba6d188e51e99a92b36e90c275c1
2015-03-25 06:53:44 +01:00
Thomas Cort d1a87c1f64 mined: clean-up trailing whitespace.
Change-Id: Ic27293d7e1d0f830d635b78e7e620dcf0ef3e03f
2015-03-24 14:03:03 +01:00
Thomas Cort d131b58784 mined1.c: remove i386 guard around escape sequences.
The escape sequences for the function keys used to be separated
out in older versions of Minix when they were different for m68k
and intel. Support for m68k was dropped and that code was
removed, leaving the ifdef i386. Since the sequences are the
same for i386 and arm, there is no need to keep the ifdef i386.

Change-Id: Id96a80bcb24da120efa63acc9b248d87fc347eac
2015-03-24 14:03:03 +01:00
Thomas Cort 6a0aa6fb5e mined.h: remove irrlevant comment.
It used to refer to several NIL_* definitions. Those were removed
in commit 6e25ad8b0a leaving the
comment with nothing to comment on.

Change-Id: I52221ae5d2c5216e82391b480cf2038ad723b8f0
2015-03-24 14:03:02 +01:00
Thomas Cort 0cf05b213d mined.h: remove unused definition, MEMORY_SIZE.
Change-Id: I1ae83c427cafb15f1382b7d8ab3871a36b0eec28
2015-03-24 14:03:02 +01:00
Thomas Cort 50d246bbba mined.h: remove minix/config.h include.
Nothing defined there is used by mined.

Change-Id: I38b692be1313aaed316eebd7caf8e879178d90dc
2015-03-24 14:02:41 +01:00
Jacob Adams d82c151c9e commands/fix: create manpage for fix(8)
Change-Id: I868f1338994d6cc2cba6789b9b4e8934610d0142
2015-03-24 08:21:14 +01:00
rlfnb 31ba042920 Fix boot if no pckd device is there
Trying to boot Minix3 master on an appliance/sbc like ALIX fails, as
the service command throws an error. Making the rc script more robust
solves it.

Change-Id: I659043cbbaa2d67b70d6d6e5ab14fff8e1bba769
2015-03-23 14:57:06 +01:00
Jacob Adams 80c94e3974 swifi: Fix incorrect memset
Change-Id: I6764aff558f51cdb90b91a3e71c982e8b3f47058
2015-03-23 14:56:59 +01:00
Jacob Adams f113a7238f Make rotate manpage more detailed
Change-Id: I028550c17b87655a6e39a7f8b3233cbe982883eb
2015-03-23 11:06:37 +01:00
Christian Koch 6f55e9f11d nonamed.8: Document the -L option.
Change-Id: I1aadb50cd416e0467a87c8d75db1c293333a7969
2015-03-19 10:00:56 +01:00
Jacob Adams 271999a2f3 Do not read past the end of the buffer
closes #22

Change-Id: I239c670915d98440c176ccf23e5270c40c4fbe81
2015-03-18 08:29:46 +01:00
Jacob Adams e3cf9c04f1 properly check if configuration file is opened
closes #21

Change-Id: I2f83b5385ac38bf07d30acb14f40c14bec476830
2015-03-18 08:25:19 +01:00
Jacob Adams 3bdcd28869 Get rid of K&R functions in recwave
Change-Id: I98cf0426aedf03ec0312f58ff77b816fd231eb84
2015-03-18 08:21:31 +01:00
Jacob Adams 25223c2ae2 Check argc is greater than 1 before using on argv
closes #19

Change-Id: I50ee3fa82bce274e710434628b6c178467fd3887
2015-03-18 08:20:08 +01:00
Emmanuel Blot 41b870c890 arm: Make sure __k_unpaged_MINIX is first
Do not rely on build order to set startup symbol (`__k_unpaged_MINIX`)
at kernel binary start

Change-Id: I1ed3f9309fe66ff97e24915938c114d5a159deaf
2015-03-18 07:50:31 +01:00
Emmanuel Blot 54841c0102 Fix incorrect sanity check
Remove invalid sanity check where an array is tested against NULL -
not a pointer

Change-Id: I3d5e33585e7f97a41124af4133e8a879ab21d972
2015-03-18 07:49:44 +01:00
Emmanuel Blot d91890d288 Fix format string for size_t types
Fix missing “%z[dux]” prefix printf formatter string for `size_t`
types.

Change-Id: If216a778b0b65e8ab2cdd1c7484cb8452d1f965d
2015-03-18 07:48:09 +01:00
Jacob Adams 61890c3b2e Change rotate.sh BZIP2 to the correct path
closes #8

Change-Id: I90cb30e3d8ee2c000aca36fb9f8cc22c6d49583e
2015-03-14 16:43:04 +01:00
Jacob Adams 1b6a97c9c0 commands/autopart: Fix dead code block
Fix dead code block, make surrounding code more readable, and remove
unused mode variable.

closes #20

Change-Id: I802e3d8680d7a7adc7acd580bfcec9dc28af0bc4
2015-03-13 18:53:05 +01:00
Jacob Adams dc0077241b Use or instead of and to determine if urb is valid
close #24

Change-Id: I12e2b20d69aa7b186a8e5cd0dc16f653a18b2ee2
2015-03-11 17:56:09 +01:00
rlfnb 7171c2321f Maybe a broken bios/device setting
Removing the panic leads to exactly one message on ALIX. Both commits
make minix out of the box booting on ALIX devices.

Change-Id: I9210fef79a8736e36b9c42c7925c9f3354c60e7c
2015-03-11 13:46:45 +01:00
rlfnb b56a9d4725 ALIX: No pci device at bus 0, dev 0, func 0
Seems like its a kind of convention introduced by Intel but not
mandatory from a PCI specification point of view, that the PCI host
controller resides on bus 0, device 0 function 0. At least tinybios
(the bios used by ALIX and WRAP) based appliances are not able to boot
with this change.

Change-Id: I0e45c68c482972be7276028525985de920cf64f7
2015-03-11 13:46:41 +01:00
Lionel Sambuc 3d0f2c86c4 Fix arm build for GCC, noassert, -Os
Change-Id: I706fdfc8fc9a5e0c9076e3657ac1a6ef0745bd14
2015-03-05 15:42:21 +01:00
David van Moolenbroek f912036bae libsffs, libvtreefs: fix getdents bug
Bad logic introduced as part of the fsdriver changes could cause
getdents to terminate early in these libraries.

Issue reported by r0ller.

Change-Id: If450d5ea85e830584878d8a4ec0f00519355a353
2015-02-10 13:47:29 +00:00
David van Moolenbroek 75e18fe498 Add 3c90x: 3Com 3C90xB/C network driver
Change-Id: Iba0bbcb3b1b69a7c204abdc81cf3afe59b6bfaae
2015-02-10 13:47:28 +00:00
David van Moolenbroek 2a3bc70264 ACPI: OS-dependent code tweaks
Change-Id: I533685f6716cb48ccf3d5ca5ef0fb681a5293549
2015-02-10 13:47:28 +00:00
David van Moolenbroek 29492bb71c ACPI: upgrade to acpica-unix2-20141107
Change-Id: I96151a2756fd9814bfba180548e8a96dca63ce51
2015-02-10 13:47:27 +00:00
David van Moolenbroek f202792edf VM: fix for handling one-shot page memory
The original one-shot page patch (git-e321f65) did not account for the
possibility of pagefaults happening while copying memory in the
kernel.  This allowed a simple cp(1) from vbfs to hang the system,
since VM was repeatedly requesting the same page from the file system.

With this fix, VM no longer tries to fetch the same memory-mapped page
from VFS more than once per memory handling request from the kernel.
In addition to fixing the original issue, this change should make
handling memory somewhat more robust and ever-so-slightly faster.

Test74 has been extended with a simple test for this case.

Change-Id: I6e565f3750141e51b52ec98c938f8e1aa40070d0
2015-02-10 13:47:27 +00:00
Thomas Goering e1131d9c96 recognize Intel 82540EP LP by e1000
Change-Id: I8868963ba09ce1dffa9416c9ece29c7315dee4cd
2014-12-12 21:28:06 +01:00
Ben Gras 5ae1a533c7 ARM: can build with llvm, switch to EABI
. bitcode fixes
	. switch to compiler-rt instead of netbsd libc functions
	  or libgcc for support functions for both x86 and arm
	. minor build fixes
	. allow  build with llvm without crossbuilding llvm itself
	. can now build minix/arm using llvm and eabi - without C++
	  support for now (hence crossbuilding llvm itself is turned off
	  for minix/arm)

Change-Id: If5c44ef766f5b4fc4394d4586ecc289927a0d6eb
2014-12-12 13:04:56 +01:00
Lionel Sambuc 41ba8c04cc Restart policies: Add testing and ProcFS DB
- Expose in procfs the service status and supported recovery policies.
 - This adds a test (testrelpol.sh) to exercise the restart policies of
   the system services and drivers.

NOTE:
  The policy support information is temporarily hardcoded in ProcFS, but
  this has to be replaced by properly retrieving this information from
  RS, which should in turn be setup on a per service basis, at
  initialization time.

Change-Id: I0cb1516a450355b38d0c46b1a8b3d9e841a2c029
2014-12-10 23:11:25 +01:00
David van Moolenbroek 5260f07c2c virtio_net: use new libnetdriver
Change-Id: Id06bdb67da12477984b42bbd46623bd8f25c0ab9
2014-12-04 12:10:52 +00:00
David van Moolenbroek d76bd1f07c rtl8169: use new libnetdriver
Change-Id: Ia26b6c440a1525f1d2bb9e7592e357dac0ba602c
2014-12-04 12:10:52 +00:00
David van Moolenbroek 4081bff625 rtl8139: use new libnetdriver
Change-Id: Iba941653b7c052375694bcec2561957c1979feb0
2014-12-04 12:10:51 +00:00
David van Moolenbroek bcc1b08c61 orinoco: use new libnetdriver
Change-Id: I003590539dd76f4be8e067f986bb1f17b151490d
2014-12-04 12:10:51 +00:00
David van Moolenbroek 6315775f16 lance: use new libnetdriver
Change-Id: If3414088e66407c688c4960f99a165b0ee1ebc83
2014-12-04 12:10:51 +00:00
David van Moolenbroek 5af3c2565f lan8710a: use new libnetdriver
Change-Id: Iaee4d75a5dfafc72d94f0b02681f9aea1c9da535
2014-12-04 12:10:50 +00:00
David van Moolenbroek 96e62d65b6 fxp: use new libnetdriver
Change-Id: I03268655a5daff3d109ae52e64673911ef096a3f
2014-12-04 12:10:49 +00:00
David van Moolenbroek 1ad10e3ae0 e1000: use new libnetdriver
Change-Id: I111750d2ca27f01039d0b427b1314aea861e2074
2014-12-04 12:10:49 +00:00
David van Moolenbroek 91c4db251e dpeth: use new libnetdriver
Change-Id: Ic389e54817c5b241dad851c89ef1cf16c015a79b
2014-12-04 12:10:49 +00:00
David van Moolenbroek 3913e49004 dp8390: use new libnetdriver
Change-Id: Ieaf6d605832d475f95fd9b06026b349dce7ee025
2014-12-04 12:10:49 +00:00
David van Moolenbroek 29018b4ecd dec21140A: use new libnetdriver
Change-Id: I54be3b770e4d1fd320200c30e9e9073a7c1b405b
2014-12-04 12:10:48 +00:00
David van Moolenbroek b80fc5be89 atl2: use new libnetdriver
Change-Id: I65de5d29a75d5f3101b2c5ab16a4b0d79bd77cc3
2014-12-04 12:10:48 +00:00
David van Moolenbroek dbcce9ddb0 libnetdriver: turn into network driver framework
The new implementation of this library provides abstractions for
network drivers, and should be used for all network drivers from now
on.  It provides the following functionality:

  - a function call table abstraction, hiding the details of the
    datalink protocol with simple parameters;
  - a state machine for sending and receiving packets, freeing the
    actual driver from keeping track of pending requests;
  - an abstraction for copying data from and to the network driver,
    freeing the actual driver from dealing with I/O vectors while at
    the same time providing a copy implementation which is more
    efficient than most current driver implementations;
  - a generalized implementation of zero-copy port-based I/O;
  - a clearer set of policies and defaults.

While the concept is very similar to lib{block,char,fs,input}driver,
one main difference is that libnetdriver now also takes care of SEF
initialization, mainly so that aspects such as recovery policies and
live-update aspects can be changed for all network drivers in a
single place.  As always, for the case that the provided message loop
is too restrictive, a set of more low-level message processing
functions is provided.

The netdriver API has been designed so as to allow alleviation of one
current protocol bottleneck: the fact that at most one send request
and one receive request may be pending at any time.  Changing this
aspect will however require a significant rewrite of libnetdriver,
and possibly debugging of drivers that are not able to cope with (in
particular) queuing multiple packets for transmission at once.

Beyond that, the design of the new API is based on the current
protocol, and may be changed/extended later to allow for non-ethernet
network drivers, exposure of link status, multicast address
configuration, suspend and resume, and any other features that are in
fact long overdue.

Change-Id: I47ec47e05852c42f92af04549d41524f928efec2
2014-12-04 12:10:48 +00:00
David van Moolenbroek 107df7c8fa e1000: convert to KNF
Change-Id: Ibd156c2e0a58fed70895080d4b230b26c500fa11
2014-12-04 12:10:48 +00:00
David van Moolenbroek 1539606d98 atl2: convert to KNF
Change-Id: Ie4b979aab3127a91a12b8086326da0eb1f9a860b
2014-12-04 12:10:47 +00:00
David van Moolenbroek d1db724f47 libvirtio: expose result size on packet dequeue
Change-Id: I49304678895779849abc2528a9f78730f968e712
2014-12-04 12:10:47 +00:00
David van Moolenbroek a810336026 orinoco: restore register memory mapping
Untested.

Change-Id: I439f0e711e16ba478dadf57ffc8ad74ec19ea1b9
2014-12-04 12:10:47 +00:00
David van Moolenbroek 2e5374621d fxp: enable bus mastering if needed
This is required for at least QEMU.  However, as of writing, QEMU also
requires fixes in its epro100 emulator before this driver can use it.

Change-Id: Ie5c5ffe4311b1a0e581bc687f1c15de3a85f4a30
2014-12-04 12:10:47 +00:00
David van Moolenbroek 92293fafd3 e1000: fix unaligned register access
This resolves a guru meditation in recent VirtualBox versions.

Change-Id: I5034d8af1fe885adda3c027cb23563bffaccf97e
2014-12-04 12:10:46 +00:00
David van Moolenbroek 4bf270019a dp8390: update, allow default port and IRQ
Bochs has switched from port base 0x240 to 0x300 for its default
NE2000 ISA configuration, and QEMU is using the same settings.

Change-Id: Ide6cdb14321eb4324d0bf6d6314c5970b3493e95
2014-12-04 12:10:46 +00:00
David van Moolenbroek cc5b198875 UDS: move from drivers/net/ to net/
Change-Id: I53992b205e767a77c7b3c868a38c7f3d772a4ed3
2014-12-04 12:10:46 +00:00
Ben Gras 3c8950cce9 minix/ changes for arm llvm build
. fixes needed to build Minix/ARM with LLVM without errors,
	  mostly size_t cleanness

Change-Id: If4dd0a23bc5cb399296073920a8940c34b4caef4
2014-12-03 23:40:56 +01:00
Lionel Sambuc 0805ab8cfd Import a few manpages
The following manpages where contributed by
Jacob Adams <tookmund@gmail.com>:
 - atnormalize.8
 - autopart.8
 - decomp16.1
 - devsize.8
 - rawspeed.8
 - rotate.8
 - update_bootcfg.8
 - updateboot.8

Change-Id: Ide3abf0962083b83e37426e2d47f3a9391d6315e
2014-11-25 11:04:20 +01:00
Ben Gras 3a9e392b3a remove unused PSW restore code
. now done in-kernel so IOPL gets restored

Change-Id: I9905d2844a4715004054a788613ff7efd02a227d
2014-11-25 10:51:01 +01:00
Ben Gras c9278f9170 restore PSW like 9393439a20 for AMD syscall
Change-Id: Ide0a8727af8d0d81361382dbd2460c7a6c5743fc
2014-11-24 12:05:45 +01:00
David van Moolenbroek 65eccd1f74 inet: detect short TCP option lengths
Previously, a TCP option length of zero would cause inet to end up
in an infinite loop.

This resolves #7, reported by Alejandro Hernandez.

Change-Id: I45ad4c789d10d8e202cf6e140a7b9db7a6543c75
2014-11-18 12:53:18 +00:00
David van Moolenbroek aa4ee93d43 dhcpd: don't crash so easily
The jump-to-start hack is not resetting global variables, resulting in
a crash after several such restarts cause an overflow in the network
table.  This patch fixes that particular issue, but more similar
issues (in particular memory leaks) are bound to come up.  As such this
is a stopgap measure until we can get rid of the old dhcpd altogether.

This resolves the additional issue reported in #2.

Change-Id: Ic4cd80eae520cf2b97e893bac63b3ab1ecfea6d8
2014-11-17 20:17:43 +00:00
David van Moolenbroek b49f4cacde rtl8139: enable bus mastering if needed
This resolves #2.

Change-Id: Ie6736f0d5a713025f09c18de7042ba44fbb1b2f8
2014-11-17 19:23:00 +00:00
David van Moolenbroek e321f65582 libfsdriver: support mmap on FSes with no device
This patch adds (very limited) support for memory-mapping pages on
file systems that are mounted on the special "none" device and that
do not implement PEEK support by themselves.  This includes hgfs,
vbfs, and procfs.

The solution is implemented in libvtreefs, and consists of allocating
pages, filling them with content by calling the file system's READ
functionality, passing the pages to VM, and freeing them again.  A new
VM flag is used to indicate that these pages should be mapped in only
once, and thus not cached beyond their single use.  This prevents
stale data from getting mapped in without the involvement of the file
system, which would be problematic on file systems where file contents
may become outdated at any time.  No VM caching means no sharing and
poor performance, but mmap no longer fails on these file systems.

Compared to a libc-based approach, this patch retains the on-demand
nature of mmap.  Especially tail(1) is known to map in a large file
area only to use a small portion of it.

All file systems now need to be given permission for the SETCACHEPAGE
and CLEARCACHE calls to VM.

A very basic regression test is added to test74.

Change-Id: I17afc4cb97315b515cad1542521b98f293b6b559
2014-11-15 11:19:52 +00:00
David van Moolenbroek 289b04677a libfsdriver: prefill st_dev for stat requests
This obviates the need for several file system implementations to
remember the device on which they are mounted.

Change-Id: Ida8325cf4bcf072e61761cfee34e3f7ed2d750b9
2014-11-14 15:54:16 +00:00
David van Moolenbroek 31b6611abf procfs: add /proc/service directory
This directory is filled dynamically with regular files, one for each
service that RS knows about, named after its label.  Its contents are
still subject to (heavy) change, but currently expose the service's
endpoint and number of restarts so far.

Change-Id: Ie58c824bcb6382c8da7a714e59fee87329970b4b
2014-11-12 12:13:53 +00:00
David van Moolenbroek f1abbce725 procfs: convert to KNF
Change-Id: Ib4252f199af0f9597745dcd2c11a7f761738671f
2014-11-12 12:13:47 +00:00
David van Moolenbroek 52be5c0afb libvtreefs: API changes/extensions, part 2
- rename start_vtreefs to run_vtreefs, since the function returns upon
  termination these days;
- add get_inode_slots function to retrieve the number of indexed slots;
- add support for extra per-inode data for arbitrary storage.

Change-Id: If2d365d7b478a1cecc9e20fb2b3e70c1a1cf7243
2014-11-12 12:13:43 +00:00
David van Moolenbroek 5eefd0fec2 libvtreefs: API changes/extensions, part 1
- move primary I/O buffer into vtreefs; change read hook API;
- add hooks for write, truncate, symlink, mknod, unlink, chmod/chown;
- modernize message_hook;
- change procfs, devman, gpio accordingly;

Change-Id: I9f0669e41195efa3253032e95d93f0a78e9d68d6
2014-11-12 12:13:38 +00:00
David van Moolenbroek 693ad767e8 libvtreefs: convert to KNF
Change-Id: I81bdf05c9b630a0cbb0ac573d36d4f59f8137199
2014-11-12 12:13:33 +00:00
Emmanuel Blot f92baba71c Fix bad cast from u16_t to ssize_t 2014-11-12 12:13:28 +00:00
David van Moolenbroek 7ee000e54a procfs: compile in x86 support only for x86 target
Issue reported by Emmanuel Blot.

Change-Id: I7f5b1b65273e6ac841d5451e0be7b0e1c92d537c
2014-11-12 12:13:23 +00:00
David van Moolenbroek a8a812ef6a test76: increase alarm times
The test would sometimes fail because an alarm triggered before the
system call to be interrupted by the alarm could be started.

Change-Id: Ia507720a1f2d259afde1f97b7edd03f22cbd4810
2014-11-12 12:12:40 +00:00
David van Moolenbroek 8b18d03deb trace(1): document how to add an IOCTL handler
Also fix two small IOCTL-related bugs:
- do not print an argument pointer for argument-less IOCTLs;
- print IOCTL contents with -V given once, just like structures.

Change-Id: Iec7373003d71937fd34ee4b9db6c6cec0c916411
2014-11-12 12:02:29 +00:00
David van Moolenbroek 92601f58cb ext2: perform super I/O with contiguous memory
Issue reported by Antoine Leca.

Change-Id: Ie6f3ab6c1943b0b7ea9d5a68d4c24b92bab17233
2014-11-11 21:43:55 +00:00
Ben Gras f53651de01 VM,MFS: better handling of some exceptional cases
Fix for problems reported by Alejandro Hernández:
	. VM unmap: handle case where there is no nextvr

Fixes for problems found by running Melkor ELF fuzzing tool:
	. VM: better handle case where region prealloc fails by
	  freeing memory that was allocated so far
	. MFS fs_readwrite: EOF check should happen for read and
	  peek requests, not just read

This fixes #4.

Change-Id: I2adf4eebdfb4c48a297beff0478eed5c917a53a4
2014-11-10 17:51:57 +01:00
Lionel Sambuc 9e77ef5013 Enhancing /proc/pci
- Adding missing fields for PCI device lookup
 - Adding the domain (for now set to zero) as part of the slot name

Change-Id: Iebaf3b21f6ab5024738cbc1dea66d5ad3ada175d
2014-11-10 14:43:27 +01:00
Lionel Sambuc 5d8311761a Turn PCI into a character driver
Change-Id: Ia9c83af4d52e82e845b6a847c3e82e33d1920ae0
2014-11-10 14:43:27 +01:00
Lionel Sambuc 3641562f44 Use NetBSD PCI ID DB
Change-Id: I3fcbce5983b4e0b45e6cc8fac076947c6a84928d
2014-11-07 16:20:39 +01:00
Lionel Sambuc 6e7bb62853 PCI driver cleanup
- Moved to KNF
 - Whitespace cleanup
 - Removed useless static functions prototypes
 - Renamed some file private functions by prepending '__'
 - Renamed some server-specific function by prepending '_'
 - Fixed compilation warning for WARNS= 3

Change-Id: Ie44d35839177d5ee0630cdf576660c852452ab80
2014-11-07 16:20:39 +01:00
Lionel Sambuc 3d3105466a PCKDB: Fix PS/2 Mouse support.
Change-Id: I2240b47ca47a3db7268b47e9e5881d8200c68531
2014-11-07 16:20:39 +01:00
Lionel Sambuc 9393439a20 Fix iopl flag when sysenter/exit are used
Change-Id: If8c12f987c3adb8f329ae163da6b2f1cb8cc772f
2014-11-07 16:20:39 +01:00
David van Moolenbroek 521fa314e2 Add trace(1): the MINIX3 system call tracer
Change-Id: Ib970c8647409196902ed53d6e9631a1673a4ab2e
2014-11-04 21:46:31 +00:00
David van Moolenbroek cb3a6387c8 VM: fix returning VFS error code for mmap
Change-Id: Ifcaa15fb8277be53515eb18c4f86a306c52d91d6
2014-11-03 11:19:08 +00:00
David van Moolenbroek 1f945e8080 Fix fcntl(F_[GS]ETNOSIGPIPE) semantics
The new semantics should match those of NetBSD and other systems.

Change-Id: Ic9ca9d6b8c3e42d2a2953d9feea5f6bacaceb43c
2014-11-01 12:57:31 +00:00
David van Moolenbroek 10b1b4ee12 devman: allow multiple event read calls up to EOF
Read calls may be repeated by VFS if the user destination memory is
not mapped in.  Devman currently assumes that all reads are
successful, and uses this to track whether EOF has been reached for
a particular event, discarding it as soon as this happens.  Upon
repetition, this may result in lost events for devmand.

With this patch, devman discards events only once devmand reads the
EOF marker, which itself can never generate a user page fault.  The
result is that read calls for data can be repeated safely, without
the risk of losing events in the process.

Change-Id: I9dfdf7f8c8992a20a10302d79c3506e61f8564b0
2014-10-28 14:43:33 +00:00
David van Moolenbroek 65f76edb8f minix libraries: resolve clang warnings
Change-Id: I0f3425fb8838708c9848a006f1eee5ab1bad71d2
2014-09-30 21:04:09 +00:00
David van Moolenbroek 5dd8da10c5 libc: resolve minix clang warnings
Change-Id: If6c42f7346cc1b00b387ae8d3b4f0df3ffb0244f
2014-09-30 20:35:56 +00:00
David van Moolenbroek 685aa79304 libsys: resolve clang warnings
Change-Id: Ic954ba8667b4d039172b8e0d2ec57674a479b8aa
2014-09-30 20:08:54 +00:00
David van Moolenbroek d794ecc9ef Replace NetBSD grep with OpenBSD grep
The NetBSD version is seriously broken--it is unable to match lines
against an empty pattern--and appears to be unmaintained.

The new version is the latest OpenBSD grep, with a number of MINIX-
specific changes marked as such, and an additional number of
(signed/unsigned, const) fixes to pass compilation.

Since this is not NetBSD code, move back the entire thing into
minix/usr.bin.

Change-Id: Icd40794a2d0cff9e7fb452db7d28c16dbd25e51d
2014-09-30 18:09:56 +00:00
David van Moolenbroek 94e65446c4 libsffs: make path names constant
And a few other related warning fixes.

Change-Id: I1a49b9ee04c2b1bf80bc943272f72ffd6de77ef6
2014-09-30 12:48:10 +00:00
David van Moolenbroek 1dcfbcd173 Remove support for call profiling
The entire infrastructure relied on an ACK feature, and as such, it
has been broken for years now, with no easy way to repair it.

Change-Id: I783c2a21276967af115a642199f31fef0f14a572
2014-09-30 12:39:03 +00:00
David van Moolenbroek e5808135dd test56: fix race condition
Change-Id: I42bfe2b150e92f760794b4a03e62859c8bd7a992
2014-09-29 16:16:36 +00:00
David van Moolenbroek cbc8a0df90 tests: fix clang warnings
Change-Id: I5dddc85169d7ef515c99dd1ab824573cbc1b5f2b
2014-09-29 16:16:32 +00:00
David van Moolenbroek e296281ce2 VFS: do not make cloned devices setuid/setgid
Change-Id: Ifd97444dd54334ccbc8780df9473450998ab7489
2014-09-29 16:16:27 +00:00
David van Moolenbroek 6990e61341 Remove obsolete MIOC(UN)MAP requests
Change-Id: I915ac759bc80a50aad21c12f088ad6c345a42986
2014-09-29 16:16:22 +00:00
David van Moolenbroek f737eea636 svrctl(2) update
- synchronize request type with ioctl by making it unsigned long;
- unbreak VFS requests, as they were being sent to PM;
- use proper ioctl direction flags (and new numbers) for requests;
- remove some needless header inclusions;
- svrctl is in libc, make its message name reflect this;
- keep backward compatibility: svrctl is part of the userland ABI.

Change-Id: I44902e8d0d11b8ebc1ef3bda94d2202481743c9b
2014-09-29 16:15:21 +00:00
David van Moolenbroek 347cc10a91 VFS/FS: putnode count need not be 64-bit
Change-Id: I49e67438d3f316e0321ac711494e988bb6510679
2014-09-29 15:14:02 +00:00
David van Moolenbroek 63ce03db66 IOCTL requests are unsigned longs now
Issue reported by JD Begin.

Change-Id: I0306d9dc43c36107897c8b73ed340d86a8dcef27
2014-09-29 15:11:01 +00:00
AndrewEdwards e3fd605f72 Create new colemak minix keymap.
Change-Id: I3464e723bd6bb578f415dfe78540e60b2eefb8b7
2014-09-29 00:39:25 +02:00
Sky Liu ca78167b44 Porting grep from NetBSD
Change-Id: I6fa9e3c0a4edc4d3ff292dc5c96ac16b34d7c792
2014-09-24 15:33:57 +02:00
David van Moolenbroek 3a40bab785 tests: reenable testisofs
Change-Id: Ic0883f8b487390e34f1a27e324b033a8cbe2cfff
2014-09-18 13:01:13 +00:00
David van Moolenbroek ef9dc93f44 Clean up obsolete FS support routines
Change-Id: I56d0ab51f32064bb964051732de7e2465dc22b75
2014-09-18 13:01:02 +00:00
David van Moolenbroek c2f99d7c3a isofs: rename source directory to "isofs"
Change-Id: Ibe630f720b4399e7ebbbd850650036fbaa9cec7b
2014-09-18 13:00:57 +00:00
David van Moolenbroek edfcb02885 isofs: basic improvements
- fix for "out of extents" panic;
- return ENOENT when a file name does not exist;
- inode count sanity check upon unmount.

Change-Id: Icb97dbaf7c8aec463438f06b341defca357094b2
2014-09-18 13:00:52 +00:00
David van Moolenbroek e2dc2c8954 isofs: use libdriver
Change-Id: I5ced800eec92f651f31d9c77c3129fe837ca4614
2014-09-18 13:00:47 +00:00
Jean-Baptiste Boric 3e08d38e8e iso9660fs: rewrite ISO 9660 file system server
iso9660fs has been cleaned up and debugged. It now supports:
 * ISO 9660 Level 3,
 * System Use Sharing Protocol (SUSP),
 * Rock Ridge Interchange Protocol (RRIP).

The following Rock Ridge features are supported:
 * POSIX file attributes (PX),
 * POSIX device number (PN),
 * Symbolic links (SL),
 * Alternate file name (NM),
 * Timestamps in 7-byte format (TF).

Change-Id: Ib227411bdda5bc10a957b27ad05fafdc95eca35f
2014-09-18 13:00:42 +00:00
David van Moolenbroek 1858c65d72 Revert "Temporarily disable the is9600 FS server"
This reverts commit ab5c98ee5a.
2014-09-18 12:59:18 +00:00
David van Moolenbroek 8ca6466a71 writeisofs: set file struct version field to one
Dictated by the spec and correctly flagged by the new isofs code.

Change-Id: Ie155c30b6a53e40ec42066af0adbcdbf457e5620
2014-09-18 12:46:29 +00:00
David van Moolenbroek 30d9b70391 PFS: rewrite, restyle
- remove the buffer pool, inode bitmap, and inode hash table, and
  simplify the code accordingly;
- use theoretically slightly more optimal buffer management;
- put the entire source in one file, instead of having many files
  with one or two functions each;
- convert the code to KNF style.

Change-Id: Ib8f6f0bd99fbc6eb9098fba718e71b8e560783d9
2014-09-18 12:46:28 +00:00
David van Moolenbroek f859061eaf PFS: use libfsdriver
In order to avoid creating libfsdriver exceptions, two changes to VFS
are necessary:

- the returned position field for reads/writes is no longer abused to
  return the new pipe size; VFS is perfectly capable of updating the
  size itself;
- during system startup, PFS is now sent a mount request, just like all
  other file systems.

In proper "two steps forward, one step back" fashion, the latter point
has the consequence that PFS can no longer drop its privileges at
startup.  This is probably best resolved with a more general solution
for all boot image system services.  The upside is that PFS no longer
needs to be linked with libc.

Change-Id: I92e2410cdb0d93d0e6107bae10bc08efc2dbb8b3
2014-09-18 12:46:28 +00:00
David van Moolenbroek 2e89653e65 libc: make socketpair(3) use the right device
UDS expects the device number of the actual socket, not the device on
which the socket happens to reside.  The code worked only because PFS
returned the same value in the st_dev stat field, which it will have
to continue doing for a while now.

Change-Id: I426d38a86a96307ff6e6ed8099d37dae02d6bf2b
2014-09-18 12:46:28 +00:00
David van Moolenbroek 970d95ecd5 ext2: use libfsdriver
- fix panic on truncating files with holes;
- remove block-based readahead, to match MFS.

Change-Id: I385552f8019e9c013a6cb937bcc8e4e7181a4a50
2014-09-18 12:46:27 +00:00
David van Moolenbroek ccaeedb267 MFS: use libfsdriver
Change-Id: Ib658c7dea47b81a417755b0554a75288117b431a
2014-09-18 12:46:27 +00:00
David van Moolenbroek ad80a203db Move clock_time into libsys
Change-Id: Ibc5034617e6f6581de7c4a166ca075b3c357fa82
2014-09-18 12:46:26 +00:00
David van Moolenbroek 0dc5c83ec2 libvtreefs: use libfsdriver
Change-Id: I0e6446bd0ccc3b89edc237be441ebfd92585f352
2014-09-18 12:46:26 +00:00
David van Moolenbroek a99c939dee libsffs: use libfsdriver
Change-Id: Id8377873455771c614371e115643cd906d05f12c
2014-09-18 12:46:25 +00:00
David van Moolenbroek ebd3c0673d libminixfs: add block I/O routines
The new functionality aims to save each file system server from having
to implement its own block I/O routines just so that it can serve as a
root file system.  The new source file (bio.c) lists the requirements
that file system servers have to fulfill in order to use the routines.

Change-Id: Ia0190fd5c30e8c2097ed8f4b0e3ccde1827e0b92
2014-09-18 12:46:25 +00:00
David van Moolenbroek c5beebb68d libminixfs: do not make fs_sync upcalls
The file system may not be expecting these upcalls at arbitrary
moments, while they serve only as a performance optimization anyway.

Change-Id: I0748fd1f6c2645ddbb64466093ee36025aac45e0
2014-09-18 12:46:24 +00:00
David van Moolenbroek 35118b0a91 test72: fix mock bdev functions
The minixfs library only ever submits vector elements (and reads) of
the system page size. The test implementation was expecting vector
elements (and reads) of the file system block size. The resulting
mismatch caused I/O to fail in various ways, even though this did not
have an effect on the actual test.

Change-Id: I02f4a3efcd4a32916435d82c7d5798e6b78f0a27
2014-09-18 12:46:24 +00:00
David van Moolenbroek f018897664 test72: fix premature block size update
Updating the current block size before flushing the cache, which still
contained blocks with the old block size, resulted in triggering an
assert on position alignment.

Change-Id: I7a83f3d3bc57bafc08aa6c8df64fbf978273bbfd
2014-09-18 12:46:23 +00:00
David van Moolenbroek 89c9de7d09 Add libfsdriver: a library to drive file systems
This library provides new abstractions for the upper (VFS) side of
file system services, and should be used for all file system service
implementations from now on.  It provides the following functionality:

  - a function call table abstraction, hiding the details of the
    VFS-FS protocol with simple parameters;
  - a (currently limited) number of per-function steps required for
    all file system implementations, such as copying in and out path
    names and result buffers;
  - a default implementation for multicomponent path lookups, such
    that the file system merely has to implement resolution of single
    components at a time;
  - an abstraction for copying data from and to the file system, which
    allows transparent intraprocess copying as required for the lookup
    implementation;
  - a set of functions to simplify getdents implementations.

The message loop provided by the library is currently for use by
single-threaded file system implementations only.  Multithreaded file
system services may use the more low-level message processing
functionality.

Protocol-level optimizations such as including names in protocol
messages may be hidden entirely in this library.  In addition, in the
future, the lookup implementation may be replaced by a single-
component lookup VFS/FS protocol request as part of a VFS name cache
implementation; this, too, can be hidden entirely in this library.

Change-Id: Ib34f0d0e021dfa3426ce8826efcf3eaa94d3ef3e
2014-09-18 12:46:23 +00:00