NT POSIX subsystem

From DisNCord Community Wiki
Jump to navigation Jump to search

The NT POSIX subsystem, officially known as Microsoft POSIX subsystem, is a subsystem for Windows NT, shipped from Windows NT 3.1 to Windows 2000. It implements an early version of the POSIX standard called POSIX.1, codified as IEEE Std 1003.1-1988, ISO/IEC 9945-1:1990 and FIPS 151-2. This topic was explored in an NCommander stream, from which a video is in progress.

The standard includes process creation and control, signal handling, filesystem IO and the standard C library. The NT POSIX subsystem implements a bare minimum of what is needed for compliance. Windows NT 3.5, 3.51 and 4.0 are officially FIPS 151-2 compliant[1].

The NT POSIX subsystem was removed in Windows XP, being replaced with Windows Services for Unix, a product based on Interix, Unix compatibiliy software developed by Softway Systems and later bought by Microsoft. (However, if the subsystem files from Windows 2000 are copied to an 32-bit Windows XP or Server 2003 installation, the subsystem will start, though this hasn't been fully tested beyond loading pax.exe.)

NCommander's Investigations

NCommander's original investigations were done on Twitter, and are available as a PDF File:POSIX Subsystem Notes.pdf. These notes should be cleaned up and integrated here (along with photos as relevant).

Runtime

The core of the POSIX subsystem is PSXSS.EXE, a Win32 binary that is one of the default NT subsystems alongside CSRSS.EXE and OS2SS.EXE. This can be seen under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Session Manager\SubSystems. NT applications won't run without the subsystem proper running.

There are two more binaries that handle communication of POSIX applications with the OS. PSXDLL.DLL is an NT POSIX dynamic library that handles calling into the POSIX subsystem, similarly to what KERNEL32.DLL, USER32.DLL etc. do for the Win32 subsystem. Finally, there is POSIX.EXE, providing integration with the standard Windows UI, that is displaying an interactive console window. This is very similar to the role of OS2.EXE in the OS/2 subsystem.

Functionality

The full list of features can be found in the POSIX.1 standard. As of features unusual on Windows NT, the subsystem includes an implementation of fork, case-sensitive files and Unix permissions.

Development

Windows SDK includes libcpsx.lib, psxdll.lib and psxrtl.lib, libraries used for linking binaries using the POSIX subsystem, as well as an incomplete copy of header files (e.g. stdio.h is missing). The rest of the header files are shipped with Microsoft Visual C++[2].

Open Watcom and Microsoft Visual C++ both support building POSIX binaries. Microsoft also ships a buggy cc wrapper, allowing to call Visual C++ from a POSIX environment, however it was shown on the NCommander stream that its practical usability is very limited.

Applications

The Windows NT base installation includes pax.exe. This is an implementation of the official POSIX archive utility[3], able to handle both tar and cpio files. pax.exe is the sole POSIX application included with Windows.

Windows NT 4.0 Resource Kit ships with a few applications for the POSIX subsystem. These are cat, chmod, chown, cp, find, grep, ln, ls, mkdir, mv, rm, rmdir, sh, touch, vi, and wc.

The Windows NT SDK includes source code for most of those, plus source-only releases for a few other tools. Most notably, these include the aforementioned cc wrapper, as well as a port of BSD make.

References