]> Zhao Yanbai Git Server - minix.git/log
minix.git
6 years agoSync with manuals from netbsd-8 branch. 23/3523/1
Sevan Janiyan [Tue, 26 Jun 2018 00:12:34 +0000 (00:12 +0000)]
Sync with manuals from netbsd-8 branch.

Change-Id: I82fdb7486ae4f0f8f622046538806471bfb17c1d

6 years agoSync with cat.c from netbsd-8 22/3522/1
Sevan Janiyan [Mon, 25 Jun 2018 23:35:19 +0000 (23:35 +0000)]
Sync with cat.c from netbsd-8

When cat is invoked with -se, print a '$' on blank lines.

Change-Id: I1bdcced967261a231eab93e8d28736f9f52f53fd

6 years agoFix Compilation on Ubuntu 18.04 21/3521/2
Lionel Sambuc [Tue, 21 Aug 2018 19:37:57 +0000 (21:37 +0200)]
Fix Compilation on Ubuntu 18.04

 * Fix Compilation of GCC on Ubuntu 18.04
   Apply the following patch:
     https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=ec1cc0263f156f70693a62cf17b254a0029f4852

 * Fix GNU make build on new GNU glibc systems

Change-Id: I44fcdc23b037a53d8cf50ec09ba9f210a1e127c8

6 years agoFix ARM NDEBUG Builds 19/3519/1
Lionel Sambuc [Sat, 31 Mar 2018 17:34:03 +0000 (19:34 +0200)]
Fix ARM NDEBUG Builds

Change-Id: I1250744d54b75d6380393afe848a6eb8c5dc894d

6 years agominix/tests/arm: naive tests to cause data aborts 18/3518/2
Arne Welzel [Thu, 22 Mar 2018 14:47:36 +0000 (15:47 +0100)]
minix/tests/arm: naive tests to cause data aborts

Some assembly code to cause unaligned access as well as
segmentation faults to exercise the data abort path.

Change-Id: Ie419114b76a8db849537a94fda781019cf14d50d

6 years agokernel/arm: send SIGSEGV to processes 17/3517/2
Arne Welzel [Thu, 22 Mar 2018 13:27:32 +0000 (14:27 +0100)]
kernel/arm: send SIGSEGV to processes

On second thought, handle unknown faults caused by processes by sending
SIGSEGV to them instead of bringing the whole system to a grind.

arm/archconst: use values defined in armreg.h

Change-Id: Ieed5bb06910ab0c8eef1e68b0b4eec680867acd3

6 years agobsd.own.mk: use -mno-unaligned-access on ARM 15/3515/1
Arne Welzel [Wed, 21 Mar 2018 19:29:58 +0000 (20:29 +0100)]
bsd.own.mk: use -mno-unaligned-access on ARM

Without this option, gcc may emit code accessing unaligned memory. This,
and the fact that SCTRL.A (System Control Register - Alignment Check) is
set to 1 in Minix causes data aborts when such code is encountered.

This was the cause of #104. The `minix-service' executable caused
unaligned memory accesses calling into getpwnam(). These then trigger
data abort exceptions. On ARM, these were previously forwarded to `vm'
as pagefaults. However, `vm' did not properly handle them, but instead
allocated one page for the faulting address (over and over again) and
then resumed the process at the faulting instruction (over and over
again). This behavior masked the whole story as an OOM.

Below the assembly version getpwent.c in which unaligned memory
accesses are even highlighted...

 ...
 341         ldr     lr, [sp, #48]
 342         cmp     lr, #0
 343         bne     .L46
 344         ldr     r0, [r4]        @ unaligned
 345         add     r1, r7, #5
 346         str     r0, [sp, #4]    @ unaligned
 347         ldr     r4, [sp, #4]
 348         mov     r5, r4, asr #31
 349         strd    r4, [r8, #40]
 ...

This should fix #104. It was tested on an actual Beaglebone Black.

An alternative fix would be to disable alignment checking by setting
SCTRL.A to 0 and allowing unaligned memory accesses.

Change-Id: I4d366eb0af1b2936bca369fd28014fb829228ad5

6 years agokernel/arm: do not treat all data aborts as pagefaults 14/3514/1
Arne Welzel [Wed, 21 Mar 2018 21:01:17 +0000 (22:01 +0100)]
kernel/arm: do not treat all data aborts as pagefaults

For now, distinguish alignment, translation and permission faults.
The first kind of faults cause the kernel to send SIGBUS to the
process causing the fault, the latter two are forwarded to `vm' as
pagefaults. Previously, any data abort was forwarded to `vm' as
a pagefault, resulting in hard to debug issue #104.

Any unhandled fault status results in a disaster. This seems
better than naively hoping `vm' can do something about it.

Change-Id: I526f575bb2681e087e20fd49c5c0846cdd450c31

6 years agoFix brazilian ABNT2 keymap 13/3513/1
Marcelo Alencar [Mon, 5 Mar 2018 02:51:13 +0000 (02:51 +0000)]
Fix brazilian ABNT2 keymap

This adds two missing keys (0x73 and 0x7e) and fixes KP_PERIOD (it
should type a comma, not a period), as mentioned in

https://groups.google.com/d/msg/minix3/Pezep_HOL3I/mnfZXAeLsTMJ

Closes #247

Change-Id: Id85d04e36adcaa1a502cac8e5013396ea92502fe

6 years agoremove a duplicate include 12/3512/1
blackdragonepic [Mon, 29 Jan 2018 02:53:46 +0000 (21:53 -0500)]
remove a duplicate include

removed #include <minix/type.h> duplicate

Closes #246

Change-Id: Icd575c452d562eb601133157a77d9d995ce043e9

6 years agoUpdate usage man page: remove reference to /usr/ast 11/3511/1
Nik Nyby [Wed, 10 Jan 2018 04:31:58 +0000 (23:31 -0500)]
Update usage man page: remove reference to /usr/ast

This directory no longer exists, probably since the netbsd file layout
re-organization.

Closes #244

Change-Id: Ie4e3761dbf3adbdd76cb6323f920a4abab6b29d5

6 years agofs/mfs: Remove a few assert.h includes 10/3510/1
Nik Nyby [Tue, 9 Jan 2018 01:36:48 +0000 (20:36 -0500)]
fs/mfs: Remove a few assert.h includes

Those are unnecessary.

Closes #241

Change-Id: I26db0f07c65e7d078e642001b97e6d4313e6660a

6 years agomkfs.mfs: fix typo in error message 09/3509/1
Nik Nyby [Tue, 9 Jan 2018 04:55:18 +0000 (23:55 -0500)]
mkfs.mfs: fix typo in error message

Closes #242

Change-Id: I91ec2b36b2abfa897a43c97d886578fd28a5c768

6 years agopci server crashes during boot on Qubes OS 06/3506/2
Krystian Lewandowski [Wed, 15 Nov 2017 17:29:06 +0000 (18:29 +0100)]
pci server crashes during boot on Qubes OS

I tried to launch Minix3 in Qubes OS. While there is no problem to boot
minix as a qube (in Qubes OS terminology) before 3641562, it fails with
the commit (and after). I didn't digg into PCI handling but this change
fixes the problem. Minix handles NULL case from pci_subclass_name.

Change-Id: I162424d92b613598e6eb845a71f90a02e31041db

7 years agoARM: Remove dependency on mtools 05/3505/1
Jean-Baptiste Boric [Wed, 12 Jul 2017 06:16:13 +0000 (08:16 +0200)]
ARM: Remove dependency on mtools

Instead of formatting the image, and then using the mtools to copy on it
the boot partition files, we use makefs to directly generate the
partition.

Change-Id: I468e3100842177f3f55edbfdb910941bafa576ba

7 years agoFixed broken multiboot struct 04/3504/1
rlfnb [Tue, 4 Jul 2017 07:08:53 +0000 (09:08 +0200)]
Fixed broken multiboot struct

Change-Id: Ib59fb04a45c4417588bf204a5a6e6306f5097e22

7 years agoreplace tickdelay with micro_delay to be quantum-agnostic 03/3503/1
rlfnb [Thu, 1 Jun 2017 09:02:25 +0000 (11:02 +0200)]
replace tickdelay with micro_delay to be quantum-agnostic

Change-Id: Ie449d797389a178372035d797c84b02d636788cd

7 years agoisofs: support directories with many entries 02/3502/1
David van Moolenbroek [Wed, 17 May 2017 23:21:45 +0000 (23:21 +0000)]
isofs: support directories with many entries

In particular, remove the hardcoded limit of 4096 entries in a single
directory, as there are (at least) real DVDs out there with more
entries than that.  The implementation of this change requires a
second pass on large directories; performance optimizations are left
to future work.

Change-Id: Ia865ac95797fa2dd36b086779c3f1fef6b2f6a6f

7 years agoat_wini: bump hardcoded ATAPI limit to DVD size 01/3501/1
David van Moolenbroek [Wed, 17 May 2017 23:16:52 +0000 (23:16 +0000)]
at_wini: bump hardcoded ATAPI limit to DVD size

at_wini was previously hardcoded to present ATAPI devices as having a
size of 800 MiB, which was enough for CDs but not for DVDs.  This
patch increases the device size to 8500 MiB, which should be large
enough to cover all DVDs.

Change-Id: I7d3192e4ecd0708a655663c1007ff517ed969580

7 years agoFix Makefile.boot small issue sync'ing with NetBSD 00/3500/1
Antoine Leca [Mon, 8 May 2017 12:15:09 +0000 (12:15 +0000)]
Fix Makefile.boot small issue sync'ing with NetBSD

Change-Id: I4f8cbfb9d4b6be8b31ce705cbecc4b12b7e1fe45

7 years agoFix lua 99/3499/1
David van Moolenbroek [Mon, 8 May 2017 11:53:38 +0000 (11:53 +0000)]
Fix lua

As reported by Jean-Baptiste Boric, lua would refuse to start,
throwing an error about incompatibility of numeric types.

This resolves #160.

Change-Id: I5cd6c3b2a35c7023946e4d14d4feedaaecb956fb

7 years agoheader cleanup 98/3498/1
rlfnb [Wed, 26 Apr 2017 22:51:30 +0000 (00:51 +0200)]
header cleanup

Change-Id: I4e169911591c56e91c301c5cb0bb3ea2d8140cf2

7 years agoFix pkgin_cd.sh 97/3497/2
Jean-Baptiste Boric [Tue, 11 Apr 2017 16:21:50 +0000 (18:21 +0200)]
Fix pkgin_cd.sh

Change-Id: I513c16b0691897f3c665532d50ed398967f3e4d0

7 years agoAdd releasetools/pkgsrc_cdimage.sh 96/3496/2
Jean-Baptiste Boric [Tue, 11 Apr 2017 16:19:55 +0000 (18:19 +0200)]
Add releasetools/pkgsrc_cdimage.sh

This script uses the image generation framework to create a pkgsrc CD
image, useful for MINIX installations without Internet connectivity.

Change-Id: Ife037f6b6958e38986afad0632f37999ecbb2b55

7 years agoRework package bundling mechanism 95/3495/2
Jean-Baptiste Boric [Tue, 11 Apr 2017 16:12:47 +0000 (18:12 +0200)]
Rework package bundling mechanism

Setting PACKAGE_DIR without PACKAGES will default to bundling all
packages in PACKAGE_DIR. PKG_INFO is also mandatory now.

Change-Id: Iaf02221ec91e9c54dc8caec6e9a01bccfc65cc31

7 years agoRemoved unused variable and cleaned whitespaces 94/3494/2
Ben Mezger [Thu, 16 Mar 2017 16:00:53 +0000 (13:00 -0300)]
Removed unused variable and cleaned whitespaces

Change-Id: Iaaf6b6f5f49f2d2599a3422250ad7e6e41838b82

7 years agoRemoved unused variables and cleaned whitespaces. 93/3493/2
Ben Mezger [Thu, 16 Mar 2017 15:56:01 +0000 (12:56 -0300)]
Removed unused variables and cleaned whitespaces.

Change-Id: Ib96d1c5bf7a1c65a99d77726fe54ccf37399f9eb

7 years agoRemoved unused variables and cleaned whitespaces. 92/3492/2
Ben Mezger [Thu, 16 Mar 2017 15:51:03 +0000 (12:51 -0300)]
Removed unused variables and cleaned whitespaces.

Change-Id: Ie5c1ad84ad162ab18443dd228686aba544ecb9ef

7 years agoPrevent arg from being used any further 91/3491/2
Ben Mezger [Thu, 16 Mar 2017 15:30:27 +0000 (12:30 -0300)]
Prevent arg from being used any further

Patch edited by David van Moolenbroek.

Change-Id: Ie25faffea359e735145dbb4ae2bd2d213488952b

7 years agodistrib: fix debug builds 90/3490/1
David van Moolenbroek [Sat, 6 May 2017 12:43:03 +0000 (14:43 +0200)]
distrib: fix debug builds

Reported by Jean-Baptiste Boric.

Change-Id: I1e9b156326385aa188c824557b6716c059e39fce

7 years agoNetwork stack feedback-based fixes 89/3489/1 213/head
David van Moolenbroek [Sun, 30 Apr 2017 15:33:24 +0000 (15:33 +0000)]
Network stack feedback-based fixes

Thanks to Lionel Sambuc!

Change-Id: Iae6b2caf58e2b58093e60c5004cfa477e43da154

7 years agotests: add advanced TCP/IP tests (test91-94) 88/3488/2
David van Moolenbroek [Thu, 29 Sep 2016 23:16:22 +0000 (23:16 +0000)]
tests: add advanced TCP/IP tests (test91-94)

Change-Id: I052102f6122f82b3307595990bf91f64e97a45a8

7 years agoImport NetBSD networking rc scripts 87/3487/2
David van Moolenbroek [Thu, 23 Feb 2017 21:57:15 +0000 (21:57 +0000)]
Import NetBSD networking rc scripts

IMPORTANT: this change has a docs/UPDATING entry!

Change-Id: I6f1e575166f5b47530a004c12aea9b45b571e13d

7 years agonetconf(8): rewrite 86/3486/2
David van Moolenbroek [Tue, 21 Feb 2017 23:34:25 +0000 (23:34 +0000)]
netconf(8): rewrite

When possible, network drivers are now started automatically.  That
means that netconf(8)'s network driver selection has become obsolete.
This patch changes netconf(8) to allow the user to specify a network
configuration (currently one of DHCP IPv4+IPv6, DHCP IPv4-only,
manual IPv4-only) for any hardware network interfaces that are
currently present.

Selection of network drivers that require manual configuration first
(mainly old ISA cards) is still supported, but now as a special case.

Change-Id: I6208fc75192eb7f0b061862aaf7507f71a620da4

7 years agoetc/rc: start lwip service 85/3485/2
David van Moolenbroek [Mon, 20 Feb 2017 14:07:55 +0000 (14:07 +0000)]
etc/rc: start lwip service

Change-Id: I10cfdcde490987b93c79532a2c53dda2307b83ce

7 years agoetc/rc: auto-start PnP ethernet drivers 84/3484/2
David van Moolenbroek [Mon, 20 Feb 2017 14:06:59 +0000 (14:06 +0000)]
etc/rc: auto-start PnP ethernet drivers

Change-Id: I0f6c955511cbb04d47093de28109b5084609856a

7 years agotests: adapt existing tests to new LWIP service 83/3483/2
David van Moolenbroek [Thu, 29 Sep 2016 23:08:31 +0000 (23:08 +0000)]
tests: adapt existing tests to new LWIP service

Change-Id: Id744e9d3fbe19733557011f8803593cf3768c35d

7 years agoping(8), traceroute(8): adapt to new LWIP service 82/3482/2
David van Moolenbroek [Thu, 29 Sep 2016 23:19:31 +0000 (23:19 +0000)]
ping(8), traceroute(8): adapt to new LWIP service

Change-Id: I0aae7199dfd9075201975e133cdaeab6bc2bd24f

7 years agoAdd lwip: a new lwIP-based TCP/IP service 81/3481/2
David van Moolenbroek [Thu, 29 Sep 2016 23:07:07 +0000 (23:07 +0000)]
Add lwip: a new lwIP-based TCP/IP service

This commit adds a new TCP/IP service to MINIX 3.  As its core, the
service uses the lwIP TCP/IP stack for maintenance reasons.  The
service aims to be compatible with NetBSD userland, including its
low-level network management utilities.  It also aims to support
modern features such as IPv6.  In summary, the new LWIP service has
support for the following main features:

- TCP, UDP, RAW sockets with mostly standard BSD API semantics;
- IPv6 support: host mode (complete) and router mode (partial);
- most of the standard BSD API socket options (SO_);
- all of the standard BSD API message flags (MSG_);
- the most used protocol-specific socket and control options;
- a default loopback interface and the ability to create one more;
- configuration-free ethernet interfaces and driver tracking;
- queuing and multiple concurrent requests to each ethernet driver;
- standard ioctl(2)-based BSD interface management;
- radix tree backed, destination-based routing;
- routing sockets for standard BSD route reporting and management;
- multicast traffic and multicast group membership tracking;
- Berkeley Packet Filter (BPF) devices;
- standard and custom sysctl(7) nodes for many internals;
- a slab allocation based, hybrid static/dynamic memory pool model.

Many of its modules come with fairly elaborate comments that cover
many aspects of what is going on.  The service is primarily a socket
driver built on top of the libsockdriver library, but for BPF devices
it is at the same time also a character driver.

Change-Id: Ib0c02736234b21143915e5fcc0fda8fe408f046f

7 years agoRMIB: add indirection support for sparse subtrees 80/3480/2
David van Moolenbroek [Fri, 30 Sep 2016 21:55:33 +0000 (21:55 +0000)]
RMIB: add indirection support for sparse subtrees

Normally, each RMIB subtree consists of an array of nodes, indexed
by node identifier.  In a sparsely filled subtree, most of the array
is empty and just wasting memory.  In that case, it may be beneficial
to have a level of indirection, with an intermediate array containing
pairs of node IDs and pointers to the actual nodes.  This patch adds
support for such indirection.

For the use cases that inspired this patch, net.inet and net.inet6,
the indirection shaves off a little under 16KB of memory from the
TCP/IP service.

Change-Id: Ic68ca3fee1a0f2032f77eef6df42728f9b9400e8

7 years agolibsys: allow for grant preallocation 79/3479/2
David van Moolenbroek [Fri, 4 Nov 2016 17:31:40 +0000 (17:31 +0000)]
libsys: allow for grant preallocation

Since the grant table is allocated dynamically, a system service always
runs the risk of running out of memory at run time when trying to
allocate a grant.  In order to allow services to mitigate that risk,
grants can now be preallocated, typically at system service startup,
using the new cpf_prealloc(3) libsys function.  The function takes a
'count' parameter that indicates the number of additional grants to
preallocate.  Thus, the function may be called from multiple submodules
within a service, each preallocating their own maximum of grants that
it may need at run time.

Change-Id: I6904726a722a8c27dfe2efa470e683718f310272

7 years agoImport new lwIP version into liblwip 78/3478/2
David van Moolenbroek [Thu, 29 Sep 2016 23:26:40 +0000 (23:26 +0000)]
Import new lwIP version into liblwip

In order to match NetBSD-style imports of external code, the library
has been restructured.  The full lwIP source tree is imported, except
for a few .git* files in its root directory, into dist/.  The MINIX 3
Makefiles and other custom files are located in lib/.  Finally, since
we need to apply a number of small patches to lwIP, these patches are
stored in patches/, in addition to being applied to the lwIP tree.

The currently imported version of lwIP is taken from its master
branch sometime after the 2.0.1 release, specifically git-7ffe5bf.

Change-Id: Ie03c4fa36fa928870263c191205d6d93f652a3cc

7 years agolance: perform full reinitialization for restarts 77/3477/2
David van Moolenbroek [Sun, 26 Feb 2017 16:04:50 +0000 (16:04 +0000)]
lance: perform full reinitialization for restarts

When performing a restart (CSR0 STOP, STRT), the behavior regarding
the NIC's current RX/TX descriptor ring counters varies between cards:
older LANCE cards do not reset the counters; newer PCnet cards do
reset them; VirtualBox's emulation is once again broken in that it
claims to emulate newer cards but implements the older behavior.

Changing the card's receive mode requires such a restart, and now that
the system can actually change receive modes dynamically as part of
normal network operation, this results in the lance driver breaking
all the time on at least VirtualBox.

Instead of trying to figure out exactly what is going on with the
counters during a restart, we now simply perform a full-blown
reinitialization every time the NIC is restarted.  That leaves no
ambiguity regarding the counters, and appears to be what drivers on
other OSes do as well.  As a bonus, this approach actually saves code.

Change-Id: I60fad2df6de4616d5de2cec39c09b60c15d854fb

7 years agolibnetdriver: rewrite 76/3476/2
David van Moolenbroek [Wed, 12 Oct 2016 04:41:08 +0000 (04:41 +0000)]
libnetdriver: rewrite

This is a driver-breaking update to the netdriver library, which is
used by all network drivers.  The aim of this change is to make the
library more compatible with NetBSD, and in particular with various
features that are expected to be supported by the NetBSD userland.
The main changes made by this patch are the following:

- each network driver now has a NetBSD-style short device name;
- drivers are not expected to receive packets right after startup;
- extended support for receipt modes, including multicast lists;
- support for multiple parallel send, receive requests;
- embedding of I/O vectors in send and receive requests;
- support for capabilities, including checksum offloading;
- support for reporting link status updates to the TCP/IP stack;
- support for setting and retrieving media status;
- support for changing the hardware (MAC) address;
- support for NetBSD interface flags IFF_DEBUG, IFF_LINK[0-2];
- support for NetBSD error statistics;
- support for regular time-based ("tick") callbacks.

IMPORTANT: this patch applies a minimal update to the existing drivers
in order to make them work at all with the new netdriver library.  It
however does *not* change all drivers to make use of the new features.
In fact, strictly speaking, all drivers are now violating requirements
imposed by the new library in one way or another, most notably by
enabling packet receipt when starting the driver.  Changing all the
drivers to be compliant, and to support the newly added options, is
left to future patches.  The existing drivers should currently *not*
be taken as examples of how to implement a new network driver!

With that said, a few drivers have already been changed to make use of
some of the new features: fxp, e1000, rtl8139, and rtl8169 now report
link and media status, and the last three of those now support setting
the hardware MAC address on the fly.  In addition, dp8390 has been
changed to default to PCI autoconfiguration if no configuration is
specified through environment variables.

Change-Id: I4b3ea9c0b9bc25d5b0609c6ff256fb0db71cdc42

7 years agosyslogd(8): drop some MINIX-specific changes 75/3475/1
David van Moolenbroek [Fri, 17 Feb 2017 11:41:41 +0000 (11:41 +0000)]
syslogd(8): drop some MINIX-specific changes

Change-Id: Ic286b89975eeea1abf0d5086ee13dfb9ab57d8ba

7 years agoftpd(8): drop some MINIX-specific changes 74/3474/1
David van Moolenbroek [Sun, 5 Mar 2017 16:13:32 +0000 (16:13 +0000)]
ftpd(8): drop some MINIX-specific changes

Also put in a crude way to clean up zombies when ftpd(8) is running
in daemon mode, because we do not yet support SA_NOCLDWAIT.

Change-Id: I8a7db1d665c432d736db833b0022d0340764db1f

7 years agoImport NetBSD httpd(8) 73/3473/1
David van Moolenbroek [Sun, 5 Mar 2017 16:03:54 +0000 (16:03 +0000)]
Import NetBSD httpd(8)

Also known as bozohttpd(8).

Change-Id: I40e955b5654674f2c708b10e5e403ca9cbc92534

7 years agoImport NetBSD rtadvd(8) 72/3472/1
David van Moolenbroek [Sun, 19 Feb 2017 14:27:23 +0000 (14:27 +0000)]
Import NetBSD rtadvd(8)

Change-Id: I22626843d85c78f0fadefd58d61d7a85d285b2b8

7 years agoImport NetBSD ndp(8) 71/3471/1
David van Moolenbroek [Sun, 19 Feb 2017 01:14:53 +0000 (01:14 +0000)]
Import NetBSD ndp(8)

Like arp(8), this utility already uses the NetBSD 8 protocol for
talking to the operating system through routing sockets.

Like arp(8), this utility is not fully functional, due to limitations
of lwIP.  While ndp(8) should provide a proper (read-only) view of the
contents of the Neighbor Discovery table, any attempts to modify the
table will fail.  In addition, various other ndp(8) features are not
supported.  On MINIX 3, the prefix and default router lists are not
managed by the operating system however, but rather by dhcpcd(8);
therefore, an implementation of the features related to those lists
would not provide any actual functionality.

Change-Id: I479bfc8141ba69fe50c1b2f7091933267ce6fa3e

7 years agoImport NetBSD tcpdump(8) 70/3470/1
David van Moolenbroek [Sun, 19 Feb 2017 00:56:10 +0000 (00:56 +0000)]
Import NetBSD tcpdump(8)

For now, printing of Sun RPC requests is disabled because we do not
yet have the RPC header files.  This should affect basically noone,
as we do not have any RPC-based programs yet, for the same reason.

Change-Id: Ie7818faaaacdc104d8b2c37a68866b4ce18247d6

7 years agoImport NetBSD libpcap 69/3469/1
David van Moolenbroek [Sun, 19 Feb 2017 00:34:03 +0000 (00:34 +0000)]
Import NetBSD libpcap

As part of this, we import bpf_filter.c from NetBSD.  Even though that
file is part of the NetBSD kernel, it is also used by userland (as is
clear here).  Our LWIP service has its own bpf_filter.c implementation
but that implementation has certain limits (e.g. on program size) that
are fine for a system service but should not apply to userland.

The libpcap code has a number of blocks guarded by __NetBSD__, but
none of those blocks apply to MINIX 3.  In particular, some of the
alignment logic used for NetBSD may in fact not work in our case.

Change-Id: Ib187e22d627c929e111d5d4a991c3bee3c0154cb

7 years agoImport NetBSD dhclient(8), dhcpd(8), dhcrelay(8) 68/3468/1
David van Moolenbroek [Thu, 16 Feb 2017 16:31:25 +0000 (16:31 +0000)]
Import NetBSD dhclient(8), dhcpd(8), dhcrelay(8)

dhcrelay(8) and omshell(1) have not been tested.

Change-Id: I0cad89f65666af4e366a86e130ce8df0894c3bb4

7 years agoImport NetBSD named(8) 67/3467/1
David van Moolenbroek [Thu, 16 Feb 2017 17:11:19 +0000 (17:11 +0000)]
Import NetBSD named(8)

Also known as ISC bind.  This import adds utilities such as host(1),
dig(1), and nslookup(1), as well as many other tools and libraries.

Change-Id: I035ca46e64f1965d57019e773f4ff0ef035e4aa3

7 years agoImport NetBSD dhcpcd(8) 66/3466/1
David van Moolenbroek [Thu, 16 Feb 2017 15:54:23 +0000 (15:54 +0000)]
Import NetBSD dhcpcd(8)

The port could be improved by adding support for pselect(2).

Other than that, this port has a few MINIX-specific changes:

- we undefine IN_IFF_ flags to stop dhcpcd from thinking that we have
  operating system support for link-local IPv4 address management;
- we work around one crash bug that seems triggered by using dhcpcd
  on some but not all interfaces;
- we add "noalias" to the default dhcpcd.conf(5) configuration file.

Change-Id: I8a81c2c2af353c5ce08335673b1ab2d4b39178da

7 years agoImport NetBSD resolvconf(8) 65/3465/1
David van Moolenbroek [Thu, 16 Feb 2017 13:21:17 +0000 (13:21 +0000)]
Import NetBSD resolvconf(8)

Also known as "openresolv".  Needed for dhcpcd(8).

Change-Id: Ibcb616837e9a5293377e451c6f6218a37260ed80

7 years agoImport NetBSD inetd(8) 64/3464/1
David van Moolenbroek [Wed, 15 Feb 2017 20:53:10 +0000 (20:53 +0000)]
Import NetBSD inetd(8)

Do not start it by default just yet.

Change-Id: Id8d2dd33eb67ae74b3ef3060638e20c781e8e37d

7 years agoImport NetBSD telnetd(8) 63/3463/1
David van Moolenbroek [Wed, 15 Feb 2017 20:36:35 +0000 (20:36 +0000)]
Import NetBSD telnetd(8)

Change-Id: Ie1ae80e8a4945f6f4ccce8f468c1b04a8d89cf43

7 years agoImport NetBSD telnet(1) 62/3462/1
David van Moolenbroek [Wed, 15 Feb 2017 17:41:07 +0000 (17:41 +0000)]
Import NetBSD telnet(1)

Change-Id: Ib58b43cc9baabe183a59410212827f65ec117277

7 years agoImport NetBSD traceroute6(8) 61/3461/1
David van Moolenbroek [Wed, 15 Feb 2017 17:31:54 +0000 (17:31 +0000)]
Import NetBSD traceroute6(8)

Change-Id: I040651cf29a9efd6b85afafe6813e48c2f1a4f2d

7 years agoImport NetBSD ping6(8) 60/3460/1
David van Moolenbroek [Wed, 15 Feb 2017 17:16:18 +0000 (17:16 +0000)]
Import NetBSD ping6(8)

Change-Id: Ife49f5fac0e50852c74a0f85b6129c204d172c68

7 years agoImport NetBSD arp(8) 59/3459/1
David van Moolenbroek [Wed, 15 Feb 2017 13:02:59 +0000 (13:02 +0000)]
Import NetBSD arp(8)

Behaviorally this port should already be largely on par with the
NetBSD 8 version, in that it sets the RTF_LLDATA flag on routing
socket requests to indicate that they target link-local data.

Many parts of the arp(8) functionality are currently not yet supported
by the operating system, largely due to lwIP not exposing appropriate
means of implementing them.

Change-Id: Icfac054b4deddda03eee4acf0e261aa48cd031ba

7 years agoImport NetBSD netstat(1) 58/3458/1
David van Moolenbroek [Wed, 15 Feb 2017 12:35:47 +0000 (12:35 +0000)]
Import NetBSD netstat(1)

The port forces the use of sysctl(7), as obtaining information through
KVM is not and will never be viable.  The sysctl mode of netstat(1) is
currently somewhat limited and buggy, though.  We fix a few minimal
issues, but more improvements will have to come from NetBSD reimports.

Some of netstat(1)'s views are currently not supported by the
operating system.  Later improvements on this point will not require
changes to the imported code, though.

Change-Id: If74a6811f0fc81bd1ecc31010a28379b14b2a0eb

7 years agoImport NetBSD route(8) 57/3457/1
David van Moolenbroek [Wed, 15 Feb 2017 12:08:12 +0000 (12:08 +0000)]
Import NetBSD route(8)

Change-Id: I724a2a56157ea72afdd3f6a82239687894c8e3e8

7 years agoImport NetBSD ifconfig(8) 56/3456/1
David van Moolenbroek [Wed, 15 Feb 2017 11:17:52 +0000 (11:17 +0000)]
Import NetBSD ifconfig(8)

Not all of its functionality is actually implemented in the operating
system.  In addition, a few modules (agr, vlan) have been disabled
because we have not imported the necessary headers yet.

Change-Id: I4c9271065d640bd9112b4bd27e2652e1d51b18b4

7 years agoImport NetBSD libwrap 55/3455/1
David van Moolenbroek [Fri, 17 Feb 2017 11:40:49 +0000 (11:40 +0000)]
Import NetBSD libwrap

Change-Id: Ib8b979fb9a96c2048b8ea93038944c743048bff4

7 years agoImport NetBSD nsswitch.conf(5) 54/3454/1
David van Moolenbroek [Thu, 23 Feb 2017 18:43:50 +0000 (18:43 +0000)]
Import NetBSD nsswitch.conf(5)

Change-Id: I0464b474d50b39cd6259c492e1fae6fecfd9d984

7 years agoImport NetBSD hosts(5) 53/3453/1
David van Moolenbroek [Tue, 14 Feb 2017 23:22:42 +0000 (23:22 +0000)]
Import NetBSD hosts(5)

Change-Id: I0924dcc7d4eb9151b77305f370360722d4a7533a

7 years agolibutil: drop some MINIX-specific changes 52/3452/1
David van Moolenbroek [Sun, 5 Mar 2017 17:26:14 +0000 (17:26 +0000)]
libutil: drop some MINIX-specific changes

Change-Id: I8deeac84deb4a986b62caabe96c8f7c722d97921

7 years agoEnable IPv6 support 51/3451/1
David van Moolenbroek [Tue, 14 Feb 2017 22:19:53 +0000 (22:19 +0000)]
Enable IPv6 support

Change-Id: I3f68c38ca5efbecd04941064542ed24004db1429

7 years agoEnable a few more NetBSD functions 50/3450/1
David van Moolenbroek [Tue, 14 Feb 2017 22:14:15 +0000 (22:14 +0000)]
Enable a few more NetBSD functions

Change-Id: Ia8463adfb12b465bd43a62aee9f14b21eaa13b19

7 years agoPTY: add minimal support for TIOCPKT 49/3449/1
David van Moolenbroek [Wed, 15 Feb 2017 19:27:45 +0000 (19:27 +0000)]
PTY: add minimal support for TIOCPKT

With TIOCPKT enabled, each piece of output is preceded by a zero byte
on the PTY master.  In addition, a non-zero byte is a flags field
that conveys information about changes on the pseudoterminal.  This
patch implements the former, but not the latter.  That is enough to
get telnetd(8) going, however.  TIOCPKT support may be extended later.

Change-Id: I6ef9cc8cf1b4406147b088400fc8499684b62a30

7 years agoRetire MINIX rlogin(1) 48/3448/1
David van Moolenbroek [Tue, 14 Feb 2017 18:56:20 +0000 (18:56 +0000)]
Retire MINIX rlogin(1)

Change-Id: Ib85e74e5333e8fffa05631dbc760284761bf3ecb

7 years agoRetire MINIX rget(1), rput(1) 47/3447/1
David van Moolenbroek [Tue, 14 Feb 2017 18:53:43 +0000 (18:53 +0000)]
Retire MINIX rget(1), rput(1)

Change-Id: I70e3ec9281275730c589fb7683801dc1ca584cab

7 years agoRetire MINIX in.telnetd(8) 46/3446/1
David van Moolenbroek [Tue, 14 Feb 2017 18:51:12 +0000 (18:51 +0000)]
Retire MINIX in.telnetd(8)

Change-Id: Ib54998e7a81f924d19b8013ef567703996d24a03

7 years agoRetire MINIX telnet(1) 45/3445/1
David van Moolenbroek [Tue, 14 Feb 2017 18:48:16 +0000 (18:48 +0000)]
Retire MINIX telnet(1)

..which, for some strange reason, was installed as "ttn".

Change-Id: I5ad2f969ad7978a27fb7345f8434470ca427d429

7 years agoRetire MINIX rarpd(8) 44/3444/1
David van Moolenbroek [Tue, 14 Feb 2017 18:43:37 +0000 (18:43 +0000)]
Retire MINIX rarpd(8)

Change-Id: I2d7b7edbb8fa6000ba368d156cf947e7691cf454

7 years agoRetire MINIX irdpd(8) 43/3443/1
David van Moolenbroek [Tue, 14 Feb 2017 18:38:28 +0000 (18:38 +0000)]
Retire MINIX irdpd(8)

Change-Id: Id11c6db9db5da18346d993cb9c3faa4313ed3ed4

7 years agoRetire MINIX arp(8) 42/3442/1
David van Moolenbroek [Tue, 14 Feb 2017 18:31:45 +0000 (18:31 +0000)]
Retire MINIX arp(8)

Change-Id: I8351fbb99d73811282e46dae7fae1b6abb130bf2

7 years agoRetire MINIX tcpd(8) 41/3441/1
David van Moolenbroek [Tue, 14 Feb 2017 18:24:20 +0000 (18:24 +0000)]
Retire MINIX tcpd(8)

Change-Id: If419d441c5df0b9f2e29db1ef0d904d102739f9b

7 years agoRetire MINIX host(1) 40/3440/1
David van Moolenbroek [Tue, 14 Feb 2017 17:55:19 +0000 (17:55 +0000)]
Retire MINIX host(1)

Change-Id: I19d2e866d6d397d3bff9ba698cb8ec26267ee82c

7 years agoRetire MINIX dhcpd(8) 39/3439/1
David van Moolenbroek [Tue, 14 Feb 2017 17:50:02 +0000 (17:50 +0000)]
Retire MINIX dhcpd(8)

Change-Id: I4b8c738b6176ce390a7a7817b0dcaf9caffe636c

7 years agoRetire MINIX hostaddr(1) 38/3438/1
David van Moolenbroek [Tue, 14 Feb 2017 17:43:49 +0000 (17:43 +0000)]
Retire MINIX hostaddr(1)

Change-Id: I30c7b5fe4c96ea040c3eea46f1dc4d9bd135745d

7 years agoRetire MINIX nonamed(8) 37/3437/1
David van Moolenbroek [Tue, 14 Feb 2017 17:34:20 +0000 (17:34 +0000)]
Retire MINIX nonamed(8)

Also retire support for the MINIX versions of /etc/hosts and
/etc/resolv.conf.  These files will be brought back with NetBSD
imports, although like NetBSD, MINIX 3 will be using external
resolvers directly from then on.  Since resolv.conf is hand-created
rather than installed, we do not mark it as obsolete.

Change-Id: Ie6154d5a4d8d977c19b9754bf920ae868680e9d1

7 years agoRetire MINIX pr_routes(8) 36/3436/1
David van Moolenbroek [Tue, 14 Feb 2017 17:19:12 +0000 (17:19 +0000)]
Retire MINIX pr_routes(8)

Change-Id: Ic7494d097f9d19185b7173edb7590044baee5abc

7 years agoRetire MINIX add_route(8) 35/3435/1
David van Moolenbroek [Tue, 14 Feb 2017 17:17:29 +0000 (17:17 +0000)]
Retire MINIX add_route(8)

Change-Id: I900a3c6ac8e8fac15f5f84960bb89f92aeb90863

7 years agoRetire MINIX ifconfig(8) 34/3434/1
David van Moolenbroek [Tue, 14 Feb 2017 17:08:55 +0000 (17:08 +0000)]
Retire MINIX ifconfig(8)

Change-Id: I26f3ceff01bbd31e4c009752c7454a58e8a72abf

7 years agoRetire inet: the previous MINIX TCP/IP service 33/3433/1
David van Moolenbroek [Tue, 14 Feb 2017 15:26:43 +0000 (15:26 +0000)]
Retire inet: the previous MINIX TCP/IP service

This commit (temporarily) leaves MINIX 3 without a TCP/IP service.

Thanks go out to Philip Homburg for providing this TCP/IP stack in the
first place.  It has served MINIX well for a long time.

Change-Id: I0e3eb6fe64204081e4e3c2b9d6e6bd642f121973

7 years agoRetire lwip: the previous lwIP-based TCP/IP service 32/3432/1
David van Moolenbroek [Mon, 13 Feb 2017 22:52:16 +0000 (22:52 +0000)]
Retire lwip: the previous lwIP-based TCP/IP service

Change-Id: Id9bbf96344a6e9d796f6773547588a981e70bf0f

7 years agoRetire MINIX tcpstat(1), udpstat(1) 31/3431/1
David van Moolenbroek [Tue, 14 Feb 2017 16:22:04 +0000 (16:22 +0000)]
Retire MINIX tcpstat(1), udpstat(1)

This needs to be done before retiring inet itself, since these
utilities include headers from inet directly.

Also retire the now-obsolete paramvalue(3).

Change-Id: I9b27771190a6a32ee533b0c0d9d37f61a16ee36c

7 years agotests: add advanced UDS tests (test90) 30/3430/1
David van Moolenbroek [Thu, 21 Jul 2016 20:50:47 +0000 (20:50 +0000)]
tests: add advanced UDS tests (test90)

Change-Id: Ib4b81d441368fd9b7e7c7b9cab802bb01fa04065

7 years agoUDS: full rewrite 29/3429/1
David van Moolenbroek [Sun, 21 Feb 2016 22:59:04 +0000 (22:59 +0000)]
UDS: full rewrite

This new implementation of the UDS service is built on top of the
libsockevent library.  It thereby inherits all the advantages that
libsockevent brings.  However, the fundamental restructuring
required for that change also paved the way for resolution of a
number of other important open issues with the old UDS code.  Most
importantly, the rewrite brings the behavior of the service much
closer to POSIX compliance and NetBSD compatibility.  These are the
most important changes:

- due to the use of libsockevent, UDS now supports multiple suspending
  calls per socket and a large number of standard socket flags and
  options;
- socket address matching is now based on <device,inode> lookups
  instead of canonized path names, and socket addresses are no longer
  altered either due to canonization or at connect time;
- the socket state machine is now well defined, most importantly
  resolving the erroneous reset-on-EOF semantics of the old UDS, but
  also allowing socket reuse;
- sockets are now connected before being accepted instead of being
  held in connecting state, unless the LOCAL_CONNWAIT option is set
  on either the connecting or the listening socket;
- connect(2) on datagram sockets is now supported (needed by syslog),
  and proper datagram socket disconnect notification is provided;
- the receive queue now supports segmentation, associating ancillary
  data (in-flight file descriptors and credentials) with each segment
  instead of being kept fully separately; this is a POSIX requirement
  (and needed by tmux);
- as part of the segmentation support, the receive queue can now hold
  as many packets as can fit, instead of one;
- in addition to the flags supported by libsockevent, the MSG_PEEK,
  MSG_WAITALL, MSG_CMSG_CLOEXEC, MSG_TRUNC, and MSG_CTRUNC send and
  receive flags are now supported;
- the SO_PASSCRED and SO_PEERCRED socket options are replaced by
  LOCAL_CREDS and LOCAL_PEEREID respectively, now following NetBSD
  semantics and allowing use of NetBSD libc's getpeereid(3);
- memory usage is reduced by about 250 KB due to centralized in-flight
  file descriptor tracking, with a limit of OPEN_MAX total rather than
  of OPEN_MAX per socket;
- memory usage is reduced by another ~50 KB due to removal of state
  redundancy, despite the fact that socket path names may now be up to
  253 bytes rather than the previous 104 bytes;
- compared to the old UDS, there is now very little direct indexing on
  the static array of sockets, thus allowing dynamic allocation of
  sockets more easily in the future;
- the UDS service now has RMIB support for the net.local sysctl tree,
  implementing preliminary support for NetBSD netstat(1).

Change-Id: I4a9b6fe4aaeef0edf2547eee894e6c14403fcb32

7 years agoRMIB: expose full node path; improve restartability 28/3428/1
David van Moolenbroek [Fri, 30 Sep 2016 21:46:18 +0000 (21:46 +0000)]
RMIB: expose full node path; improve restartability

A single function may be used to handle the implementation of more
than one node.  In some cases, the behavior of that function may
depend on the path name used to reach the node.  Therefore, provide
the full path name as part of the call information.

As a result, RMIB has to save the paths for each of its remote MIB
mount points.  That in turn also allows it to autonomously remount its
mount points after a MIB service restart, thus bringing us a step
closer to proper recovery after a MIB crash without requiring the
service using RMIB to perform explicit steps.  As before, the missing
ingredient is actual notification of MIB service restarts, and proper
support for *that* will likely require changes to the DS service.

Change-Id: Ic0c79931d6f3a76c2c998047f8b47350fd0fa5b0

7 years agoPM/libsys: extend getepinfo, add getsockcred(3) 27/3427/1
David van Moolenbroek [Tue, 12 Jul 2016 14:46:27 +0000 (14:46 +0000)]
PM/libsys: extend getepinfo, add getsockcred(3)

The service-only getepinfo(2) PM call returns information about a
given endpoint.  This patch extends that call so that it returns
enough information to allow correctly filling a sockcred structure.
A new getsockcred(3) function is added to libsys to fill an actual
sockcred structure with the obtained information.  However, for the
caller's convenience, the groups list is kept separate.

Change-Id: I9f1a6d1a221c77eabaa3498ff4ec9a5fb922e4fd

7 years agolibsys: retire getnucred in favor of getepinfo 26/3426/1
David van Moolenbroek [Wed, 27 Jan 2016 23:24:56 +0000 (23:24 +0000)]
libsys: retire getnucred in favor of getepinfo

The getnucred() function was used by UDS to obtain credentials of user
processes in a form used in the UDS API, namely the ucred structure.
Since the NetBSD merge, this structure has changed drastically (aside
from being renamed to "uucred"), and it is no longer in UDS's best
interest to use this structure internally.  Therefore, getnucred() is
no longer a useful API either, and instead we directly use the
previously private getepinfo() function to obtain credentials.

Change-Id: I80bc809de716ec0a9b7497cb109d2f2708a629d5

7 years agoUDS: prepare for socket file creation in bind(2) 25/3425/1
David van Moolenbroek [Sun, 27 Dec 2015 19:35:12 +0000 (19:35 +0000)]
UDS: prepare for socket file creation in bind(2)

This patch prepares for moving of the creation of socket files on the
file system from the libc bind(2) stub into the UDS service.  This
change is necessary for the socket type agnostic libc implementation.
The change is not yet activated - the code that is not yet used is
enclosed in "#if NOT_YET" blocks.  The activation needs to be atomic
with UDS's switch to libsockdriver; otherwise, user applications may
break.

As part of the change, various UDS bind(2) semantics are changed to
match the POSIX standard and other operating systems.  In
implementation terms, the service-only VFS API checkperms(2) is
renamed to socketpath(2), and extended with a new subcall which
creates a new socket file.  An extension to test56 checks the new
bind(2) semantics of UDS, although most new tests are still disabled
until activation as well.

Finally, as further preparation for a more structural redesign of the
UDS service, also return the <device,inode> number pair for the
created or checked file name, and make returning the canonized path
name optional.

Change-Id: I892d04b3301d4b911bdc571632ddde65fb747a8a

7 years agoAdd libsockevent: a socket event dispatching library 24/3424/1
David van Moolenbroek [Thu, 21 Jul 2016 20:59:26 +0000 (20:59 +0000)]
Add libsockevent: a socket event dispatching library

This library provides an event-based abstraction model and dispatching
facility for socket drivers.  Its main goal is to eliminate any and
all need for socket drivers to keep track of pending socket calls.
Additionally, this library takes over responsibility of a number of
other tasks that would otherwise be duplicated between socket drivers,
but in such a way that individual socket drivers retain a large degree
of freedom in terms of API behavior.  The library's main features are:

- suspension, resumption, and cancellation of socket calls;
- an abstraction layer for select(2);
- state tracking of shutdown(2);
- pending (asynchronous) errors and the SO_ERROR socket option;
- listening-socket tracking and the SO_ACCEPTCONN socket option;
- generation of SIGPIPE signals; SO_NOSIGPIPE, MSG_NOSIGNAL;
- send and receive low-watermark tracking, SO_SNDLOWAT, SO_RCVLOWAT;
- send and receive timeout support and SO_SNDTIMEO, SO_RCVTIMEO;
- an abstraction layer for the SO_LINGER socket option;
- tracking of various on/off socket options as well as SO_TYPE;
- a range of pre-checks on socket calls that are required POSIX.

In order to track per-socket state, the library manages an opaque
"sock" object for each socket.  The allocation of such objects is left
entirely to the socket driver.  Each sock object has an associated
callback table for calls from libsockevent to the socket driver.  The
socket driver can raise events on the sock object in order to flag
that any previously suspended operations of a particular type should
be resumed.  The library may defer processing such raised events if
immediate processing could interfere with internal consistency.

The sockevent library is layered on top of libsockdriver, and should
be used by all socket driver implementations if at all possible.

Change-Id: I3eb2c80602a63ef13035f646473360293607ab76

7 years agoAdd libsockdriver: a library for socket drivers 23/3423/1
David van Moolenbroek [Sun, 21 Feb 2016 22:15:35 +0000 (22:15 +0000)]
Add libsockdriver: a library for socket drivers

This library provides abstractions for socket drivers, and should be
used as the basis for all socket driver implementations.  It provides
the following functionality:

  - a function call table abstraction, hiding the details of the
    socket driver protocol with simple parameters and presenting the
    socket driver with callback functions very similar to the BSD
    socket API calls made from userland;
  - abstracting data structures and helper functions for suspending
    and resuming blocking calls;
  - abstracting data structures and helper functions for copying data
    from and to the caller.

Overall, the library is similar to lib{block,char,fs,input,net}driver
in concept.  Some of the abstractions provided here should in fact be
applied to libchardriver as well.  As always, for the case that the
provided message loop is too restrictive, a set of more low-level
message processing functions is provided.

Change-Id: I79ec215f5e195c3b0197e223636f987d3755fb13

7 years agoVFS: support close-on-exec flag for copyfd(2) 22/3422/1
David van Moolenbroek [Wed, 20 Jul 2016 13:03:03 +0000 (13:03 +0000)]
VFS: support close-on-exec flag for copyfd(2)

The flag is supported only when copying out file descriptors (i.e.
COPYFD_TO).  It will be used by UDS to support MSG_CMSG_CLOEXEC.

Change-Id: I46bfd04b5f28e22ec48938e43e42f78d3931220d

7 years agoVFS: deny copying sockets to owning socket driver 21/3421/1
David van Moolenbroek [Wed, 20 Jul 2016 12:47:34 +0000 (12:47 +0000)]
VFS: deny copying sockets to owning socket driver

This patch stops a socket driver from using copyfd(2) to copy in a
file descriptor that is a reference to a socket owned by that socket
driver, returning EDEADLK instead.  In effect, this will stop deadlock
and resource exhaustion issues with UDS once it has been converted to
a socket driver.  See the comment in the patch for details.

Change-Id: I5728a405eabda207725618231a6ff7be2d517146

7 years agoVFS: support for suspending close(2) for sockets 20/3420/1
David van Moolenbroek [Mon, 25 Jul 2016 11:11:37 +0000 (11:11 +0000)]
VFS: support for suspending close(2) for sockets

This change effectively adds the VFS side of support for the SO_LINGER
socket option, by allowing file descriptor close operations to be
suspended (and later resumed) by socket drivers.  Currently, support
is limited to the close(2) system call--in all other cases where file
descriptors are closed (dup2, close-on-exec, process exit..), the
close operation still completes instantly.  As a general policy, the
close(2) return value will always indicate that the file descriptor
has been closed: either 0, or -1 with errno set to EINPROGRESS.  The
latter error may be thrown only when a suspended close is interrupted
by a signal.

As necessary for UDS, this change also introduces a closenb(2) system
call extension, allowing the caller to bypass blocking SO_LINGER close
behavior.  This extension allows UDS to avoid blocking on closing the
last reference to an in-flight file descriptor, in an atomic fashion.
The extension is currently part of libsys, but there is no reason why
userland would not be allowed to make this call, so it is deliberately
not protected from use by userland.

Change-Id: Iec77d6665232110346180017fc1300b1614910b7