Page 387 - DCAP103_Principle of operating system
P. 387

Principles of Operating Systems



                   Notes         Program
                                 /* Open files for input and output */
                                 inhandle = CreateFile(“data”, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
                                 outhandle  =  CreateFile(“newf”,  GENERIC_WRITE,  0,  NULL,  CREATE_ALWAYS,
                                 FILE_ATTRIBUTE_NORMAL, NULL);
                                 /* Copy the file. */
                                 do{
                                     s = ReadFile(inhandle, buffer, BUF_SIZE, &count, NULL);
                                     if(s && count > 0) WriteFile(outhandle, buffer, count, &ocnt, NULL);
                                 } while(s > 0 && count > 0);
                                  /* Close the files. */
                                 CloseHandle(inhandle);
                                 CloseHandle(outhandle);

                                 Windows 2000 NTFS is a hierarchical file system, similar to the UNIX file system. The separator
                                 between component names is \ however, instead of /, a fossil inherited from MS-DOS. There
                                 is a concept of a current working directory and path names can be relative or absolute. Hard
                                 and symbolic links are supported, the former implemented by having multiple directory entries,
                                 as in UNIX, and the latter implemented using reparse points (discussed later in this unit). In
                                 addition, compression, encryption, and fault tolerance are also supported. These features and
                                 their implementations will be discussed later in this unit.
                                 The major directory management API functions are given in Figure 13.4, again along with their
                                 nearest UNIX equivalents. The functions should be self explanatory.


                                   Figure 13.4: The Principal Win32 API Functions for Directory Management. The Second
                                             Column Gives the Nearest UNIX Equivalent, When One Exists



                                     Win32 API function UNIX    Description
                                     CreateDirectory   mkdir    Create a new directory

                                     RemoveDirectory   rmdir    Remove an empty directory
                                     FindFirstFile     opendir  Initialize to start reading the entries in a directory
                                     FindNextFile      readdir  Read the next directory entry
                                     MoveFile          rename   Move a file from one directory to another

                                     SetCurrentDirectory  chdir  Change the current working directory


                                 13.2.3 Implementation of the Windows 2000 File System
                                 NTFS is a highly complex and sophisticated file system. It was designed from scratch, rather
                                 than being an attempt to improve the old MS-DOS file system. Below we will examine a number
                                 of its features, starting with its structure, then moving on to file name lookup, file compression,
                                 and file encryption.
                                 13.2.4 File System Structure

                                 Each  NTFS  volume  (e.g.,  disk  partition)  contains  files,  directories,  bitmaps,  and  other  data
                                 structures.  Each  volume  is  organized  as  a  linear  sequence  of  blocks  (clusters  in  Microsoft’s



        380                               LOVELY PROFESSIONAL UNIVERSITY
   382   383   384   385   386   387   388   389   390   391   392