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

📄 unix to windows nt.txt

📁 本文是介绍如何从UNIX到NT程序的可移植技术,(国内是没有这方面的资料,所以是E文哦)
💻 TXT
📖 第 1 页 / 共 5 页
字号:
        subsystem.  However, since  you   best  strategy for us, since we
        can  invoke POSIX commands from   believe that it resulted  in  a
        the  WIN32  subsystem,  it   is   better  implementation than the
        possible  to  port  some  stand   two     commercial     products
        alone  programs  to  the  POSIX   described later, and because it
        subsystem.    For  example,  we   eliminates  the  need  to   pay
        ported  the  pax  utility,  the   licensing fees for each copy of
        POSIX 1003.2[9] replacement for   each  product  that  uses   the
        cpio  and  tar,  to Windows NT,   library.   The  availability of
        and it can be invoked from  any   source code makes  it  possible
        WIN32 program.  Softway System,   to provide adequate support.
        Inc.,                       URL
        http://www.softway.com,  has an
        agreement  with  Microsoft   to   3.  GOALS
        enhance  the POSIX subsystem so
        that  they  can  achieve  POSIX   We wanted our software to  work
        1003.2   conformance.   Softway   with  Windows  3.1, Windows 95,
        claims that they will  open  up   and  Windows  NT.    A   summer
        the  POSIX subsystem so that it   student  wrote  a POSIX library
        can access WIN32  applications.   for Windows  3.1  and  we  were
        Even  if the POSIX subsystem on   able  to  port  a number of our
        Windows NT is  opened  up,  the   tools.   However,  the  limited
        POSIX    subsystem    is    not   capabilities   of  Windows  3.1
        available for Windows 95.         made it a less  than  desirable
                                          platform.   We  instead focused
        The fifth strategy is to use an   our goals  on  Windows  NT  and
        existing    POSIX   or   X/Open   Windows  95.  We decided to use
        library that runs in the  WIN32   only  the  WIN32  API  for  our
        subsystem.  At the time that we   library  so  that  the  library
        began  this  effort,  we   were   would work on Windows 95 and so
        aware  of two vendors that sell   that all WIN32 interfaces would
        such libraries but as discussed   be available to applications.
        later, these products were less
        than     satisfactory.       In   Initially,  our  goal  was   to
        addition,  Steve Chamberlain at   provide    the   IEEE   POSIX.1
        Cygnus has  started  writing  a   interface with a library.  This
        POSIX  interface for Windows NT   would  be sufficient to run ksh
        and Windows 95, but it  appears   and about eighty utilities that
        as   if   his  goals  are  less   we had written.  It soon became
        ambitious   than   ours,    URL   obvious that this wasn't enough
        http://www.cygnus.com/misc/gnu-   for  many  applications.   Most
        win32/.                           real  programs  use  facilities
                                          that   are  not  part  of  this













        standard  such  as  sockets  or   wanted to be  able  to  compile
        IPC.                              and   execute   UNIX   programs
                                          without  having  to  understand
        We   needed   to   provide    a   their  semantics.   In addition
        character     based    terminal   we wanted to limit  the  number
        interface so that curses  based   of new interfaces functions and
        applications  such  as vi could   environments variables that  we
        run.  After the initial set  of   had  to add to use our library.
        utilities   was   running,   we   It is difficult to manage  more
        wanted to  get  several  socket   than  one  or  two  environment
        based  tools  working.  Several   variables when installing a new
        projects at  AT&T  that  became   package.
        interested    in    using   our
        libraries, required the  System   Another goal that we had was to
        V   IPC   facilities.   The   S   provide   a   robust   set   of
        graphics  system[10]  and  ksh-   utilities     with      minimal
        93[11] required runtime dynamic   overhead.  If utilities written
        linking.     As   the   project   to   the   X/Open   API    were
        progressed,   the   need    for   noticeably slower than the same
        privileged  users, such as root   utilities written to the native
        on UNIX systems, surfaced.   We   WIN32   API,   then  they  were
        decided  that  it was important   likely to be  rewritten  making
        to  have  setuid   and   setgid   our  library unnecessary in the
        capabilities.  It  soon  became   long run.
        clear that we needed full  UNIX
        functionality  and  we  set our   A final and important goal  was
        goal  on   X/Open   Release   4   interoperatability   with   the
        conformance.                      native   Windows   NT   system.
                                          Integration   with  the  native
        We needed to  have  a  complete   system not only meant  that  we
        set  of  UNIX development tools   could use headers and libraries
        since we  didn't  want  to  get   from  the  native  system,  but
        into  the business of rewriting   that  we could pass environment
        makefiles  or  changing   build   variables   and    open    file
        scripts.   Most code written at   descriptors to commands written
        AT&T, including our  own,  uses   with the native system.   There
        nmake[12], (no relation to  the   couldn't  be two unrelated sets
        Microsoft  nmake),  but we also   of  user   ids   and   separate
        wanted to be  able  to  support   passwords.  If write permission
        other make variants.  We didn't   were  disabled  from  the  UNIX
        want to do manual configuration   system, then there should be no
        on  tools  that  have automatic   way to  write  the  file  using
        configuration scripts.            facilities in the native system
                                          and vice versa.
        One important goal that we  had
        from  the  beginning was to not   We have not as yet achieved all
        require WIN32 specific  changes   of our goals, but we think that
        to  the  source  to  get  it to   we are close.  We  are  in  the
        compile   and   execute.    The   process  of  running the X/Open
        reason  for  this  is  that  we   conformance  tests  to   verify













        compliance   with   the  X/Open   the  path  name,  so  that  the
        API's.  The rest of  the  paper   pathname c:\home\dgk names  the
        will discuss some of the issues   file  in directory \home\dgk on
        we needed to deal with and  our   drive c:.  Many UNIX  utilities
        solutions.                        expect  only / separated names,
                                          and  expect  a  leading  /  for
                                          absolute  pathnames.  They also
        4.  PROBLEMS_TO_SOLVE             expect  multiple  /'s   to   be
                                          treated as a single separator.
        The following problems need  to
        be understood and dealt with in   Even though NTFS supports  case
        porting applications to Windows   sensitivity for file names, the
        NT.   These  are  some  of  the   WIN32 API has  no  support  for
        issues   that   need   to    be   case       sensitivity      for
        addressed   by   POSIX  library   directories and minimal support
        implementations.    Section   6   for case sensitivity for files,
        describes  how UWIN solved most   limited          to           a
        of these problems.                FILE_FLAG_POSIX_SEMANTICS
                                          creation    flag    for     the
        4.1  Windows_NT_File_Systems      CreateFile() function.  Certain
                                          characters such as *, ?, >,  |,
        Windows   NT   supports   three   :,  ", and \, cannot be used in
        different  file systems, called   filenames created  or  accessed
        FAT,  HPFS,  and  NTFS.    FAT,   with the WIN32 API.  The names,
        which  stands  for  File Access   aux,  com1,  com2,   nul,   and
        Table, is the Windows  95  file   filenames  consisting  of these
        system.   It  is similar to the   names followed by  any  suffix,
        DOS file system except that  it   cannot  be  created or accessed
        allows  long file names.  There   in any  directory  through  the
        is no distinction between upper   WIN32 API.
        and  lower  case  although  the
        case is preserved.  HPFS, which   Because  Windows   95   doesn't
        stands   for  High  Performance   support  execute  permission on
        File System, was  designed  for   files, it uses the .exe  suffix
        OS/2.  NTFS, the native NT File   to  decide whether a file is an
        System,  is  similar   to   the   executable.  Windows NT doesn't
        Berkeley  file  system.[13]  It   require  this  suffix, but some
        allows  long  file names (up to   NT utilities, such as  the  DOS
        255  characters)  and  supports   command   interpreter,  require
        both   upper   and  lower  case   the .exe suffix.
        characters.   It  stores   file
        names as 16 bit Unicode names.    4.2  Line_Delimiters

        The file  system  namespace  in   Windows   NT   uses   the   DOS
        Win32  is hierarchical as it is   convention  of  a two character
        in UNIX and  DOS.   A  pathname   sequence  <cr><nl>  to  signify
        can  be separated by either a /   the  end of each line in a text
        or a \.  Like DOS,  and  unlike   file.  UNIX uses a single  <nl>
        UNIX, disk drives are specified   to  signify  end  of line.  The
        as a colon terminated prefix to   result is that file  processing













        is more complex than it is with   of   an   array   of   handles.
        UNIX.  There are separate modes   Unfortunately,  socket  handles
        for  opening a file as text and   do  not  have  this  attribute.
        binary  with  the  Microsoft  C   One of the few  novel  features
        library.   Binary  mode  treats   of  WIN32  is  the  ability  to
        the  file  as  a  sequence   of   create a handle for a directory
        bytes.   Text  mode  strips off   with the synchronize attribute.
        each  <cr>  in  front  of  each   This handle changes state  when
        new-line  as  the file is read,   any  files under that directory
        and inserts a <cr> in front  of   change.  This is  how  multiple
        each   <nl>   as  the  file  is   views  of  a  directory  can be
        written.  Because the number of   updated   correctly   in    the
        characters     read     doesn't   presence of change.
        indicate the physical  position
        of    the    underlying   file,   4.4  Inconsistent_Interfaces
        programs  that  keep  track  of
        characters read and use lseek()   The WIN32 API handle  interface
        are likely to not work in  text   is      often     inconsistent.
        mode.      Fortunately,    many   Failures  from  functions  that
        programs that run on Windows NT   return  handles return either 0
        do  not  require  the  <cr>  in   or   -1   depending   on    the
        front of each <nl> in order  to   function.    The  CloseHandle()
        work.   This  difference turned   function  does  not  work  with
        out to be  less  of  a  problem   directory  handles.   The WIN32
        that    we    had    originally   API is also  inconsistent  with
        expected.                         respect   to  calls  that  take
                                          pathname  arguments  and  calls
        4.3  Handles vs. file             that    take   handles.    Some
             descriptors                  functions require the  pathname
                                          and  others require the handle.
        The WIN32 API uses handles  for   In some instances,  both  calls
        almost   all  objects  such  as   exist, but they behave a little
        files,     pipes,      sockets,   differently.
        processes, and events, and most
        handles can be duped  within  a   4.5  Chop_Sticks_Only
        process   or   across   process
        boundaries.   Handles  can   be   The WIN32  subsystem  does  not
        inherited      from      parent   have  an  equivalent for fork()
        processes.      Handles     are   or  an   equivalent   for   the
        analogous  to  file descriptors   exec*()  family.   There  is  a
        except that they are unordered,   single     primitive,     named
        so  that a per process table is   CreateProcess()  that  takes 10
        needed    to    maintain    the   arguments,  yet  still   cannot
        ordering.                         perform the simple operation of
                                          overlaying the current  process
        Many  handles,  such  as  pipe,   with  a new program as execve()
        process,   and  event  handles,   requires.
        have a  synchronize  attribute,
        and  a  process  can wait for a
        change of state on any  or  all







⌨️ 快捷键说明

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