Unit OS C: Interoperability Unit OS C: Interoperability
C.2. Programming
C.2. Programming
Copyright Notice Copyright Notice
© 2000-2005 David A. Solomon and Mark Russinovich
© 2000-2005 David A. Solomon and Mark Russinovich
These materials are part of the
These materials are part of the Windows Operating Windows Operating System Internals Curriculum Development Kit,
System Internals Curriculum Development Kit, developed by David A. Solomon and Mark E.
developed by David A. Solomon and Mark E.
Russinovich with Andreas Polze Russinovich with Andreas Polze
Microsoft has licensed these materials from David Microsoft has licensed these materials from David Solomon Expert Seminars, Inc. for distribution to Solomon Expert Seminars, Inc. for distribution to academic organizations solely for use in academic academic organizations solely for use in academic environments (and not for commercial use)
environments (and not for commercial use)
Roadmap for Section C.2 Roadmap for Section C.2
UNIX Environments on Windows UNIX Environments on Windows
Approaches to UNIX Programming on Windows Approaches to UNIX Programming on Windows Interix - the POSIX Subsystem for Windows
Interix - the POSIX Subsystem for Windows Common Desktop, Filesystem, IPC
Common Desktop, Filesystem, IPC
Interix in Action: /proc-fs, gcc, truss, ksh, csh Interix in Action: /proc-fs, gcc, truss, ksh, csh Integration scenarios: X11 on Windows
Integration scenarios: X11 on Windows Cygwin Compatibility Library and tools Cygwin Compatibility Library and tools UWIN from ATT Research
UWIN from ATT Research
UNIX Programming on Windows UNIX Programming on Windows
Interix - POSIX subsystem for Windows Interix - POSIX subsystem for Windows
Part of Services for UNIX 3.5 Part of Services for UNIX 3.5
Applicable to Windows NT/2000/XP/2003 Applicable to Windows NT/2000/XP/2003
Compatibility libraries for Windows-API:
Compatibility libraries for Windows-API:
Applicable to all Windows variants Applicable to all Windows variants
Visual Studio libraries for C/C++
Visual Studio libraries for C/C++
Cygwin library and runtime Cygwin library and runtime
UWIN library and runtime UWIN library and runtime
MKS toolkit (Mortice Kern Systems) MKS toolkit (Mortice Kern Systems)
Virtual Machine Environments Virtual Machine Environments
VMware (Intel only), VirtualPC (Intel + PowerPC) VMware (Intel only), VirtualPC (Intel + PowerPC)
The Interix Subsystem as part of The Interix Subsystem as part of
Windows Services for UNIX 3.5 Windows Services for UNIX 3.5
A full POSIX subsystem for Windows A full POSIX subsystem for Windows
Interix replaces the original POSIX subsystem on Windows Interix replaces the original POSIX subsystem on Windows NT, Windows 2000, Windows XP, and Windows Server 2003 NT, Windows 2000, Windows XP, and Windows Server 2003 Full network support
Full network support
Interoperability between POSIX and Windows subsystems Interoperability between POSIX and Windows subsystems (CreateProcess())
(CreateProcess())
Bundled with many essential UNIX tools (including X11R6 Bundled with many essential UNIX tools (including X11R6 clients)
clients)
From Windows Server 2003 R2 forward SFU does not apply From Windows Server 2003 R2 forward SFU does not apply and will be blocked from installing
and will be blocked from installing
Microsoft acquired Softway Systems, the makers of Microsoft acquired Softway Systems, the makers of
Interix on Sept. 17, 1999 Interix on Sept. 17, 1999
Interix Features Interix Features
KornShell, C Shell and Bourne Shell KornShell, C Shell and Bourne Shell
with full job control with full job control
Over 300 utilities, Over 300 utilities,
including scripting tools such as awk, sed, perl, Tcl/Tk including scripting tools such as awk, sed, perl, Tcl/Tk
Berkeley System Distribution (BSD) Berkeley System Distribution (BSD)
sockets mapped to Winsock sockets mapped to Winsock Memory-mapped files
Memory-mapped files
System V (SVID) interprocess communication (IPC):
System V (SVID) interprocess communication (IPC):
semaphores, message queues and shared memorysemaphores, message queues and shared memory
UNIX Look and Feel:
UNIX Look and Feel:
Pseudo-terminal support Pseudo-terminal support Color curses support Color curses support
Ability to execute Windows applications from Interix Ability to execute Windows applications from Interix Full tty semantics mapped to console windows
Full tty semantics mapped to console windows Pseudo-terminal support
Pseudo-terminal support
Interix Features (contd.) Interix Features (contd.)
Full integration with Windows security model, administration, file Full integration with Windows security model, administration, file systems, networking and printers
systems, networking and printers
Support for POSIX.1 (system services) and POSIX.2 Support for POSIX.1 (system services) and POSIX.2 (shell and utilities)
(shell and utilities)
X11R6 + X11R5 runtime, including X clients:
X11R6 + X11R5 runtime, including X clients:
xterm, twm, xrdb,
xterm, twm, xrdb, and xlsclients and xlsclients
Support for daemons (inetd) running as Windows services Support for daemons (inetd) running as Windows services telnetd
telnetd & rlogind & rlogind services (multiuser login support) services (multiuser login support) Berkeley r-utilities (servers and clients)
Berkeley r-utilities (servers and clients) cron, syslogd
cron, syslogd & other daemon/service support & other daemon/service support Internet clients:
Internet clients: ftp, telnet, ping, rshftp, telnet, ping, rsh
Interix Software Development Kit Interix Software Development Kit
Development tools, including Development tools, including
make, RCS, lex, yacc, cc, c89, nm, ar, strip make, RCS, lex, yacc, cc, c89, nm, ar, strip
ANSI C, POSIX.1 and POSIX.2 interfaces ANSI C, POSIX.1 and POSIX.2 interfaces
Color curses library Color curses library
BSD-style sockets library support BSD-style sockets library support
pthread implementation pthread implementation
X11R6 + X11R5 libraries and header files X11R6 + X11R5 libraries and header files gcc (GNU C) compiler (gcc 3.3)gcc (GNU C) compiler (gcc 3.3)
g++ (GNU C++) compilerg++ (GNU C++) compiler
g77g77 (GNU FORTRAN77) compiler (GNU FORTRAN77) compiler Support for Microsoft Visual C/C++
Support for Microsoft Visual C/C++
Interix - Interix -
The POSIX Subsystem for Windows The POSIX Subsystem for Windows
OS/2 Windows POSIX
Environment Subsystems
User
Application
Subsystem DLL
Windows User/GDI
Device Driver
Executive
Device Drivers Kernel
Hardware Abstraction Layer (HAL) User
Mode Kernel Mode
System
& Service Processes
Windows
Interix/Windows API Integration Interix/Windows API Integration
Windows Kernel
NTFS
CDFS FAT
Interix
Subsystem Windows
Subsystem
Common Common Desktop Desktop
Pipes, sockets Shared memory
Win32exec COM
Common File Systems
Interix App
Win App Interix
App
Win App
Common Desktop Common Desktop
Interix shell appears in a console window with Interix shell appears in a console window with
standard controls standard controls
Cut-and-paste support between Interix, Cut-and-paste support between Interix,
Windows, & X11 applications Windows, & X11 applications
Launch Interix applications from a desktop icon Launch Interix applications from a desktop icon
or menu or menu
Standard Windows tools apply Standard Windows tools apply
InstallShield, etc.
InstallShield, etc.
Common File System Common File System
Interix supports NTFS, FAT, CDFS.
Interix supports NTFS, FAT, CDFS.
NTFS provides case sensitive filenames, group NTFS provides case sensitive filenames, group ownership, file modes (ACLs) and hard links
ownership, file modes (ACLs) and hard links
Windows groups to UNIX uid/gid mapping Windows groups to UNIX uid/gid mapping
NTFS I/O operation audit features are available to ported NTFS I/O operation audit features are available to ported UNIX apps on Interix
UNIX apps on Interix
% id
uid=197611(andreas) gid=197121(None) groups=197121(None), 65792(+Everyone), 1976 14(Debugger Users), 131616(+Administrators), 131617(+Users), 66820(+INTERACTIVE) , 66827(+Authenticated Users), 4095(CurrentSession), 66048(+LOCAL)
%
% who am I
andreas ttyn01 Dec 5 20:51
Common Execution Environment Common Execution Environment
Interix applications can fork/exec Windows applications Interix applications can fork/exec Windows applications Can shell script Windows apps
Can shell script Windows apps
ksh and csh are supported ksh and csh are supported
Used in the product in lp and cc Used in the product in lp and cc
Interix implements UNIX directory hierarchy Interix implements UNIX directory hierarchy
/usr, /bin, /sbin, /etc, /dev … /usr, /bin, /sbin, /etc, /dev …
Mapping for drive letters: /dev/fs/C/…
Mapping for drive letters: /dev/fs/C/…
/proc file system - statistics about Windows + Interix apps /proc file system - statistics about Windows + Interix apps
Windows apps explicitly for the UNIX environment
Windows apps explicitly for the UNIX environment
/proc filesystem in action /proc filesystem in action
Demo: list active processes via ksh-script Demo: list active processes via ksh-script
/proc/$pid/cmdline contains 0-terminated list of arguments for /proc/$pid/cmdline contains 0-terminated list of arguments for
each process on the system each process on the system
$
$ for pid in `ls /proc`
> do
> echo "$pid\t\c"
> cat /proc/$pid/cmdline | \ tr "\000" "\n" | \ tail -n 1
> done
0 IdleProcess 0 IdleProcess
1168 C:\WINDOWS\system32\spoolsv.exe 1168 C:\WINDOWS\system32\spoolsv.exe 1264 C:\WINDOWS\VMADD\VMSRVC.EXE 1264 C:\WINDOWS\VMADD\VMSRVC.EXE 1276 C:\WINDOWS\system32\nfsclnt.exe 1276 C:\WINDOWS\system32\nfsclnt.exe
1336 "C:\Program Files\Common Files\Microsoft 1336 "C:\Program Files\Common Files\Microsoft Shared\VS7Debug\mdm.exe"
Shared\VS7Debug\mdm.exe"
1428 C:\SFU\common\rshsvc.exe 1428 C:\SFU\common\rshsvc.exe 1477 sh
1477 sh
1572 C:\WINDOWS\System32\VPCMap.exe 1572 C:\WINDOWS\System32\VPCMap.exe 1632 C:\WINDOWS\system32\PSXRUN.EXE 1632 C:\WINDOWS\system32\PSXRUN.EXE 164 C:\WINDOWS\System32\alg.exe
164 C:\WINDOWS\System32\alg.exe 1672 C:\WINDOWS\system32\psxss.exe 1672 C:\WINDOWS\system32\psxss.exe 1688 C:\SFU\Mapper\mapsvc.exe
1688 C:\SFU\Mapper\mapsvc.exe 1857 /usr/sbin/cron
1857 /usr/sbin/cron
2032 C:\WINDOWS\system32\wscntfy.exe 2032 C:\WINDOWS\system32\wscntfy.exe
2164 C:\WINDOWS\System32\svchost.exe -k HTTPFilter 2164 C:\WINDOWS\System32\svchost.exe -k HTTPFilter 2876 "C:\WINDOWS\system32\posix.exe" /u /c /bin/csh -l 2876 "C:\WINDOWS\system32\posix.exe" /u /c /bin/csh -l 321 /usr/sbin/init
321 /usr/sbin/init
The script’s output (shortened)
Interix with gcc and truss in action Interix with gcc and truss in action
%%
% cat > hello.c
% cat > hello.c
# include <stdio.h>
# include <stdio.h>
main () { main () {
printf("Hello Interix\n");printf("Hello Interix\n");
}}
^D%^D%
% gcc hello.c -o hello
% gcc hello.c -o hello
%%
%%
% file hello
% file hello
hello: Windows NT PE format (EXE), hello: Windows NT PE format (EXE),
dynamically linked executable not stripped In dynamically linked executable not stripped In tel Posix-CUI
tel Posix-CUI
%%
% pwd
% pwd
% truss ./hello
% truss ./hello tracing pid 3591 tracing pid 3591
getdata() getdata returned 0 getdata() getdata returned 0 getrlimit() getrlimit returned 0 getrlimit() getrlimit returned 0
pthread_inform_signals() pthread_inform_signals pthread_inform_signals() pthread_inform_signals returned 0
returned 0
unixpath2win() unixpath2win returned 0 unixpath2win() unixpath2win returned 0 getids() getids returned 0
getids() getids returned 0 getids() getids returned 0 getids() getids returned 0 getids() getids returned 0 getids() getids returned 0 getids() getids returned 0 getids() getids returned 0
open("/usr/lib/libc.so.3.5", 0x1) open returned 3 open("/usr/lib/libc.so.3.5", 0x1) open returned 3 read(3, 0x81EC18, 4096) read returned 4096 read(3, 0x81EC18, 4096) read returned 4096 0x1000
0x1000
close(3) close returned 0 close(3) close returned 0
unixpath2win() unixpath2win returned 0 unixpath2win() unixpath2win returned 0
fstat(1, 0xC60710, 0x0) fstat ret: 0 dev: 0x0 ino:
fstat(1, 0xC60710, 0x0) fstat ret: 0 dev: 0x0 ino:
0x00000000 0x00000000
isatty(1) isatty returned 0 isatty(1) isatty returned 0 isatty(1) isatty returned 0 isatty(1) isatty returned 0
write(1, 0x124418, 14) Hello Interix write(1, 0x124418, 14) Hello Interix
Interprocess Communication Interprocess Communication
Applications can share data between Applications can share data between
subsystems via subsystems via
Pipes Pipes
Sockets (Local and Remote) Sockets (Local and Remote)
Shared Memory (Windows mapped files to System Shared Memory (Windows mapped files to System
V shared memory)
V shared memory)
INTERIX Integration with COM INTERIX Integration with COM ( ( Example App) Example App)
tide
UNIX C Application
I NTERIX Subsystem Windows Subsystem xtide
UNIX X11 C Application
VBTIDE.EXE TIDE.XLS
Visual Basic GUI Or Excel Plug-in
TIDEWRAP.DLL
INTERIX COM DLL Module
Existing X11 Graphical Application
Existing UNIX Character-based
Application
New Windows Graphical Application
Virtual PC + Interix + X11
Virtual PC + Interix + X11
Local X server for SFU 3.5 Local X server for SFU 3.5
Starnet Communications offers Free X Server Download Starnet Communications offers Free X Server Download
X-Win32 LX complements SFU 3.5 by enabling the display of X-Win32 LX complements SFU 3.5 by enabling the display of
local X Windows applications local X Windows applications
UNIX Integration in Windows UNIX Integration in Windows
Server 2003 R2 Server 2003 R2
New Subsystem for UNIX Applications (SUA) New Subsystem for UNIX Applications (SUA)
An extensively upgraded subsystem derived from An extensively upgraded subsystem derived from
the Interix subsystem the Interix subsystem
Biggest change: SUA permits UNIX applications it Biggest change: SUA permits UNIX applications it
hosts to also make Win32 API calls hosts to also make Win32 API calls
OCI and ODBC connectivity OCI and ODBC connectivity
Visual Studio Debugger Extension Visual Studio Debugger Extension
64-bit Application Support 64-bit Application Support
This feature is supported and tested for accessing This feature is supported and tested for accessing
the Oracle oci.dll library and for accessing the the Oracle oci.dll library and for accessing the
Windows standard ODBC library
Windows standard ODBC library
SUA Architecture SUA Architecture
Full Subsystem, not an Emulator Full Subsystem, not an Emulator
Complete UNIX Complete UNIX
subsystem on subsystem on
the Windows the Windows
Kernel Kernel
Ability to Ability to
access Win32 access Win32
from SUA from SUA
applications applications
UNIX applications
Win32®
applications
UNIX Integration in Windows UNIX Integration in Windows
Server 2003 R2 (contd.) Server 2003 R2 (contd.)
Active Directory Services Active Directory Services
NIS schema and Kerberos authentication extensions NIS schema and Kerberos authentication extensions Identity Management for UNIX
Identity Management for UNIX
Administration Components Administration Components
Password Synchronization Password Synchronization
Server For NIS Server For NIS
Other Network File and Print Services Other Network File and Print Services
Microsoft Services for NFS Microsoft Services for NFS
Mapping Server Mapping Server
NFS AdminUI + NFS client + NFS server NFS AdminUI + NFS client + NFS server
Portmap + RpcXdr Portmap + RpcXdr
Server for NFS Authentication Server for NFS Authentication
Windows Server 2003 R2 UNIX Windows Server 2003 R2 UNIX
SDKs and Tools SDKs and Tools
The following are available for download:
The following are available for download:
Utilities and SDK for UNIX-based Applications Utilities and SDK for UNIX-based Applications
Base Utilities Base Utilities
SVR-5 Utilities SVR-5 Utilities
Base SDK Base SDK GNU SDK GNU SDK
GNU Utilities GNU Utilities
UNIX Perl UNIX Perl
Visual Studio Debugger Add-in
Visual Studio Debugger Add-in
Cygwin compatibility library – Cygwin compatibility library –
principles and problems principles and problems
Cygwin DLL is loaded into an application's text segment Cygwin DLL is loaded into an application's text segment
UNIX kernel emulation UNIX kernel emulation
Needs access to all processes running under it Needs access to all processes running under it
First Cygwin DLL to run creates shared memory areas that other First Cygwin DLL to run creates shared memory areas that other processes using separate instances of the DLL can access
processes using separate instances of the DLL can access Keeping track of open file descriptors and assisting fork/exec Keeping track of open file descriptors and assisting fork/exec Per-process structures for process id, user id, signal masks, etc.
Per-process structures for process id, user id, signal masks, etc.
Potential security hole - shared memory region writable to Potential security hole - shared memory region writable to
all processes
all processes
Highlights of Cygwin Functionality Highlights of Cygwin Functionality
Supporting both Windows NT/2000/XP and 9x Supporting both Windows NT/2000/XP and 9x
Cygwin runs as Windows app; not a subsystem Cygwin runs as Windows app; not a subsystem
Permissions and Security Permissions and Security
maps Windows file ownership and permissions to the more standard, maps Windows file ownership and permissions to the more standard,
older UNIX model older UNIX model
File Access File Access
Windows- and POSIX-style paths Windows- and POSIX-style paths
Using either forward or back slashes as the directory delimiter Using either forward or back slashes as the directory delimiter
Symbolic links are emulated by files containing a magic cookie followed Symbolic links are emulated by files containing a magic cookie followed
by the path to which the link points by the path to which the link points
Text Mode vs. Binary Mode Text Mode vs. Binary Mode
compatibility at the expense of violating the POSIX standard that states compatibility at the expense of violating the POSIX standard that states
Cygwin features (contd.) Cygwin features (contd.)
Process Creation Process Creation
The fork call in Cygwin is particularly interesting because it does not The fork call in Cygwin is particularly interesting because it does not map well on top of the Windows API
map well on top of the Windows API
Cygwin fork is a non-copy-on-write implementation similar to what Cygwin fork is a non-copy-on-write implementation similar to what was present in early flavors of UNIX
was present in early flavors of UNIX
Signals Signals
When a Cygwin process starts, the library starts a secondary thread When a Cygwin process starts, the library starts a secondary thread for use in signal handling
for use in signal handling
This thread waits for Windows events used to pass signals This thread waits for Windows events used to pass signals
When a process notices it has a signal, it scans its signal bitmask When a process notices it has a signal, it scans its signal bitmask and handles the signal in the appropriate fashion
and handles the signal in the appropriate fashion Most standard UNIX signals are provided
Most standard UNIX signals are provided Job control works as expected
Job control works as expected
Cygwin features (contd.) Cygwin features (contd.)
Sockets Sockets
Socket-related calls in Cygwin are mapped onto Winsock Socket-related calls in Cygwin are mapped onto Winsock
Cygwin has to perform winsock initialization when appropriate Cygwin has to perform winsock initialization when appropriate Child proc. initialize winsock if any inherited file descriptor is a Child proc. initialize winsock if any inherited file descriptor is a
socket socket
Select Select
The UNIX select function is another call that does not map The UNIX select function is another call that does not map
cleanly on top of the Windows-API cleanly on top of the Windows-API
Windows select in Winsock only works on socket handles Windows select in Winsock only works on socket handles
Cygwin select works for different types of file descriptors Cygwin select works for different types of file descriptors
(sockets, pipes, handles, and a custom /dev/windows (sockets, pipes, handles, and a custom /dev/windows
Software, Software,
that has been ported to Cygwin that has been ported to Cygwin
Apache 1.3.9 and php-4.0b2, Apache 1.3.9 and php-4.0b2, CD Recording Software
CD Recording Software
Data Plotting Library DISLIN 7.3 Data Plotting Library DISLIN 7.3
Differential X Protocol Compressor 3.8.0 Differential X Protocol Compressor 3.8.0 DirectX
DirectX
FreeCIV 1.8.0 FreeCIV 1.8.0 gcc 2.95.2 gcc 2.95.2
Gimp for Win32 Gimp for Win32 groff 1.16.1 groff 1.16.1 IBM's OpenDX IBM's OpenDX Icarus Verilog Icarus Verilog
Insight debugger, pine, wget, info, other ports Insight debugger, pine, wget, info, other ports Kerberos V4 eBones Distribution v1.0.3 Kerberos V4 eBones Distribution v1.0.3 LAPACK Libraries
LAPACK Libraries LessTif 0.89.9 LessTif 0.89.9
• libstdc++-v3 2.90.7
• lynx-2.8.2r1
• mc-4.1.36, tcltk-8.3.1
• Open PTC for Windows
• perl-5.6.0
• Perl, gdbm, cvs, and cygipc
• PGPlot 5.2
• Python headers for mingw
• RPM 3.04, Lynx 2.8.3
• RXVT
• screen-3.9.8, xchat-1.6.0
• Screen Saver Library
• TCL/Tk 8.1
• UCD SNMP
• X11R6.4 Archive and Zyacc
• XChat-text 1.5.7 Install
Cygwin now
UWIN UWIN
The UWIN package contains the following three elements:
The UWIN package contains the following three elements:
Libraries that provide the UNIX Application Programming Interface Libraries that provide the UNIX Application Programming Interface
(API) (API)
Include files and development tools such as cc, yacc, lex, and make.
Include files and development tools such as cc, yacc, lex, and make.
Korn Shell and over 200 utilities such as ls, sed, cp, stty etc.
Korn Shell and over 200 utilities such as ls, sed, cp, stty etc.
www.research.
www.research.attatt.com/.com/swsw/tools//tools/uwinuwin// (free non-commercial license) (free non-commercial license)
The library functions are implemented in a DLL (POSIX.DLL) The library functions are implemented in a DLL (POSIX.DLL) Programs linked with POSIX.DLL run under the Windows Programs linked with POSIX.DLL run under the Windows subsystem instead of the POSIX subsystem
subsystem instead of the POSIX subsystem
A cc command is provided to compile and link programs for UWIN A cc command is provided to compile and link programs for UWIN on Windows
on Windows
Process control and management:
Process control and management:
UWIN includes a spawn() family of functions that combines the UWIN includes a spawn() family of functions that combines the functionality of fork/exec for efficiency; vfork() support
functionality of fork/exec for efficiency; vfork() support
With exec(), an existing process can be overlaid with another process With exec(), an existing process can be overlaid with another process Each process has a unique process id and belongs to a process group Each process has a unique process id and belongs to a process group
File descriptor semantics:
File descriptor semantics:
Open files, pipes, sockets, fifos, and character and block special devices Open files, pipes, sockets, fifos, and character and block special devices files have file descriptors associated with them
files have file descriptors associated with them
They can be duped and inherited with UNIX semantics They can be duped and inherited with UNIX semantics
UNIX signal semantics:
UNIX signal semantics:
Nearly all of the UNIX signals are provided including job control signals so Nearly all of the UNIX signals are provided including job control signals so that ksh can stop and restart jobs
that ksh can stop and restart jobs
A process can catch, block or ignore signals A process can catch, block or ignore signals
Signals can be sent to processes or to process group Signals can be sent to processes or to process group
-D_BSDCOMPAT compiler flag for UCB UNIX signal semantics -D_BSDCOMPAT compiler flag for UCB UNIX signal semantics
UWIN features
UWIN features
UWIN features (contd.) UWIN features (contd.)
Support for devices Support for devices
Character and block devices with major and minor numbers Character and block devices with major and minor numbers
Support for direct access to floppy drives (/dev/fd0), and SCSI tape Support for direct access to floppy drives (/dev/fd0), and SCSI tape drives (/dev/mt0), as well as ptys and ttys
drives (/dev/mt0), as well as ptys and ttys
Terminal interface for consoles, sockets, and serial lines:
Terminal interface for consoles, sockets, and serial lines:
The POSIX termios interface is supported for consoles with vt100 The POSIX termios interface is supported for consoles with vt100 emulation
emulation
UWIN supports pseudo-ttys UWIN supports pseudo-ttys
Desktop integration for console windows:
Desktop integration for console windows:
Select text, copy/paste to the clipboard Select text, copy/paste to the clipboard
The /dev/clipboard pseudo-device can be used to redirect command The /dev/clipboard pseudo-device can be used to redirect command input and output to the clipboard
input and output to the clipboard
The /dev/windows pseudo-device can be used within select() to block The /dev/windows pseudo-device can be used within select() to block
UWIN features (contd.) UWIN features (contd.)
UCB sockets based on WINSOCK:
UCB sockets based on WINSOCK:
Sockets are file descriptors and obey file descriptor semantics Sockets are file descriptors and obey file descriptor semantics
Internet domain protocol (AF_INET) and UNIX domain sockets are Internet domain protocol (AF_INET) and UNIX domain sockets are provided
provided
The multicast socket protocol is supported The multicast socket protocol is supported
Pathname mapping from UNIX to Windows:
Pathname mapping from UNIX to Windows:
UNIX style naming for all files with / as the delimiter by creating mounts.
UNIX style naming for all files with / as the delimiter by creating mounts.
Each drive letter in Windows is mounted in a single letter directory Each drive letter in Windows is mounted in a single letter directory name under / so that /a/file is the UWIN name for a:\file.
name under / so that /a/file is the UWIN name for a:\file.
Implicitly mounted directories:
Implicitly mounted directories:
/sys on the system directory, /sys on the system directory,
/win on the windows directory, and /win on the windows directory, and
/msdev on the directory containing the Microsoft tools /msdev on the directory containing the Microsoft tools
Character and block special devices are in /dev Character and block special devices are in /dev
UWIN also supports UNC names for files that begin with //
UWIN also supports UNC names for files that begin with //
UWIN features (contd.) UWIN features (contd.)
UNIX naming conventions:
UNIX naming conventions:
The PATH variable is a : separated list rather than a ; separated list The PATH variable is a : separated list rather than a ; separated list The cc command generates files with a .o suffix by default, etc
The cc command generates files with a .o suffix by default, etc
Mapping UNIX ids/permissions to Windows permissions:
Mapping UNIX ids/permissions to Windows permissions:
Windows subject identifiers are mapped to UNIX user ids and group ids.
Windows subject identifiers are mapped to UNIX user ids and group ids.
UNIX permissions are mapped onto Windows Windows file ACLs.
UNIX permissions are mapped onto Windows Windows file ACLs.
chown() to change the owner and or group of a file.
chown() to change the owner and or group of a file.
File control locking:
File control locking:
UNIX file control advisory locking is supported with deadlock detection.
UNIX file control advisory locking is supported with deadlock detection.
Memory mapping and shared memory and System V IPC:
Memory mapping and shared memory and System V IPC:
mmap(), System V shared memory, semaphores, message passing API mmap(), System V shared memory, semaphores, message passing API
Runtime linking of dynamically linked libraries:
Runtime linking of dynamically linked libraries:
UWIN features (contd.) UWIN features (contd.)
ii-node numbers: -node numbers:
An iAn i-node number is returned when reading a file and when stating a file -node number is returned when reading a file and when stating a file
Hard links Hard links
Hard links are supported on both NTFS and FAT file systems Hard links are supported on both NTFS and FAT file systems
Symbolic links Symbolic links
Symbolic links to files and directories can be created in UWIN and are Symbolic links to files and directories can be created in UWIN and are implemented as Windows shortcuts
implemented as Windows shortcuts
A .lnk suffix will be appended to these file names but will not appear when A .lnk suffix will be appended to these file names but will not appear when reading directories with UWIN
reading directories with UWIN
Shortcuts created by Windows 9x and Windows NT/2k/XP appear as Shortcuts created by Windows 9x and Windows NT/2k/XP appear as symbolic links in UWIN but do not have the .lnk suffix removed.
symbolic links in UWIN but do not have the .lnk suffix removed.
Fifo's Fifo's
Fifo's (UNIX named pipes) can be created with mkfifo() and opened as an Fifo's (UNIX named pipes) can be created with mkfifo() and opened as an ordinary file
ordinary file
UWIN features (contd.) UWIN features (contd.)
Setuid and setgid programs Setuid and setgid programs
Use chmod() to turn on setuid permission for a program.
Use chmod() to turn on setuid permission for a program.
The program must be on an NTFS file system.
The program must be on an NTFS file system.
inet Daemons and commands inet Daemons and commands
UWIN 4.0 comes with the UCB inetd daemon, the telnet daemon, the rlogin UWIN 4.0 comes with the UCB inetd daemon, the telnet daemon, the rlogin daemon, and the rsh daemon.
daemon, and the rsh daemon.
It also includes the telnet, ftp, rsh, and rlogin programs.
It also includes the telnet, ftp, rsh, and rlogin programs.
The ssh daemon and program can be built from the source The ssh daemon and program can be built from the source
Access of Registry through the File System Access of Registry through the File System
UWIN treats the Windows registry as a file system with registry keys treated as UWIN treats the Windows registry as a file system with registry keys treated as files, and keys that have sub-keys treated as directories.
files, and keys that have sub-keys treated as directories.
You can use UWIN tools directly on registry keys. The registry is automatically You can use UWIN tools directly on registry keys. The registry is automatically mounted under /reg during startup.
mounted under /reg during startup.
Cron daemon Cron daemon
MKS Interoperability Products MKS Interoperability Products
Mortice Kern Systems -
Mortice Kern Systems - http://www.datafocus.com/ http://www.datafocus.com/
MKS Toolkit for Developers Features MKS Toolkit for Developers Features
Over 300 UNIX and Windows command-line utilities Over 300 UNIX and Windows command-line utilities
(full POSIX.2 specification).
(full POSIX.2 specification).
MKS Korn shell (ksh) and MKS C shell (csh) MKS Korn shell (ksh) and MKS C shell (csh) Command-line build utilities including
Command-line build utilities including
ar, cc, make, grep, vi.
ar, cc, make, grep, vi.
Tools and utilities for manipulating HTML content (htdiff, htsplit, url, mkurl).
Tools and utilities for manipulating HTML content (htdiff, htsplit, url, mkurl).
Web CGI scripting, and active Perl scripting (web, mkscgi, PScript™) Web CGI scripting, and active Perl scripting (web, mkscgi, PScript™)
File system commands (mount, umount) and symbolic link support.
File system commands (mount, umount) and symbolic link support.
smtpmail and mapimail.
smtpmail and mapimail.
Win32 file and user security utilities (chacl, lsacl, su).
Win32 file and user security utilities (chacl, lsacl, su).
Utilities for setting up users, groups, and permissions on Windows Utilities for setting up users, groups, and permissions on Windows
userinfo, groupinfo, member userinfo, groupinfo, member
Tape and archive commands Tape and archive commands
tar, pax, cpio, mt tar, pax, cpio, mt
NuTCracker Packaging NuTCracker Packaging
MKS Toolkit features (contd.):
MKS Toolkit features (contd.):
Commands to manipulate Commands to manipulate
device drivers, device drivers,
Windows domains, and Windows domains, and
file associations (dev, domain, ftype).
file associations (dev, domain, ftype).
Remote utilities:
Remote utilities:
rsh, rexec, rcp, rlogin rsh, rexec, rcp, rlogin
Packaging:
Packaging:
NuNuTCRACKER Workstation, NTCRACKER Workstation, NuTCRACKER Server, Power User Utilities uTCRACKER Server, Power User Utilities MKS Toolkit contains the SCO XVision Eclipse X Server.
MKS Toolkit contains the SCO XVision Eclipse X Server.
Hummingbird 3D OpenGL X Server Hummingbird 3D OpenGL X Server
an add-on to MKS Toolkit for Enterprise Developers an add-on to MKS Toolkit for Enterprise Developers
Further Reading Further Reading
Windows Services for UNIX 3.5 Windows Services for UNIX 3.5
http://www.microsoft.com/windowsserversystem/sfu/
http://www.microsoft.com/windowsserversystem/sfu/
http://www.starnet.com/xwin32LX/get_xwin32LX.htm http://www.starnet.com/xwin32LX/get_xwin32LX.htm
UNIX Integration in Windows Server 2003 R2 UNIX Integration in Windows Server 2003 R2
http://www.microsoft.com/technet/community/events/windows2 http://www.microsoft.com/technet/community/events/windows2
003srvR2/add-52.mspx 003srvR2/add-52.mspx..
Cygwin - Cygnus Solutions Cygwin - Cygnus Solutions
http://www.cygwin.com/
http://www.cygwin.com/
UWIN - ATT Research UWIN - ATT Research
http://www.research.att.com/sw/tools/uwin/
http://www.research.att.com/sw/tools/uwin/