]> Zhao Yanbai Git Server - minix.git/log
minix.git
8 years agoVFS: disallow opening files of unsupported types 44/3344/1
David van Moolenbroek [Sun, 27 Dec 2015 22:44:34 +0000 (22:44 +0000)]
VFS: disallow opening files of unsupported types

Any attempt to use open(2) to open a socket file now fails with
EOPNOTSUPP, as is common and in the process of being standardized.
The behavior and error code is now tested in test56.

Any attempt to open a file of which the type is not known to VFS
(e.g., as a result of bogus file system contents) now fails with EIO.
For now, this is a safety feature, to prevent VFS tripping over such
types in unchecked cases.  In the future, a proper VFS code audit
should determine whether we can lift this restriction again, although
it does not seem particularly useful to be able to open files of
unknown types anyway.  Another error code may be assigned to this case
later, too.

Change-Id: Ib4cb4341eec954f0448fe469ecf28bd78edebde2

8 years agoVFS: add debug dump for select 43/3343/1
David van Moolenbroek [Thu, 4 Aug 2016 16:12:54 +0000 (16:12 +0000)]
VFS: add debug dump for select

By now it has become clear that the VFS select code has an unusually
high concentration of bugs, and there is no indication that any form
of convergence to a bug-free state is in sight.  Thus, for now, it
may be helpful to be able to dump the contents of the select tables
in order to track down any bugs in the future.  Hopefully that will
allow the next bugs to be resolved slightly after than before.

The debug dump can be triggered with "svrctl vfs get print_select".

Change-Id: Ia826746dce0f065d7f3b46aa9047945067b8263d

8 years agoVFS: fix race condition in select(2) 42/3342/1
David van Moolenbroek [Thu, 4 Aug 2016 16:17:09 +0000 (16:17 +0000)]
VFS: fix race condition in select(2)

A select query could deadlock if..

- it was querying a character or socket device that, at the start of
  the select query, was not known to be ready for the requested
  operations;
- this device could not be checked immediately, due to another ongoing
  query to the same character or socket driver;
- the select query had a timer that triggered before the device could
  be checked, thereby changing the select query to non-blocking.

In this situation, a missing flag check would cause the select code to
conclude erroneously that the operations which it flagged for later,
were satisfied.  At the same time, the same flag remained set, so that
the select query would continue to wait for that device.  This
resulted in a deadlock.  The same bug could most likely be triggered
through other scenarios that were even less likely to occur.

This patch fixes the race condition and puts in a hopefully slightly
more informative comment for the affected block of code.

In practice, the bug could be triggered fairly reliably by generating
lots of output in tmux.

Change-Id: I1c909255dcf552e6c7cef08b0cf5cbc41294b99c

8 years agoVFS: forbid mknod(2) on symlinks 41/3341/1
David van Moolenbroek [Fri, 15 Jul 2016 14:29:16 +0000 (14:29 +0000)]
VFS: forbid mknod(2) on symlinks

As imposed by POSIX.

Extend a random test to verify this behavior.

Change-Id: Ib70550cefaeb9efd54e22312425263a5606fb5e8

8 years agoVarious timer improvements 40/3340/1
David van Moolenbroek [Thu, 21 Jul 2016 15:31:27 +0000 (15:31 +0000)]
Various timer improvements

Now that clock_t is an unsigned value, we can also allow the system
uptime to wrap.  Essentially, instead of using (a <= b) to see if time
a occurs no later than time b, we use (b - a <= CLOCK_MAX / 2).  The
latter value does not exist, so instead we add TMRDIFF_MAX for that
purpose.

We must therefore also avoid using values like 0 and LONG_MAX as
special values for absolute times.  This patch extends the libtimers
interface so that it no longer uses 0 to indicate "no timeout".
Similarly, TMR_NEVER is now used as special value only when
otherwise a relative time difference would be used.  A minix_timer
structure is now considered in use when it has a watchdog function set,
rather than when the absolute expiry time is not TMR_NEVER.  A few new
macros in <minix/timers.h> help with timer comparison and obtaining
properties from a minix_timer structure.

This patch also eliminates the union of timer arguments, instead using
the only union element that is only used (the integer).  This prevents
potential problems with e.g. live update.  The watchdog function
prototype is changed to pass in the argument value rather than a
pointer to the timer structure, since obtaining the argument value was
the only current use of the timer structure anyway.  The result is a
somewhat friendlier timers API.

The VFS select code required a few more invasive changes to restrict
the timer value to the new maximum, effectively matching the timer
code in PM.  As a side effect, select(2) has been changed to reject
invalid timeout values.  That required a change to the test set, which
relied on the previous, erroneous behavior.

Finally, while we're rewriting significant chunks of the timer code
anyway, also covert it to KNF and add a few more explanatory comments.

Change-Id: Id43165c3fbb140b32b90be2cca7f68dd646ea72e

8 years agoPreparations for PAE support 39/3339/1
rlfnb [Tue, 12 Jul 2016 15:20:41 +0000 (17:20 +0200)]
Preparations for PAE support

Change-Id: I9a7c9ed9f803e2e26d745d14149a8aec64ab0c75

8 years agoAdapt MINIX-specific part of tools/installboot 38/3338/1
Antoine Leca [Tue, 2 Aug 2016 21:07:15 +0000 (23:07 +0200)]
Adapt MINIX-specific part of tools/installboot

This is necessary to enable correct compilation of the tools version
of installboot_nbsd(8)when cross-compiling on a system close enough
to MINIX, like NetBSD 7.0.1 for example.

Change-Id: I7a12614518293e05d64d7cc189c62651fdc64734

8 years agoClean up traces from long-gone sys_int86 interface 37/3337/1
Antoine Leca [Wed, 20 Jul 2016 15:43:35 +0000 (17:43 +0200)]
Clean up traces from long-gone sys_int86 interface

Change-Id: I773ab67342be852cc74f76b4fcbb338c9cb11f7e

8 years agoDrop obsolete postinstall script 36/3336/1
Antoine Leca [Wed, 20 Jul 2016 10:13:26 +0000 (12:13 +0200)]
Drop obsolete postinstall script

Conflicts with NetBSD /usr/sbin/postinstall(8)

Change-Id: Iaefe4494b95b46d1134f4a477798765bbcc66c70

8 years agoRemove long-obsolete pwdauth(8) command (in usr/lib) 35/3335/1
Antoine Leca [Wed, 20 Jul 2016 09:50:25 +0000 (11:50 +0200)]
Remove long-obsolete pwdauth(8) command (in usr/lib)

Change-Id: I454d506199ce1d5d48295bca86b590ce0701dcc2

8 years agoAllow part(8) to make subpartitions above 4G 34/3334/1
Antoine Leca [Thu, 14 Jul 2016 12:09:14 +0000 (14:09 +0200)]
Allow part(8) to make subpartitions above 4G

Change-Id: I3fd2c5de7cbb190b857eb34f16463f67a30118a3

8 years agoImport locale tools and ressource files 33/3333/1
Lionel Sambuc [Mon, 20 Jun 2016 16:30:51 +0000 (18:30 +0200)]
Import locale tools and ressource files

This commit requires special steps, please checkout docs/UPDATING.

Tools:
 - gencat
 - locale
 - mkcsmapper
 - mkesdb
 - mklocale

Libs:
 - i18n_module
 - libintl

Ressources:
 - i18n
 - locale

Change-Id: I559d0399d8e98bcee15225cab786e43f31506207

8 years agokernel/cpulocals.h: Simplify macros 32/3332/1
Lionel Sambuc [Sat, 18 Jun 2016 08:00:40 +0000 (10:00 +0200)]
kernel/cpulocals.h: Simplify macros

Change-Id: Ice845fb0743ff686398293cef2620f5ac9c902ad

8 years agognu/texinfo: Disable -Werror for clang 31/3331/1
Lionel Sambuc [Sat, 2 Jul 2016 12:07:35 +0000 (14:07 +0200)]
gnu/texinfo: Disable -Werror for clang

Change-Id: Ib5053044c03503942f9626703f086ee2bbb518ac

8 years agoPM: Convert K&R C -> ANSI C 30/3330/1
Richard Sailer [Fri, 8 Jul 2016 13:17:14 +0000 (15:17 +0200)]
PM: Convert K&R C -> ANSI C

Aditionally this removes all trailing whitespaces in pm server code
using: sed -i 's/[[:space:]]*$//' *.c

Change-Id: Ie44162fd56cd7042f4f0cc7bd7314b17ea128761

8 years agomade minix3 bootable via EFI 29/3329/1
Ralf Neeb [Sat, 2 Jul 2016 11:28:02 +0000 (13:28 +0200)]
made minix3 bootable via EFI

Change-Id: I61d995e240deb6ebb3027d3ab07e6e3759e52b01

8 years agoTypo in hardfloat command-line fixup/replacement 28/3328/1
Mark Pauley [Fri, 15 Apr 2016 20:39:48 +0000 (13:39 -0700)]
Typo in hardfloat command-line fixup/replacement

- Added two missing '%' characters to replacement strings.

Change-Id: I139d432f5cf2651642284fa39112b66f478dadce

8 years agoINET/LWIP: minimal net.route sysctl support 27/3327/1
David van Moolenbroek [Fri, 17 Jun 2016 14:03:27 +0000 (14:03 +0000)]
INET/LWIP: minimal net.route sysctl support

At a point not too far in the future, we will be switching from the
hardcoded MINIX3 implementation of the getifaddrs(3) libc routine to
the proper NetBSD implementation.  The latter uses the
net.route.rtable sysctl functionality to obtain its information.  In
order make the transition as painless as possible, this patch adds
basic support for that net.route.rtable functionality to INET and
LWIP, using the remote MIB (RMIB) facility.

Change-Id: I54f5cea7985f6606e317c73a5e6be3a5d07bc7dc

8 years agoIPC: use RMIB to handle kern.ipc sysctl subtree 26/3326/1
David van Moolenbroek [Tue, 14 Jun 2016 08:03:51 +0000 (08:03 +0000)]
IPC: use RMIB to handle kern.ipc sysctl subtree

With this patch, the IPC service is changed to use the new RMIB
facility to register and handle the "kern.ipc" sysctl subtree itself.
The subtree was previously handled by the MIB service directly.  This
change improves locality of handling: especially the
kern.ipc.sysvipc_info node has some peculiarities specific to the IPC
service and is therefore better handled there.  Also, since the IPC
service is essentially optional to the system, this rearrangement
yields a cleaner situation when the IPC service is not running: in
that case, the MIB service will expose a few basic kern.ipc nodes
indicating that no SysV IPC facilities are present.  Those nodes will
be overridden through RMIB when the IPC service is running.

It should be easier to add the remaining (from NetBSD) kern.ipc nodes
as well now.

Test88 is extended with a new subtest that verifies that sysctl-based
information retrieval for semaphore sets works as expected.

Change-Id: I6b7730e85305b64cfd8418c0cc56bde64b22c584

8 years agoMIB/libsys: support for remote MIB (RMIB) subtrees 25/3325/1
David van Moolenbroek [Sat, 23 Apr 2016 18:07:39 +0000 (18:07 +0000)]
MIB/libsys: support for remote MIB (RMIB) subtrees

Most of the nodes in the general sysctl tree will be managed directly
by the MIB service, which obtains the necessary information as needed.
However, in certain cases, it makes more sense to let another service
manage a part of the sysctl tree itself, in order to avoid replicating
part of that other service in the MIB service.  This patch adds the
basic support for such delegation: remote services may now register
their own subtrees within the full sysctl tree with the MIB service,
which will then forward any sysctl(2) requests on such subtrees to the
remote services.

The system works much like mounting a file system, but in addition to
support for shadowing an existing node, the MIB service also supports
creating temporary mount point nodes.  Each have their own use cases.
A remote "kern.ipc" would use the former, because even when such a
subtree were not mounted, userland would still expect some of its
children to exist and return default values.  A remote "net.inet"
would use the latter, as there is no reason to precreate nodes for all
possible supported networking protocols in the MIB "net" subtree.

A standard remote MIB (RMIB) implementation is provided for services
that wish to make use of this functionality.  It is essentially a
simplified and somewhat more lightweight version of the MIB service's
internals, and works more or less the same from a programmer's point
of view.  The most important difference is the "rmib" prefix instead
of the "mib" prefix.  Documentation will hopefully follow later.

Overall, the RMIB functionality should not be used lightly, for
several reasons.  First, despite being more lightweight than the MIB
service, the RMIB module still adds substantially to the code
footprint of the containing service.  Second, the RMIB protocol not
only adds extra IPC for sysctl(2), but has also not been optimized for
performance in other ways.  Third, and most importantly, the RMIB
implementation also several limitations.  The main limitation is that
remote MIB subtrees must be fully static.  Not only may the user not
create or destroy nodes, the service itself may not either, as this
would clash with the simplified remote node versioning system and
the cached subtree root node child counts.  Other limitations exist,
such as the fact that the root of a remote subtree may only be a
node-type node, and a stricter limit on the highest node identifier
of any child in this subtree root (currently 4095).

The current implementation was born out of necessity, and therefore
it leaves several improvements to future work.  Most importantly,
support for exit and crash notification is missing, primarily in the
MIB service.  This means that remote subtrees may not be cleaned up
immediately, but instead only when the MIB service attempts to talk
to the dead remote service.  In addition, if the MIB service itself
crashes, re-registration of remote subtrees is currently left up to
the individual RMIB users.  Finally, the MIB service uses synchronous
(sendrec-based) calls to the remote services, which while convenient
may cause cascading service hangs.  The underlying protocol is ready
for conversion to an asynchronous implementation already, though.

A new test set, testrmib.sh, tests the basic RMIB functionality.  To
this end it uses a test service, rmibtest, and also reuses part of
the existing test87 MIB service test.

Change-Id: I3378fe04f2e090ab231705bde7e13d6289a9183e

8 years agoDo not hide the MSG_NOSIGNAL flag 24/3324/1
David van Moolenbroek [Mon, 9 May 2016 09:55:07 +0000 (09:55 +0000)]
Do not hide the MSG_NOSIGNAL flag

Instead, filter it in libc for old networking implementations, as
those do not support sending SIGPIPE to user processes anyway.  This
change allows newer socket drivers to implement the flag as per the
specification.

Change-Id: I423bdf28ca60f024a344d0a73e2eab38f1b269da

8 years agoLWIP: fix system.conf file 23/3323/1
David van Moolenbroek [Fri, 17 Jun 2016 14:10:57 +0000 (14:10 +0000)]
LWIP: fix system.conf file

Change-Id: I0f204a14776b4c3aaab4723c14a508506187acbc

8 years agoImport a subset of PF distribution files 22/3322/1
David van Moolenbroek [Fri, 17 Jun 2016 22:07:26 +0000 (22:07 +0000)]
Import a subset of PF distribution files

We do not support any PF functionality, nor do we intend to.  However,
some NetBSD utilities rely on the presence of these files.  Not all of
the files are installed.  The NetBSD source seems rather inconsistent
in where from to include these files.  We simply follow what NetBSD
does, though.

Change-Id: Ib244dfcc60b16ebc4697af22f71b7e014374b855

8 years agoImport additional networking headers from NetBSD 21/3321/1
David van Moolenbroek [Tue, 5 Apr 2016 15:23:18 +0000 (15:23 +0000)]
Import additional networking headers from NetBSD

While still a small subset of the NetBSD headers, this set should
allow various additional utilities to be compiled without too many
MINIX3-specific changes (even if those utilities will not yet work).

Change-Id: Idc70e9901d584e960cd406f75f561dcc9a4ddb7d

8 years agolibchardriver: make some pointers constant 20/3320/1
David van Moolenbroek [Sun, 1 May 2016 12:48:46 +0000 (12:48 +0000)]
libchardriver: make some pointers constant

Change-Id: Ieabc6962d10f9f6e0db7807fd24add212bcfc148

8 years agokernel: Update copyright year 19/3319/1
Jacob Adams [Sat, 9 Apr 2016 03:43:11 +0000 (23:43 -0400)]
kernel: Update copyright year

Change-Id: If566bf95db32d9f5ebf1a6677acdaad1c023112e

8 years agocawf(1): remove various redundant comparisons 18/3318/1
David van Moolenbroek [Fri, 17 Jun 2016 20:09:08 +0000 (20:09 +0000)]
cawf(1): remove various redundant comparisons

Reported by dcb314.

This fixes #135, #136.

Change-Id: I0f83a92e18adf68e5ad493b9057d093a6b37b328

8 years agoCorrect bad assignments in various conditions 17/3317/1
David van Moolenbroek [Fri, 17 Jun 2016 20:06:16 +0000 (20:06 +0000)]
Correct bad assignments in various conditions

Reported by dcb314.

This fixes #128, #129, #130, #131, #132, #133.

Change-Id: I284d6dd87fba7c5775bea22d04412d685a2ab027

8 years agoMFS: do not crash when reading superblock fails 16/3316/1
David van Moolenbroek [Fri, 17 Jun 2016 19:48:20 +0000 (19:48 +0000)]
MFS: do not crash when reading superblock fails

While MFS failing to do I/O on a block is generally fatal, reading
the superblock at mount time is an exception: this case may occur
when the given partition is too small to contain the superblock.
Therefore, MFS should not crash or even report anything in this
case, but rather refuse to mount cleanly.

This fixes #121.

Change-Id: I11326b48922a0e0ebefecbb8eec7c428f985f2b3

8 years agoSEF: identity transfer only after controlled crash 15/3315/1
David van Moolenbroek [Fri, 17 Jun 2016 18:09:52 +0000 (18:09 +0000)]
SEF: identity transfer only after controlled crash

Transparent (endpoint-preserving) restarts with identity transfer
are meant to exercise the crash recovery system only.  After *real*
crashes, such restarts are useless at best and dangerous at worst,
because no state integrity can be guaranteed afterwards.  Thus,
except after a controlled crash, it is best not to perform such
restarts at all.  This patch changes SEF such that identity transfer
is successful only if the old process was the subject of a crash
induced through "service fi".  As a result, testrelpol.sh should
continue to be able to use identity transfers for testing purposes,
but any real crash will be handled more appropriately.

This fixes #126.

Change-Id: Idc17ac7b3dfee05098529cb889ac835a0cd03ef0

8 years agoVFS: fix aborting queued requests after FS crash 14/3314/1
David van Moolenbroek [Fri, 17 Jun 2016 18:02:29 +0000 (18:02 +0000)]
VFS: fix aborting queued requests after FS crash

The new asserts from git-29e004d exposed an issue in how VFS handles
aborting file system (FS) requests that are queued for a FS (as
opposed to sent to it) when that FS crashes.  In that scenario, the
queued worker has its w_task set to NONE, because there is no ongoing
communication.  However, worker_stop() is called on it regardless,
which used to abort the request only if w_task was not set to NONE,
leading to an improperly aborted request, a warning, and a VFS crash a
bit later.  This patch changes worker_stop() so that w_task need not
be set to a valid endpoint for FS requests to be properly aborted.

Change-Id: Ib73db285e689ae4742b15cba26137bf340bc303b

8 years agoBoot-to-ramdisk image generation scripts 13/3313/2 140/head
Jean-Baptiste Boric [Tue, 6 Oct 2015 06:58:08 +0000 (08:58 +0200)]
Boot-to-ramdisk image generation scripts

Scripts for generating boot-to-ramdisk images are now available. These
can be used for example to boot from PXE or from a USB stick, as the
ramdisk are self-contained and do not rely on any block devices after
being loaded into RAM.

The image generation framework has also been slightly cleaned up in
order to better accomodate tarball sets bundling in images.

Change-Id: I65a176832bd0d6954b430fa8305f90af0bd606c1

8 years agoRevert "libutil: add getmaxpartitions() implementation" 11/3311/1
Jean-Baptiste Boric [Sun, 13 Mar 2016 18:30:35 +0000 (19:30 +0100)]
Revert "libutil: add getmaxpartitions() implementation"

This reverts commit 22ad44d6a9fa80d47806bf1897394569b6c15b8a.

With the MIB service implemented, this hack is no longer necessary.

Change-Id: Ic969c2dcecd6fc9ce283d1dda6518796869875e3

8 years agolibc: enable all functionality in net/ 10/3310/1
David van Moolenbroek [Sun, 13 Mar 2016 15:55:44 +0000 (15:55 +0000)]
libc: enable all functionality in net/

Some functions in lib/libc/net were disabled on MINIX3 only, but with
a few added header files they build just fine, even though some of
them rely on system functionality that has not yet been implemented.
Since the functionality is unlikely to be used in practice (because
it typically requires the use of protocol families that themselves are
not yet supported, such as IPv6), already enabling it right now helps
in building packages that rely on the functionality being present at
compile time, while not posing any practical risk of breaking the same
packages at run time.

Change-Id: Idee8e3963c9e300bde9575429f0e77b0565acaef

8 years agoPM: add support for saved user/group IDs 09/3309/2
David van Moolenbroek [Sat, 12 Mar 2016 10:11:36 +0000 (10:11 +0000)]
PM: add support for saved user/group IDs

This patch aims to synchronize the basic process user and group ID
management, as well as the set[ug]id(2) and sete[ug]id(2) behavior,
with NetBSD.  As it turns out, the main issue was missing support for
saved user and group IDs.  This support is now added.

Since NetBSD's userland, which we are importing, may rely on NetBSD
specifics when it comes to security, we choose not to deviate from
NetBSD's behavior in any way here.  A new test, test89, verifies the
correct behavior - it has been confirmed to pass on NetBSD as is.

Change-Id: I023935546d97ed01ffd8090f7793d336cceb0f4a

8 years agoAdded device ID for 82573 08/3308/1
rlfnb [Sun, 6 Mar 2016 20:21:41 +0000 (21:21 +0100)]
Added device ID for 82573

Device ID belongs to a NIC being used in many Thinkpad laptops, tested!

Close #118
Change-Id: If6c2327a4fb4cae49a734dc1cebbe3dc8c383456

8 years agolibc: fix local from-source upgrades 04/3304/3
David van Moolenbroek [Sat, 27 Feb 2016 17:45:02 +0000 (17:45 +0000)]
libc: fix local from-source upgrades

Commit git-c38dbb9 inadvertently broke local MINIX3-on-MINIX3 builds,
since its libc changes relied on VFS being upgraded already as well.
As a result, after installing the new libc, networking ceased to work,
leading to curl(1) failing later on in the build process.  This patch
introduces transitional code that is necessary for the build process
to complete, after which it is obsolete again.

Change-Id: I93bf29c01d228e3d7efc7b01befeff682954f54d

8 years agoKernel: disable assert in prefetch abort handler 07/3307/1
David van Moolenbroek [Wed, 9 Mar 2016 12:02:03 +0000 (12:02 +0000)]
Kernel: disable assert in prefetch abort handler

For a reason currently unknown to us, the qemu-linaro emulator
sometimes produces a Prefetch Abort exception with a fault location
(IFAR) rather different from the location of the instruction being
executed (LR corrected by 4).  So far it has been observed in the
__udivmodsi4 routine of various processes, where the fault address is
for the first byte of the next page after the current instruction,
which itself is 44-64 bytes away from the start of that next page.
The affected instruction does not perform any sort of memory access.

Short of debugging qemu-linaro itself, we have no choice but to
disable the assert that previously went off in case the IFAR and
corrected LR are not equal.  Since we have not yet observed this case
on actual hardware, the kernel prints a warning when detecting such a
mismatch for the first time.  For the qemu-linaro case, the kernel's
actual page fault handling logic already handles this strange case
just fine.

Change-Id: Ibd19e624149ab4e68bfe75b918ec1554b825a431

8 years agorc: start syslogd with -s (no UDP sockets) 05/3305/2
David van Moolenbroek [Mon, 29 Feb 2016 16:24:21 +0000 (16:24 +0000)]
rc: start syslogd with -s (no UDP sockets)

Change-Id: I80f46c1c525d2573614676cdd612e284c16be481

8 years ago3c90x: add support for 3c905B 100BaseTX 03/3303/1
David van Moolenbroek [Sat, 27 Feb 2016 15:35:17 +0000 (15:35 +0000)]
3c90x: add support for 3c905B 100BaseTX

Tested and found working.  No driver changes required.

Change-Id: Ib05e7540a6264f784b6342d6e84c4e11423b2ec9

8 years agosetup.sh: fix various issues 02/3302/1
David van Moolenbroek [Fri, 26 Feb 2016 19:41:21 +0000 (19:41 +0000)]
setup.sh: fix various issues

- fix the reinstallation (preserve-/home) option;
- remove support for just reinstalling the bootloader, as the main
  purpose of this option (allowing an upgrade from the old MINIX
  boot monitor to the NetBSD bootloader) is no longer needed and was
  already broken;
- do not try to copy over /etc/motd.install: it no longer exists.

This resolves issue 106.

Change-Id: Iad3805d86c4806d725f9b285c2d4378670790f78

8 years agoVFS: remove unused variable in worker.c 01/3301/1
David van Moolenbroek [Sun, 21 Feb 2016 22:01:11 +0000 (22:01 +0000)]
VFS: remove unused variable in worker.c

Change-Id: Ife41d292ab50a36c75dc28b682684095654bfcf2

8 years agoPrepare for switch to native BSD socket API 00/3300/2
David van Moolenbroek [Sun, 21 Feb 2016 17:39:34 +0000 (17:39 +0000)]
Prepare for switch to native BSD socket API

Currently, the BSD socket API is implemented in libc, translating the
API calls to character driver operations underneath.  This approach
has several issues:

- it is inefficient, as most character driver operations are specific
  to the socket type, thus requiring that each operation start by
  bruteforcing the socket protocol family and type of the given file
  descriptor using several system calls;
- it requires that libc itself be changed every time system support
  for a new protocol is added;
- various parts of the libc implementations violate the asynchronous
  signal safety POSIX requirements.

In order to resolve all these issues at once, the plan is to turn the
BSD socket calls into system calls, thus making the BSD socket API the
"native" ABI, removing the complexity from libc and instead letting
VFS deal with the socket calls.

The overall change is going to break all networking functionality. In
order to smoothen the transition, this patch introduces the fifteen
new BSD socket system calls, and makes libc try these first before
falling back on the old behavior.  For now, the VFS implementations of
the new calls fail such that libc will always use the fallback cases.
Later on, when we introduce the actual implementation of the native
BSD socket calls, all statically linked programs will automatically
use the new ABI, thus limiting actual application breakage.

In other words: by itself, this patch does nothing, except add a bit
of transitional overhead that will disappear in the future.  The
largest part of the patch is concerned with adding full support for
the new BSD socket system calls to trace(1) - this early addition has
the advantage of making system call tracing output of several socket
calls much more readable already.

Both the system call interfaces and the trace(1) support have already
been tested using code that will be committed later on.

Change-Id: I3460812be50c78be662d857f9d3d6840f3ca917f

8 years agolibc: reorganize vector I/O wrappers 99/3299/1
David van Moolenbroek [Sat, 16 Jan 2016 17:30:39 +0000 (17:30 +0000)]
libc: reorganize vector I/O wrappers

The reorganization allows other libc system call wrappers (namely,
sendmsg and recvmsg) to perform I/O vector coalescing as well.

Change-Id: I116b48a6db39439053280ee805e0dcbdaec667a3

8 years agoVFS: start off cleanup of pipe2 IPC message 98/3298/1
David van Moolenbroek [Thu, 14 Jan 2016 18:29:20 +0000 (18:29 +0000)]
VFS: start off cleanup of pipe2 IPC message

There is no reason to use a single message for nonoverlapping requests
and replies combined, and in fact splitting them out allows reuse of
messages and avoids various problems with field layouts.  Since the
upcoming socketpair(2) system call will be using the same reply as
pipe2(2), split up the single message used for the latter.  In order
to keep the used parts of messages at the front, start a transitional
phase to move the pipe(2) flags field to the front of its request.

Change-Id: If3f1c3d348ec7e27b7f5b7147ce1b9ef490dfab9

8 years agolibc: check raw IP socket type before using it 97/3297/1
David van Moolenbroek [Sat, 9 Jan 2016 13:34:13 +0000 (13:34 +0000)]
libc: check raw IP socket type before using it

Previously, the libc sendto(3) and recvfrom(3) implementations would
blindly assume that any unrecognized socket is a raw-IP socket.  This
is not only inconsistent but also messes with returned error codes.

Change-Id: Id0328f04ea8ca0968a4e8636bc441caa0c3579b7

8 years agoCross-compilation fixes: 96/3296/1
Lionel Sambuc [Sun, 7 Feb 2016 21:13:15 +0000 (22:13 +0100)]
Cross-compilation fixes:

 - GCC >4.9:
     Newer toolchains trigger more warnings, which by default are
   treated as errors. Disable this while building the tools as this
   will be a recurring problem in the future.

   close #105

 - FreeBSD: Fix some fetch.sh scripts which fails as FreeBSD's patch
   fails to patch two .info files. We ignore this for the time being.

Change-Id: Ic669281db6c41005119ea8f76f78b5ec60e1b386

8 years agoifdef for switching RTS/CTS off 95/3295/1
rlfnb [Sat, 6 Feb 2016 20:08:50 +0000 (21:08 +0100)]
ifdef for switching RTS/CTS off

Change-Id: Iccc4b151b2047539dfd79ce0ff1381c0579539e9

8 years agoFix usage of parenthesis in Makefiles 94/3294/1
Lionel Sambuc [Sat, 6 Feb 2016 11:38:52 +0000 (12:38 +0100)]
Fix usage of parenthesis in Makefiles

While BSD make support both $() and ${} around variables, the NetBSD
source tree uses only ${} by convention.

Imported software is left as is, and sometimes $() is used when the
containing Makefile/Makefile fragment is used both by GNU make and BSD
make, as it can happen for the tools, and other parts as well which are
compiled using the host make tool.

Change-Id: Ic7d480812fde53e7e3e95275a30a3b720c95cc15

8 years agomoved service configuration out of system.conf 93/3293/1
rlfnb [Thu, 4 Feb 2016 07:03:13 +0000 (08:03 +0100)]
moved service configuration out of system.conf

Change-Id: I996c0e700b087c5130ac6480ae39e1eefa771eff

8 years agomail: close `fp` after use 92/3292/1
Thomas Cort [Sun, 7 Feb 2016 13:18:01 +0000 (13:18 +0000)]
mail: close `fp` after use

Add missing `fclose(fp)`

Issue #109

Change-Id: I0908ede77cba18336c399c5e16771cb6650e6404

8 years agoBasic statistical profiling fixes 91/3291/1
David van Moolenbroek [Thu, 28 Jan 2016 12:09:35 +0000 (13:09 +0100)]
Basic statistical profiling fixes

At least it works again now.  Sprofalyze should be made aware of the
kernel information page, though (i.e., /proc/ipcvecs).

Change-Id: Id4e5f6417ad152607c4e53b323b6f65ea4b10c6e

8 years agobootloader: do not try to autoload NetBSD modules 90/3290/1
David van Moolenbroek [Mon, 25 Jan 2016 18:23:56 +0000 (19:23 +0100)]
bootloader: do not try to autoload NetBSD modules

The NetBSD bootloader attempts to load NetBSD kernel modules for
"unusual" file systems.  We do not support NetBSD kernel modules,
and thus, the bootloader gives us warnings about not being able
to load them, in particular when booting CD images.  This patch
disables the NetBSD file system module autoload feature.

Change-Id: I55fce53b4bb0282b7d8a005192200fe466312f62

8 years agotests: another fix 89/3289/1
David van Moolenbroek [Mon, 25 Jan 2016 18:03:59 +0000 (19:03 +0100)]
tests: another fix

- test80: resolve race condition resulting from unintended send

Change-Id: Id029d679a3903de0f712a15d4756952dbc36070c

8 years agotests: fixes 88/3288/1
David van Moolenbroek [Mon, 25 Jan 2016 12:16:23 +0000 (12:16 +0000)]
tests: fixes

- test3: support running the test set from a pseudoterminal;
- test60: fix number conversion bug that caused chmod errors;
- test65: remove nonworking package installation instructions;
- testisofs: work around failure due to having a timezone set;
- testisofs: exclude extra RR_MOVED directory from output.

Change-Id: Ibfcc631de7e2f4da46bac3ad9de8d7c7cd7a6189

8 years agoFix ARM noassert builds -g/-O{s/0/1/2/3} 87/3287/1
Lionel Sambuc [Sat, 23 Jan 2016 10:45:33 +0000 (11:45 +0100)]
Fix ARM noassert builds -g/-O{s/0/1/2/3}

Also fixes ARM assert build -O3.

Change-Id: I52bda91308ecfa0e8b23c4140c38c49347cc10f7

8 years agoBumping version to 3.4.0 83/3283/3
Lionel Sambuc [Wed, 13 Jan 2016 19:39:46 +0000 (20:39 +0100)]
Bumping version to 3.4.0

Change-Id: Ia5630d7409cf7042853847ee29866e2db3514c91

8 years agosetup.sh: clean up 86/3286/2
Lionel Sambuc [Wed, 20 Jan 2016 16:41:58 +0000 (17:41 +0100)]
setup.sh: clean up

 - Fix unmounting order of slices.
 - Update pkgin pre-installation commands, make them as generic as
   possible.

Change-Id: Ifaa4021fed048facca8d2a170aa65491feb37702

8 years agoServer packages: Make sure /usr/pkg/var/run exists 85/3285/2
Lionel Sambuc [Wed, 20 Jan 2016 16:39:42 +0000 (17:39 +0100)]
Server packages: Make sure /usr/pkg/var/run exists

If this directory doesn't exist, pid files are not created, which create
issues when shutting down or rebooting.

Change-Id: I52dddb57aca4368b1775606e22818fba99d05bf6

8 years agoFix X11 forwarding: sendmsg/recvmsg only supported over UDS 84/3284/2
Lionel Sambuc [Wed, 20 Jan 2016 15:27:55 +0000 (15:27 +0000)]
Fix X11 forwarding: sendmsg/recvmsg only supported over UDS

Change-Id: Id9dc5517ec09382010a556fbabc6dccc77942378

8 years agoImprove libexec debug output 82/3282/3
Lionel Sambuc [Sun, 3 Jan 2016 10:45:18 +0000 (11:45 +0100)]
Improve libexec debug output

Change-Id: I6a82d3eeed263e813852549fac015b82832c5c29

8 years agoReduce sysident patches 81/3281/3
Lionel Sambuc [Sun, 3 Jan 2016 10:44:52 +0000 (11:44 +0100)]
Reduce sysident patches

Change-Id: I4499a294e74ed69648afc33bff5f750f3d1aa019

8 years agoFix typo in comment 80/3280/3
Gerhard Poul [Fri, 25 Dec 2015 16:15:42 +0000 (17:15 +0100)]
Fix typo in comment

Change-Id: Iefc0f11ac81da1d681785530e33a4668d8614de9

8 years agoFix umount order in setup.sh 79/3279/3
Lionel Sambuc [Thu, 31 Dec 2015 17:41:27 +0000 (18:41 +0100)]
Fix umount order in setup.sh

Change-Id: Ife0c36b0fdc70e4b7ae86278d0df8d6d00d19df4

8 years agotests: add most kyua kernel tests 78/3278/3
Lionel Sambuc [Thu, 31 Dec 2015 10:14:35 +0000 (11:14 +0100)]
tests: add most kyua kernel tests

Change-Id: I2da22559ee3b0208945e21312e7721a32e629d27

8 years agold.elf_so: sysctl support uncommented 77/3277/3
Lionel Sambuc [Wed, 30 Dec 2015 22:22:55 +0000 (23:22 +0100)]
ld.elf_so: sysctl support uncommented

Change-Id: I253f3b4a2ef8c5b3fb332eb98a08d328a9591c52

8 years agold.elf_so: Drop fallback routine 76/3276/3
Lionel Sambuc [Wed, 30 Dec 2015 08:16:54 +0000 (09:16 +0100)]
ld.elf_so: Drop fallback routine

Change-Id: Ia2236146c3302ba992aa6fea0fc9e9699fe9e3cd

8 years agomined: fix buffer overflow in input() 75/3275/3
Thomas Cort [Tue, 22 Dec 2015 03:07:01 +0000 (03:07 +0000)]
mined: fix buffer overflow in input()

input() is used to accept filenames when saving, regular
expressions when searching, and other input. It writes
the characters into buffers such as file and exp_buf and
others which are of length LINE_LEN.

To prevent writing beyond the end of the intended buffer,
truncate the input at LINE_LEN - 1 and ensure that the
string is NULL terminated.

Change-Id: I142baa8cfae38bdd7fa648d86559d6d9b8e7a7fd

8 years agoFix soft faults in FSes resulting in partial I/O 74/3274/3
David van Moolenbroek [Wed, 30 Dec 2015 13:17:42 +0000 (13:17 +0000)]
Fix soft faults in FSes resulting in partial I/O

In order to resolve page faults on file-mapped pages, VM may need to
communicate (through VFS) with a file system.  The file system must
therefore not be the one to cause, and thus end up being blocked on,
such page faults.  To resolve this potential deadlock, the safecopy
system was previously extended with the CPF_TRY flag, which causes the
kernel to return EFAULT to the caller of a safecopy function upon
getting a pagefault, bypassing VM and thus avoiding the loop.  VFS was
extended to repeat relevant file system calls that returned EFAULT,
after resolving the page fault, to keep these soft faults from being
exposed to applications.

However, general UNIX I/O semantics dictate that if an I/O transfer
partially succeeded before running into a failure, the partial result
is to be returned.  Proper file system implementations may therefore
end up returning partial success rather than the EFAULT code resulting
from a soft fault.  Since VFS does not get the EFAULT code in this
case, it does not know that a soft fault occurred, and thus does not
repeat the call either.  The end result is that an application may get
partial I/O results (e.g., a short read(2)) even on regular files.
Applications cannot reasonably be expected to deal with this.

Due to the fact that most of the current file system implementations
do not implement proper partial-failure semantics, this problem is not
yet widespread.  In fact, it has only occurred on direct block device
I/O so far.  However, the next generation of file system services will
be implementing proper I/O semantics, thus exacerbating the problem.

To remedy this situation, this patch changes the CPF_TRY semantics:
whenever the kernel experiences a soft fault during a safecopy call,
in addition to returning FAULT, the kernel also stores a mark in the
grant created with CPF_TRY.  Instead of testing on EFAULT, VFS checks
whether the grant was marked, as part of revoking the grant.  If the
grant was indeed marked by the kernel, VFS repeats the file system
operation, regardless of its initial return value.  Thus, the EFAULT
code now only serves to make the file system fail the call faster.

The approach is currently supported for both direct and magic grants,
but is used only with magic grants - arguably the only case where it
makes sense.  Indirect grants should not have CPF_TRY set; in a chain
of indirect grants, the original grant is marked, as it should be.
In order to avoid potential SMP issues, the mark stored in the grant
is its grant identifier, so as to discard outdated kernel writes.
Whether this is necessary or effective remains to be evaluated.

This patch also cleans up the grant structure a bit, removing reserved
space and thus making the structure slightly smaller.  The structure
is used internally between system services only, so there is no need
for binary compatibility.

Change-Id: I6bb3990dce67a80146d954546075ceda4d6567f8

8 years agolibsys: use linked list for free grants 73/3273/3
David van Moolenbroek [Tue, 29 Dec 2015 15:37:11 +0000 (15:37 +0000)]
libsys: use linked list for free grants

With this change, obtaining an existing free grant is no longer an
operation of O(n) complexity.  As a result, the now-deprecated
getgrant/setgrant part of the grants API also no longer has a
performance advantage.

Change-Id: Ic19308a76924c6242f9784244a6b3600e561e0fe

8 years agoAdd sequence numbers to grant IDs 72/3272/3
David van Moolenbroek [Mon, 28 Dec 2015 23:48:39 +0000 (23:48 +0000)]
Add sequence numbers to grant IDs

The memory grant identifier for safecopies now includes a sequence
number in its upper bits, to prevent accidental reuse of a grant ID
after revocation and subsequent reallocation.  This should increase
overall system robustness by a tiny amount, and possibly help catch
bugs in system services early on.  For now, the lower 20 bits of the
grant ID are used as grant table slot index (thus allowing for up to
a million grants per process), and the next 11 bits of the (signed
32-bit) grant ID are used to store the per-slot sequence number.  As
grant IDs are never exposed to userland, the split can be changed
later on without breaking the userland ABI.

Change-Id: Ic34be27ff2a45db0ea5db037a24eef9efcd9ca40

8 years agoKernel: apply x86 copy overflow check to ARM 71/3271/3
David van Moolenbroek [Tue, 29 Dec 2015 15:58:24 +0000 (15:58 +0000)]
Kernel: apply x86 copy overflow check to ARM

Apply the x86 overflow check from git-d09f72c to ARM code as well.
Not just stack traces, but also system services can trigger this
case, possibly as a result of being handed bad pointers by userland,
ending in a kernel panic.

Change-Id: Ib817e8b682fafec8edb486a094319ad11eda7081

8 years agoKernel: synchronize i386 and ARM clock code 70/3270/3
Lionel Sambuc [Sun, 20 Dec 2015 11:15:50 +0000 (12:15 +0100)]
Kernel: synchronize i386 and ARM clock code

Change-Id: Ie5c4653299e47aaefc9d35a8af491ad0b2eab1ab

8 years agoKernel: convert K&R functions to ANSI 69/3269/3
Dr. Florian Grätz [Thu, 5 Nov 2015 14:39:38 +0000 (15:39 +0100)]
Kernel: convert K&R functions to ANSI

Changed all K&R style functions to ANSI-style declarations within the
kernel directory. The code compiles and aparently works for i386. For
arm my toolchain does not work, but I have changed the code with great
care. Also, the make command fails for the test suite. Therefore, I
strongly recommand to review the code with care.

Edited by David van Moolenbroek to convert really all K&R functions.

Change-Id: I58cde797d36f4caa9c72db4e4dc27d8545ab8866

8 years agoe1000: add i82583V 1000baseT Ethernet 68/3268/3
rlfnb [Tue, 10 Nov 2015 15:04:00 +0000 (16:04 +0100)]
e1000: add i82583V 1000baseT Ethernet

added device id for the i82583V NIC. Tested successful on bare metal.

Change-Id: I486ea60a52a16075a1da8ffa0280884a407acc30

8 years agotrace(1): resolve all level-5 LLVM warnings 67/3267/3
David van Moolenbroek [Thu, 17 Dec 2015 13:50:28 +0000 (13:50 +0000)]
trace(1): resolve all level-5 LLVM warnings

Change-Id: If5ffe97eb0b15387b1ab674657879e13f58fb27e

8 years agoImport NetBSD ipcrm(1) 66/3266/3
David van Moolenbroek [Thu, 17 Dec 2015 13:14:08 +0000 (13:14 +0000)]
Import NetBSD ipcrm(1)

A few MINIX3-specific changes are necessary due to the fact that we
are missing the System V IPC message queue system calls.

Change-Id: Idd252984be9df69618cef79bcf6c676cbf915d85

8 years agoImport NetBSD ipcs(1) 65/3265/3
David van Moolenbroek [Thu, 17 Dec 2015 13:07:17 +0000 (13:07 +0000)]
Import NetBSD ipcs(1)

The old ipcs(1) utility had a dubious license at best.

Change-Id: Ic4c0a24f04c94cc77a43658f6c939d138461bd6a

8 years agoMIB: add support for System V IPC information node 64/3264/3
David van Moolenbroek [Thu, 17 Dec 2015 12:57:54 +0000 (12:57 +0000)]
MIB: add support for System V IPC information node

The kernel.ipc.sysvipc_info node is the gateway from NetBSD ipcs(1)
and ipcrm(1) to the IPC server, and thus necessary for a clean
import of these two utilities.  The MIB service implementation uses
the preexisting (Linux-specific) information calls on the IPC server
to obtain the information.

Change-Id: I85d1e193162d6b689f114764254dd7f314d2cfa0

8 years agoIPC server: subscribe to process events on demand 63/3263/3
David van Moolenbroek [Thu, 17 Dec 2015 12:33:40 +0000 (12:33 +0000)]
IPC server: subscribe to process events on demand

As mentioned in previous patches, services may not subscribe to
process events from specific processes only, since this results in
race conditions.  However, the IPC server can safely turn on and off
its entire subscription based on whether any System V IPC semaphores
(and, in the future, message queues) are allocated at all.  Since
the System V IPC facilities are not so commonly used, this removes
the extra round trip from PM to the IPC server and back for caught
signals and process exits in the common case.

Change-Id: I937259034872be32f4e26ab99270f4d475ff6134

8 years agoIPC server: major fixes, test set for semaphores 62/3262/3
David van Moolenbroek [Thu, 17 Dec 2015 11:34:07 +0000 (11:34 +0000)]
IPC server: major fixes, test set for semaphores

- rewrite the semop(2) implementation so that it now conforms to the
  specification, including atomicity, support for blocking more than
  once, range checks, but also basic fairness support;
- fix permissions checking;
- fix missing time adjustments;
- fix off-by-one errors and other bugs;
- do not allocate dynamic memory for GETALL/SETALL;
- add test88, which properly tests the semaphore functionality.

Change-Id: I85f0d3408c0d6bba41cfb4c91a34c8b46b2a5959

8 years agoPM: generic process event publish/subscribe system 61/3261/3
David van Moolenbroek [Sat, 12 Dec 2015 17:22:00 +0000 (17:22 +0000)]
PM: generic process event publish/subscribe system

Now that there are services other than PM and VFS that implement
userland system calls directly, these services may need to know about
events related to user processes.  In particular, signal delivery may
have to interrupt blocking system calls, and certain cleanup tasks may
have to be performed after a user process exits.

This patch aims to implement a generic, lasting solution for this
problem, by allowing services to subscribe to "signal delivered"
and/or "process exit" events from PM.  PM publishes such events by
sending messages to its subscribed services, which must then reply an
acknowledgment message.

For now, only the two aforementioned events are implemented, and only
the IPC service makes use of the process event facility.

The new process event publish/subscribe system replaces the previous
VM notify-sig/watch-exit/query-exit system, which was unsound: 1) it
allowed subscription to events from individual processes, and suffered
from fundamental race conditions as a result; 2) it relied on "not too
many" processes making use of the IPC server functionality in order to
avoid loss of notifications.  In addition, it had the "ipc" process
name hardcoded, did not distinguish between signal delivery and exits,
and added a roundtrip to VM for all events from all processes.

Change-Id: I75ebad4bc54e646c6433f473294cb4003b2c3430

8 years agoIPC server: restyle 60/3260/3
David van Moolenbroek [Wed, 25 Nov 2015 22:37:19 +0000 (22:37 +0000)]
IPC server: restyle

Closer to KNF, better coding practices, more similar to other
services, no more global variables, a few more comments, that
kind of stuff.  No major functional changes.

Change-Id: I6e8f53bfafd6f41e92031fba76c40a31d2107a8e

8 years agoIPC server: NetBSD sync, general improvements 59/3259/3
David van Moolenbroek [Tue, 24 Nov 2015 23:01:22 +0000 (23:01 +0000)]
IPC server: NetBSD sync, general improvements

- switch to the NetBSD identifier system; it is not only better, but
  also required for porting NetBSD ipcs(1) and ipcrm(1); however, it
  requires that slots not be moved, and that results in some changes;
- synchronize some other things with NetBSD: where keys are kept, as
  well as various non-permission mode flags;
- fix semctl(2) vararg retrieval and message field type;
- use SUSPEND instead of weird reply exceptions in the call table;
- fix several memory leaks and at least one missing permission check;
- improve the atomicity of semop(2) by a small amount, even though
  its atomicity is still broken at a fundamental level;
- use the new cheaper way to retrieve the current time;
- resolve all level-5 LLVM warnings.

Change-Id: I0c47aacde478b23bb77d628384aeab855a22fdbf

8 years agoIPC server: expose semaphore information 58/3258/2
David van Moolenbroek [Mon, 23 Nov 2015 23:25:27 +0000 (23:25 +0000)]
IPC server: expose semaphore information

Specifically, add support for the IPC_INFO, SEM_INFO, and SEM_STAT
semctl(2) operations, similar to how information about shared memory
is already exposed as well.  The MINIX3 ipcs(1) utility already had
support for these operations, and can now actually use them, too.

Change-Id: Ice5a02e729bf6df6aa8fab76e854808adc04dae3

8 years agoImport NetBSD pagesize(1) 57/3257/2
David van Moolenbroek [Thu, 19 Nov 2015 14:59:41 +0000 (14:59 +0000)]
Import NetBSD pagesize(1)

Change-Id: I6a749cba5c6dabb3daea8c5bad3e94be342833d7

8 years agoMIB: slim process tables to reduce memory usage 56/3256/2
David van Moolenbroek [Sun, 8 Nov 2015 12:39:45 +0000 (12:39 +0000)]
MIB: slim process tables to reduce memory usage

- About 80% of PM's process table consisted of per-signal sigaction
  structures.  This is information not used by the MIB service, and
  can safely be stored outside the main process table.

- The MIB service does not need most of the VFS process table, so VFS
  now generates a "light" version of its table upon request, with just
  the fields used by the MIB service.

The result is a size reduction of the MIB service of about 700KB.

Change-Id: I79fe7239361fbfb45286af8e86a10aed4c2d2be7

8 years agoProcFS: get process information from MIB service 55/3255/2
David van Moolenbroek [Sun, 8 Nov 2015 11:56:52 +0000 (11:56 +0000)]
ProcFS: get process information from MIB service

Instead of pulling in process tables itself, ProcFS now queries the
MIB service for process information.  This reduces ProcFS's memory
usage by about 1MB.  The change does have two negative consequences.

First, getting all the original /proc/<pid>/psinfo fields filled in
would take a lot of extra effort.  Since the only program that uses
those files at all is mtop(1), we reformat psinfo to expose only the
information used by mtop(1).  This means that with this patch, older
copies of MINIX3 ps and top will cease to work.

Second, since both MIB and ProcFS update their own view of the
process list only once per clock tick, ProcFS' view may now be
outdated by up to two clock ticks.  This is unlikely to pose a
problem in practice.

Change-Id: Iaa6b60450c8fb52d092962394d33d08bd638bc01

8 years agoRename top(1) to mtop(1), import NetBSD top(1) 54/3254/2
David van Moolenbroek [Sun, 8 Nov 2015 11:29:53 +0000 (11:29 +0000)]
Rename top(1) to mtop(1), import NetBSD top(1)

Due to differences in (mainly) measuring and accumulating CPU times,
the two top programs end up serving different purposes: the NetBSD
top is a system administration tool, while the MINIX3 top (now mtop)
is a performance debugging tool.  Therefore, we keep both.

The newly imported BSD top has a few MINIX3-specific changes.  CPU
statistics separate system time from kernel time, rather than kernel
time from time spent on handling interrupts.  Memory statistics show
numbers that are currently relevant for MINIX3.  Swap statistics are
disabled entirely.  All of these changes effectively bring it closer
to how mtop already worked as well.

Change-Id: I9611917cb03e164ddf012c5def6da0e7fede826d

8 years agoImport NetBSD ps(1) 53/3253/2
David van Moolenbroek [Wed, 28 Oct 2015 22:51:59 +0000 (22:51 +0000)]
Import NetBSD ps(1)

No changes except for one cosmetic adjustment:  NetBSD has chosen to
rename the standard TT column to TTY and not shorten tty names;  we
undo those changes, making ps(1) behave more in accordance with the
specification and its manual page, and, most importantly for us, not
use an incredibly wide TTY column to print "console".

Change-Id: I3b3c198762f3eacf1b8e500557a803c1fedf2a61

8 years agoImport NetBSD dev_mkdb(8) 52/3252/2
David van Moolenbroek [Tue, 6 Oct 2015 16:42:46 +0000 (16:42 +0000)]
Import NetBSD dev_mkdb(8)

Adapt libc devname(3) to make use of it, so that such device name
queries are now several orders of magnitude faster.  The database
is created and updated at system bootup time.

Change-Id: I0cbcb24c7d47577d4d6af9c8290c21ee4df9a0ff

8 years agow(1): switch to libkvm 51/3251/2
David van Moolenbroek [Fri, 9 Oct 2015 20:56:06 +0000 (20:56 +0000)]
w(1): switch to libkvm

Change-Id: I6d836d9aa2e1dfe8df1d866a5cc33868522f767e

8 years agoImport NetBSD libkvm 50/3250/2
David van Moolenbroek [Wed, 28 Oct 2015 17:52:48 +0000 (17:52 +0000)]
Import NetBSD libkvm

Imported with no changes, but not all parts are expected to be
functional.  The libc nlist functionality is enabled for the
purpose of successful linking, although the nlist functionaly has
not been tested on MINIX3 nor is it needed for how we use libkvm.

In terms of function calls: kvm_getproc2, kvm_getargv2,
kvm_getenvv2, and kvm_getlwps are expected to work, whereas
kvm_getproc, kvm_getargv, kvm_getenvv, and kvm_getfiles are not.

Change-Id: I7539209736f1771fc0b7db5e839d2df72f5ac615

8 years agoImport NetBSD sysctl(8) 49/3249/2
David van Moolenbroek [Wed, 28 Oct 2015 13:02:34 +0000 (13:02 +0000)]
Import NetBSD sysctl(8)

Change-Id: Idc3a9138521de1329daaab3bd0907a0db0d37775

8 years agoRetire sysuname(2), synchronize sys/utsname.h 48/3248/2
David van Moolenbroek [Fri, 9 Oct 2015 18:34:38 +0000 (18:34 +0000)]
Retire sysuname(2), synchronize sys/utsname.h

Now that uname(3) uses sysctl(2), we no longer need sysuname(2).
Backward compatibility is retained for old statically linked
binaries for a short while.

Also remove the now-obsolete MINIX3-specific "arch" field from the
utsname structure.  While this is an ABI break at the libc level,
it should pose no problems in practice, because:

- statically linked programs (i.e., all of the base system) are not
  affected, as they will use headers synchronized with libc;
- the structure is getting smaller, thus, older dynamically linked
  programs (typically in pkgsrc) using the new libc will end up with
  garbage in the "arch" field, but it is unlikely they will use this
  field anyway, since it was specific to MINIX3;
- new dynamically linked programs using an old libc could end up with
  memory corruption, but this is not a scenario that is expected to
  occur in the first place - certainly not with programs from pkgsrc.

Change-Id: I29c76576f509feacc8f996f0bd353ca8961d4917

8 years agoStart using sysctl(3) throughout userland 47/3247/2
David van Moolenbroek [Wed, 28 Oct 2015 15:06:03 +0000 (15:06 +0000)]
Start using sysctl(3) throughout userland

This patch mostly removes MINIX3-specific workarounds for missing
sysctl support.

Change-Id: I21e35e887359619ba72c252aa43d9017301a46ac

8 years agoMIB: initial tree population 46/3246/2
David van Moolenbroek [Tue, 27 Oct 2015 21:32:33 +0000 (21:32 +0000)]
MIB: initial tree population

Change-Id: I28ef0a81a59faaf341bfc15178df89474779a136

8 years agoPM: restore own proper process group 45/3245/2
David van Moolenbroek [Mon, 2 Nov 2015 19:20:00 +0000 (19:20 +0000)]
PM: restore own proper process group

PM uses its own process table entry as source for kernel signals,
and temporarily changes its own process group to make the signals
arrive at the right processes.  However, the value is never reset,
with as result that the temporary value shows up in ps(1) output.

Change-Id: Ib7f635b2cf1958055123736dfd58c26530632785

8 years agoPM: remember when each process was started 44/3244/2
David van Moolenbroek [Mon, 2 Nov 2015 17:45:28 +0000 (17:45 +0000)]
PM: remember when each process was started

Change-Id: I176f01681ebe758b03b635f2b5ecc8f083710bb4

8 years agoVM: report resource usage with VM usage info 43/3243/2
David van Moolenbroek [Wed, 4 Nov 2015 11:10:57 +0000 (11:10 +0000)]
VM: report resource usage with VM usage info

Change-Id: I93e898343e7fb72e75ae74c650b10f2ba570d381