⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unix to windows nt.txt

📁 本文是介绍如何从UNIX到NT程序的可移植技术,(国内是没有这方面的资料,所以是E文哦)
💻 TXT
📖 第 1 页 / 共 5 页
字号:
        care of exact case matching  on   exec*()  to  exit.  The process
        file  systems  that require it.   id  returned  by  the  getpid()
        One  of  the  most  troublesome   function will be the process id
        aspects of the WIN32 API is its   of the process that invoked the
        lack of  support  for  pathname   exec*()   function.   In  other
        case  distinction.   It  is not   cases,  it  will  be  the  same
        uncommon to  have  files  named   process  id  as the WIN32 uses.
        Makefile  and  makefile  in the   To prevent that process id from
        same directory in  UNIX.   UWIN   being  used  again  by WIN32, a
        handles   case  distinction  by   handle to the process  is  kept
        calling the WIN32  CreateFile()   by the grandparent process.
        function  both with and without
        the   FILE_FLAG_POSIX_SEMANTICS   Even  though   we   implemented
        function.    If   they  compare   fork()  and  the exec*() family
        equal, it executes the function   of functions, our  code  rarely
        internally, otherwise it spawns   uses    them.     Because   the
        a POSIX  subsystem  process  to   CreateProcess()        function
        carry out the task.               doesn't  have  an overlay flag,
                                          two  processes   need   to   be













        created  in  order  to  do both   6.5  Terminals
        fork()  and  exec*().    libast
        provides  a  spawn*() family of   The POSIX termios interface  is
        functions  that  combines   the   implemented   by  creating  two
        functionality of fork()/exec*()   threads;  one  for   processing
        on systems that don't have  the   keyboard  input events, and the
        spawn*() family.  All functions   other  for  processing   output
        in libast that create processes   events  and  escape  sequences.
        such  as  system()  and popen()   These threads are connected  to
        are   programmed   with    this   the   read   and   write   file
        interface.     On   most   UNIX   descriptors of the  process  by
        systems, the spawn*() family is   pipes.   The  same architecture
        written using fork() or vfork()   is  used   for   socket   based
        and  exec*().   We  implemented   terminals and serial I/O lines.
        spawn*()   in   our   posix.dll   Initially, these threads run in
        library to call CreateProcess()   the  process  that  created the
        directly.                         console   and   make   it   the
                                          controlling   terminal.   These
        6.4  Signals                      threads service  all  processes
                                          that   share   the  controlling
        Signals are handled  by  having   terminal.  New threads will  be
        each  process run a thread that   created  if  the  process  that
        waits on an event.  To  send  a   owns the threads terminates and
        signal  to  a  process, the bit   another  process is sharing the
        corresponding  to   the   given   console.   When  a  process  is
        signal  number  is  set  in the   created,   these   threads  are
        receiving   process's   process   suspended   and   the   console
        block,   and  then  its  signal   handles  are passed down to the
        thread  event  is   set.    The   child.  This enables  a  native
        signal thread then wakes up and   application  to  run  with  its
        looks  for  signals.    It   is   standard input  and  output  as
        important    for   the   signal   console    handles.    If   the
        handler to be executed  in  the   application  has  been   linked
        primary  thread of the process,   with  the posix.dll, then these
        since the handler may contain a   threads  are   resumed   before
        longjmp()  out  of  the handler   main()  is  called so that UNIX
        function.   Prior  to   calling   style terminal processing takes
        main(),  an exception filter is   place.  The result is that UNIX
        added  to  the  primary  thread   processes will echo  characters
        that  checks  for signals.  The   as  they  are typed and respond
        signal  thread  does  this   by   to special  keys  specified  by
        suspending  the  primary thread   stty,   whereas   native  WIN32
        raising an exception that  will   applications  will  only   echo
        active  the exception filter of   characters  when  they are read
        the primary  thread,  and  then   and will use Control-C  as  the
        resuming the primary thread.      interrupt character.

















        6.6  Ids_and_Permissions          permission bits.  With  the  NT
                                          file    system,    this   extra
        Permissions for files are  only   information has been stored  by
        available on Windows NT.  Calls   using   a   poorly   documented
        to  get  an   set   permissions   feature  called  multiple  data
        return  not  implemented errors   streams  that  allows a file to
        on  Windows  95.   Creating   a   have   multiple    individually
        Windows  NT  ACL  that  closely   named  parts.   A separate data
        corresponds to UNIX permissions   stream  is  created   to   hold
        isn't  very difficult.  The ACL   additional   information  about
        needs three  entries;  one  for   the file.  The SYSTEM attribute
        owner,  one  for group, and one   is put on any file or directory
        that represents the group  that   that  has  an  additional  data
        contains all users.  Windows NT   stream  so  that  they  can  be
        allows separate  permission  to   identified quickly with minimal
        delete a file and to change its   overhead     during    pathname
        security   attribute.     These   mapping.
        permissions  are  give  to  the
        owner  of  a  file.   The  UNIX   Using  multiple  data   streams
        umask()    command   sets   the   requires  the  NT  file system.
        default  ACL  so  that   native   On other  file  systems,  fifos
        applications  that  are  run by   and    symbolic    links    are
        UWIN  will  create  files  with   implemented  by   storing   the
        UNIX type permissions.            information in the file itself.
                                          The       setuid,        setgid
        Mapping of subject  identifiers   functionality  is not supported
        to  and from user and group ids   on these file systems.
        is    more    complex.     UWIN
        maintains  a  table  of subject   UWIN  treats  Windows  95   and
        identifier    prefixes,     and   Windows NT 4.0 short cuts as if
        constructs   the  user  id  and   they   were   symbolic   links.
        group id by  a  combination  of   However,  these  links  can  be
        the index in this table and the   created with any  of  the  UWIN
        last component of  the  subject   interfaces.   This  was done by
        identifier.    The   number  of   reverse engineering the  format
        subject   identifier   prefixes   of a short cut file and finding
        that    are    likely   to   be   where the pathname of the  file
        encountered on a given  machine   that it referred to was stored.
        is much smaller than the number
        of accounts so that this  table   Fifos are implemented by  using
        is easier to maintain.            WIN32  named  pipes.  A name is
                                          selected based on the  creation
        6.7  Special_files_and_Links      date  of  the  fifo file.  Only
                                          the first reader and the  first
        Special files such as fifos and   writer  on  the fifo create and
        symbolic  links  require stat()   connect to the named pipe.  All
        information that is not kept by   other  instances  duplicate the
        the  NT  or  FAT  file systems.   handle of either the reader  or
        Also, the file system does  not   the   writer.    This  way  all
        store  the  setuid  and  setgid   writers to a fifo use the  same













        handle   as  required  by  fifo   it  possible  to  use  the UNIX
        semantics.                        implementation of tcl  to  port
                                          tksh[17]    applications     to
        A POSIX  subsystem  command  is   Windows NT.
        also  invoked  to  create  hard
        links since there is  no  WIN32   6.9  Invocation
        API  function to do this.  Hard
        links fail for files in the FAT   When UWIN invokes a process, it
        file system.                      does   not   know  whether  the
                                          process is a UWIN process or  a
        6.8  Sockets                      native  process.   It  modifies
                                          the PATH variable  so  that  it
        Sockets are  implemented  as  a   uses   the   ;   separated  DOS
        layer  on  top  of WINSOCK, the   format.  It  also  passes  open
        Microsoft API for BSD  sockets.   files  in  the same manner that
        Most  functions  were  straight   the Microsoft C library does so
        forward  to   implement.    The   that programs that are compiled
        select()  function  proved more   with   this   library    should
        difficult    than    we     had   correctly  inherit  open  files
        anticipated    because   socket   from   UWIN   programs.     The
        handles could not be  used  for   initialization   function  also
        synchronization,   and  because   sees whether a  security  token
        the  Microsoft  select()   call   has  been placed in its address
        only    worked    with   socket   space by the UMS server, and if
        handles.      The     posix.dll   so, it impersonates this token.
        select()     function    allows
        different   types    of    file   The  POSIX   library   has   an
        descriptors to be waited for.     initialization   routine   that
                                          sets up  file  descriptors  and
        Our  first  implementation   of   assigns     the     controlling
        select()   created  a  separate   terminal starting the  terminal
        thread that used the  Microsoft   emulation  threads as required.
        select()  to  wait  for  socket   The  posix.lib   library   also
        handles, and created  an  event   supplies  a  WinMain() function
        for  the  main thread to add to   that is called when the program
        the list  of  handles  to  wait   begins.       This     function
        for.  Our second implementation   initializes the stdin,  stdout,
        used  a  library   routine   to   and  stderr  functions and then
        convert  input/output events on   calls  a   posix.dll   function
        sockets to windows messages and   passing  the address of another
        then  waited  for  both windows   posix.lib     function     that
        messages  and   handle   events   actually  invokes  main().  The
        simultaneously.    This  method   posix.dll function starts up up
        had the added  advantages  that   the  signal thread and sets the
        it  was  possible  to implement   exception  filter  for   signal
        SIGIO and that it was  easy  to   processing  as described above.
        add  a pseudo file device named   The reason for this  complexity
        /dev/windows that could be used   is  so  that UNIX programs will
        to listen for windows messages.   start    with    the    correct
        Adding this pseudo device  made   environment,    and   so   that













        argv[0] will have  UNIX  syntax   programs  work.   Our  compiler
        without the trailing .exe since   wrapper  can  be  invoked as cc
        many  programs   use   argv[0].   for ANSI-C compilation,  as  CC
        Much  of  the complexity occurs   for C++ compilation, and as pcc
        inside   the   posix.dll   part   to   build   POSIX    subsystem
        because  programs do no require   applications.
        recompilation when changes  are
        added there.                      Our  compiler  wrapper  follows
                                          the  normal  UNIX  defaults for
                                          suffixes rather than using  the
        7.  CURRENT_STATUS                Microsoft   conventions;   .o's
                                          rather than .obj's.   The  .exe
        At the time  of  this  writing,   suffix   is  not  required  for
        most interfaces required by the   Windows  NT  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -