📄 unix to windows nt.txt
字号:
library for porting X11 based as possible. The library
applications including a needed to handle console and
version that offers a Windows serial line support, sockets,
look and feel. UNIX permissions, and other
commonly used mechanisms such
as memory mapping, IPC, and
dynamic linking. In addition, shared by all the currently
to be useful, the libraries had active UNIX processes in a
to be documented and supported. memory mapped region. This
This put the scope of the region is writable by all
project outside of the reach of processes so that an ill-
a small research department behaved process could affect
such as ours. another process. Even though
all processes have read and
We subcontracted some of the write access to the shared
development to AT&T GIS in segment, secure access to
India to help complete this kernel objects in Windows NT is
project. We jointly designed not compromised by this model
the terminal interface and the because a process must have
group in India implemented it. access rights to an object to
They also worked on completing use it; knowing its address or
the sockets library. They value doesn't give additional
packaged the software for access rights. Some initial
installation and are providing measurements indicated that the
documentation. This section alternative of having a server
describes the UWIN process update the shared
implementation and how we memory region, would have had a
solved many of the problems performance penalty that we did
described in Section 4. not believe was worth the cost.
However, this is an area for
6.1 UWIN_Architecture future investigation.
The current implementation of The open file table is an array
UWIN consists of two of structures of type Pfd_t as
dynamically linked libraries illustrated in Table 1.
named posix.dll and ast.dll
that more or less implement the ______________________
functions documented |_____________________|
respectively in section 2 and |long refcount |
section 3 of UNIX manuals. In |_____________________|
addition, a server process |_____________________|
named UMS runs as Administrator |char type |
(the closest thing to root). |_____________________|
UMS generates security tokens |_____________________|
for setuid/setgid programs as
needed. It also is responsible TABLE 1. File Table Structure
for keeping the /etc/passwd and
/etc/group files consistent The refcount field is used to
with the registry database. keep track of free entries in
The Architecture for UWIN is this table. The Win32
illustrated in Figure 1. The InterlockedIncremenet() and
UMS server does not exist for InterlockedDecremenet()
Windows 95. functions are used to maintain
this count so that concurrent
The posix.dll library maintains access by different processes
an open file table that is will work correctly. The oflag
field stores the open flags for __________________________________________
the file. The type field |_________________________________________|
indicates what type of file, |long refcount |
regular, pipe, socket, or |_________________________________________|
special file. The function |_________________________________________|
that is used read from or to |HANDLE sigevent |
write to the file depend on the |_________________________________________|
value of type. For certain |_________________________________________|
types, the extra field stores |HANDLE etok,rtok |
an index into a type-specific |_________________________________________|
table that stores additional |_________________________________________|
information about this file. |pid_t pid,ppid,pgrp,sid |
|_________________________________________|
The posix.dll library also |_________________________________________|
maintains a per process |Psig_t siginfo |
structure, Pproc_t. The per |_________________________________________|
process structure contains |_________________________________________|
information required by UNIX |ulong alarmremain |
processes that is not required |_________________________________________|
by Win32 processes such as |_________________________________________|
parent process id, process |time_t cutime,cstime |
group id, signal masks, and |_________________________________________|
process state as illustrated in |_________________________________________|
Table 2.
TABLE 2. Process Table
Like the open file table, the Structure
process table maintains a
reference count so that process The process structure contains
slots can be allocated without an array of up to OPEN_MAX
creating a critical region. structures of type Pprocfd_t
The meaning of most of the that is indexed by file
fields in the process structure descriptor. The Pprocfd_t
can be deduced by its name. structure contains the close-
The Psig_t structure contains on-exec bit, the index of the
the bit mask for ignored, file in the open file table,
blocked and pending signals. and the corresponding handle or
When the first child process is handles as illustrated in Table
invoked by a process, a thread 3.
is created that waits for this
and subsequent processes to The posix.dll library
complete. The waitevent field implements the malloc(),
contains an event this thread realloc(), and free() interface
also waits on so that using the Vmalloc library
additional children can be written by Kiem-Phong Vo[14].
added to the list of children The Vmalloc library provides an
to wait for. interface to walk over all
memory segments that are
allocated which is needed for
the fork() implementation
described later.
__________________________ explicitly opened for reading
|_________________________| as a text file, an Sfio
|short index | discipline for read() and
|_________________________| lseek() can be inserted on the
|_________________________| stream to change all <cr><nl>
|HANDLE primary | sequences are to <nl>. The
|_________________________| lseek() discipline uses logical
|_________________________| offsets so that the removal of
<cr> characters is transparent.
TABLE 3. Process file We did not provide a discipline
structure to change <nl> to <cr><nl>
since we discovered that most
The ast.dll library provides a Windows 95 and Windows NT
portable application utilities worked without the
programming interface that is <cr>s. The <cr>s could be
used by all of our utilities. inserted by a filter such as
The interface to this library sed if required.
is named libast.a, for
compatibility with its name on 6.2 Files
UNIX systems. libast.a
provides C library functions The posix.dll library performs
that are not present on all the mapping between handles and
systems so that application file descriptors. Usually,
code doesn't require #ifdefs to each file descriptor has one
handle system dependencies. handle associated with it. In
libast.a is built using the some cases, two handles may be
iffe command [15] to feature associated with a file
test the host system and descriptor. An example of this
determine what interfaces do is a console that is open for
not exist in the native system. reading and writing which uses
separate handles for reading
libast.a relies on the and writing.
Microsoft C library for most of
the ANSI-C functionality. The The posix.dll library handles
most significant exception to the mapping between UNIX
this, other than malloc() which pathnames and WIN32 pathnames.
is provided by posix.dll, is Many UNIX programs assume that
the stdio library. libast.a pathnames that do not begin
provides its own version of the with a / are relative
stdio library based on calls to pathnames. In addition, only /
Sfio[16]. The Sfio library is recognized as a delimiter.
makes calls to posix.dll rather There is only a single root
than making direct calls to the directory; the operation of
WIN32 API as the Microsoft C changing to another drive does
library does so that pathnames not change the root directory.
are correctly mapped. The posix.dll library maps all
file names it encounters. If
The use of Sfio also provides a the file name begins with a /
simple solution to the <cr><nl> and the first component is a
problem. When a file is single letter, then this letter
is taken as the drive letter. 6.3 fork/exec
Thus, the UNIX filename
/d/bin/date gets translated to The fork() system call was
d:\bin\date. The file name implemented by creating a new
mapping routine also recognizes process with the same startup
special file names such as information as the current
/dev/tty and /dev/null. A / process. Before executing
not followed by a drive letter main(), it copies the data and
is mapped to the drive that stack of the parent process
UWIN has been installed on so into itself. Handles that were
that programs that embed closed when the new process was
absolute pathnames for files in created are duplicated into the
/bin, /tmp, /dev, and /etc work new process. The exec*()
without modification. family of functions was much
harder to implement. The
Finally, the path search problem is that there is no way
algorithm was modified to look to overlay the calling process.
for .exe and .bat suffices. Portage and NuTCracker have the
current process wait for the
One problem introduced by the child process to complete and
pathname mapping is that then exit. There are two
passing file name arguments to problems with this approach.
native NT utilities is more First, a process that execs
difficult since it understands repeatedly will fill up the
DOS style names, not UNIX process table. More
names. A library routine was importantly, resources from the
added to return a DOS name parent process are not
given a UNIX name. released. Our method causes
the child process to be
The posix.dll library pathname reparented to the grandparent
mapping function also takes and the process that calls
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -