Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS8: File System 8.5. Windows File and Directory.

Slides:



Advertisements
Similar presentations
NT Net Lib Roteiro da apresentação: diagrama de fluxo de chamadas da API Win32 explicação das chamadas apresentação da classe Uma mini-biblioteca com as.
Advertisements

Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS1: Overview of Operating Systems 1.1. Windows.
Chapter 10: File-System Interface
UNIX File Systems (Chap 4. in the book “the design of the UNIX OS”) Acknowledgement : Soongsil Univ. Presentation Materials.
Case Study: Windows 2000 Part I Will Richards CPSC 550 Spring 2001.
Linux+ Guide to Linux Certification, Second Edition
WinAPI i System Plików 1. Volume Management 2. Disk Management 3. Directory Management 4. File Management Autor: Tomasz Jurkiewicz.
1 JMH Associates © 2004, All rights reserved Chapters 2-3 Input/Output With File and Directory Processing.
1 JMH Associates © 2004, All rights reserved Chapter 1 Getting Started with Win32/64.
Command Prompt Chapter 7 Using ATTRIB, SUBST, XCOPY, DOSKEY, and the MS-DOS Text Editor Richard Goldman ©January 31, 2000.
Budapesti Műszaki és Gazdaságtudományi Egyetem Méréstechnika és Információs Rendszerek Tanszék Scheduling in Windows Zoltan Micskei
 AFS name space managed as mini-file systems (aka Volumes)  AFS Mount Points are the equivalent of NTFS Junctions and DFS Referrals which are stored.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 11 Case Study 2: Windows Vista Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Input/Output With File and Directory Processing. – 2 – OBJECTIVES Describe the Windows file systems (compared to UNIX/Linux) Perform sequential file processing.
7.3. Windows Security Descriptors
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS3: Concurrency 3.5. Lab Slides & Lab Manual.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
Linux+ Guide to Linux Certification, Second Edition
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
Chapter 4. INTERNAL REPRESENTATION OF FILES
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Win32 Programming Lesson 7: Kernel Objects. Abstract  Many of the concepts we’ll look at today won’t make complete sense until you use them  However,
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS8: File System 8.3. Encrypting File System Security.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS5: Memory Management 5.5. Lab Manual.
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Unit OS8: File System 8.6. Lab Manual. 2 Copyright Notice © David A. Solomon and Mark Russinovich These materials are part of the Windows Operating.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS A: Windows Networking A.2. Windows Sockets.
Unit OS11: Performance Evaluation Lab Manual.
3.1. Concurrency, Critical Sections, Semaphores
Unit OS A: Windows Networking A.4. Lab Manual. 2 Copyright Notice © David A. Solomon and Mark Russinovich These materials are part of the Windows.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS8: File System 8.1. Background: File System.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS7: Security 7.1. The Security Problem.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Chapter 16 File Management The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander John.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS2: Operating System Principles 2.4. The Windows.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS7: Security 7.4. Lab Manual.
Basic DOS How to get some work done. It’s all a file Everything is a file: OS files, Application files, Data files and Game files Files have 8.3 names:
GAME203 – C Files stdio.h C standard Input/Output “getchar()”
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS3: Concurrency 3.3. Advanced Windows Synchronization.
System Programming Course introduction Getting Started …
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS1: Overview of Operating Systems 1.1. Windows.
Input/Output With File and Directory Processing
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Mario Tayah and Jim Fawcett CSE 775 – Distributed Objects Spring 2007
File Management Mario Tayah and Jim Fawcett
Unit OS7: Security 7.4. Quiz Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze.
Unit OSC: Interoperability
Unit OS4: Scheduling and Dispatch
Unit OS11: Performance Evaluation
Unit OS A: Windows Networking
Unit OS8: File System 8.6. Quiz
Unit OS2: Operating System Principles
Unit OS10: Fault Tolerance
Unit OSB: Comparing the Linux and Windows Kernels
File Management.
Windows Internals Brown-Bag Seminar Chapter 1 – Concepts and Tools
Windows APIs File Processing Copyright © 2016 Curt Hill.
Files in Windows API David Halbig Lopez.
The Unix File System.
Unit OS5: Memory Management
3.3. Advanced Windows Synchronization
Advanced UNIX progamming
Input - Output.
Internal Representation of Files
Mario Tayah and Jim Fawcett CSE775 – Distributed Objects Spring 2007
The CreateFile Function
Introduction to Operating Systems
Command Prompt Using DEL, DELTREE, RENAME and MOVE
Presentation transcript:

Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS8: File System 8.5. Windows File and Directory Management

2 Copyright Notice © David A. Solomon and Mark Russinovich These materials are part of the Windows Operating System Internals Curriculum Development Kit, developed by David A. Solomon and Mark E. Russinovich with Andreas Polze Microsoft has licensed these materials from David Solomon Expert Seminars, Inc. for distribution to academic organizations solely for use in academic environments (and not for commercial use)

3 Roadmap for Section 8.5 Windows File I/O API - General Principles Moving and Copying Files Directory Management Directory Searching File and Directory Attributes

4 Windows API I/O: File and Directory Management Windows API provides a number of straightforward functions to manage files Delete, copy, rename files Create temporary file names Absolute pathnames start with drive letter or server name! It is not possible to delete an open file in Windows (but it is possible in Windows9X) UNIX unlink() decrements link count (but does not necessarily delete file) BOOL DeleteFile (LPCTSTR lpszFileName)

5 Moving files Copies the named existing file and assigns new name An existing file will be replaced only if fFailIfExists == FALSE DeleteFile() and CopyFile do not work for directories Win32 does not support any file linking (but NTFS and POSIX subsystem do) BOOL CopyFile( LPCTSTR lpszExistingFile, LPCTSTR lpszNewFile, BOOL fFailIfExists );

6 Moving Files (contd.) MoveFile() fails if the new file already exists (use MoveFileEx() for existing files) Windows 9X does not implement MoveFileEx() New files can be on different drives / directories New directories must be on same drive lpszNew == NULL : existing file is deleted fdwFlags: MOVEFILE_REPLACE_EXISTING – replace existing destination file MOVEFILE_COPY_ALLOWED – destination may be on different volume BOOL MoveFile (LPCTSTR lpszExisting, LPCTSTR lpszNew); BOOL MoveFileEx( LPCTSTR lpszExisting, LPCTSTR lpszNew, DWORD fdwFlags);

7 Directory Management lpszPath points to null-terminated string with the name of the target directory Only an empty directory can be rmoved lpsa == NULL will create a null-ACL for the new directory BOOL CreateDirectory( LPCTSTR lpszPath, LPSECURITY_ATTRIBUTES lpsa ); BOOL RemoveDirectory( LPCTSTR lpszPath );

8 Directory Management (contd.) Each process has current working directory Each individual drive keeps working directory GetCurrentDirectory: ccCurDir is size of buffer in characters (!) Buffer to small: GetCurrentDirectory() returns required size (!) or zero on failure Call GetCurrentDirectory twice: first to obtain size of buffer, next to obtain value (or use MAX_PATH constant) BOOL SetCurrentDirectory( LPCTSTR lpszCurDir ); DWORD GetCurrentDirectory( DWORD cchCurDir, LPTSTR lpszCurDir );

9 Directory Searching Search a directory for files that satisfy a specified name pattern Search handles must be obtained via FindFirstFile() and closed via FindClose() FindFirstFile() examines subdirectories and file names Return of INVALID_HANDLE_VALUE indicates failure Parameters: lpszSearchFile points to directory/pathname that can contain wildcard characters (? and *; no regular expressions) lpffd points to data structure with access information HANDLE FindFirstFile( LPCTSTR lpszSearchFile, LPWIN32_FIND_DATA lpffd );

10 WIN32_FIND_DATA structure typedef struct _WIN32_FIND_DATA { // wfd DWORD dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; DWORD nFileSizeHigh; DWORD nFileSizeLow; DWORD dwReserved0; DWORD dwReserved1; TCHAR cFileName[ MAX_PATH ]; TCHAR cAlternateFileName[ 14 ]; } WIN32_FIND_DATA; Does not contain path- portion of name DOS 8.3 name FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_COMPRESSED, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_ENCRYPTED, FILE_ATTRIBUTE_HIDDEN,.FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_OFFLINE, FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_SPARSE_FILE, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_TEMPORARY

11 Directory Searching (contd.) FindNextFile() returns FALSE in case of invalid arguments or if no more matching files are found GetLastError() returns ERROR_NO_MORE_FILES Use FindClose() to close search handle CloseHandle() will raise an exception GetFileInformationByHandle() obtains same info... Programs must do wildcard expansion on their own MS-DOS shell (cmd.exe) does not expand wildcards (sh.exe does) BOOL FindNextFile( HANDLE hFindFile, LPWIN32_FIND_DATA lpffd ); BOOL FindClose( HANDLE hFindFile );

12 More File and Directory Attributes File times are 64-bit unsigned integers (time in 100 ns units (10 7 / s) since January 1, 1601) FileTimeToSystemTime()/SystemTimeToFileTime() convert into years down to milliseconds (and vice versa) CompareFileTime(), SetFileTime() NTFS supports all three file times FAT is accurate only for LastAccess-time BOOL GetFileTime( HANDLE hFiles, LPFILETIME lpftCreation, LPFILETIME lpftLastAccess, LPFILETIME lpftLastWrite );

13 File Attributes (contd.) Returns file attribute or 0xFFFFFFFF in case of failure Attributes include: FILE_ATTRIBUTE_DIRECTORYFILE_ATTRIBUTE_NORMALFILE_ATTRIBUTE_READONLYFILE_ATTRIBUTE_TEMPORARY SetFileAttribute() changes those attributes for a file DWORD GetFileAttributes( LPCTSTR lpszFileName )

14 File Flags - controlling read-ahead Cache Manager (CM) performs read-ahead and write-back Reading the next block during sequential access Asynch. read-ahead with history for strided access history of the last two read requests If a pattern can be determined, cache manager extrapolates it Cache Manager un-maps cached data according to access scheme File flags can be specified when opening a file with CreateFile() FILE_FLAG_SEQUENTIAL_SCAN Instructs Cache Manager to perform sequential read-ahead FILE_FLAG_ RANDOM_ACCESS Instructs Cache Manager not to perform read-ahead FILE_FLAG_NO_BUFFERING Cache Manager shall not be involved with I/O on this file

15 Further Reading Mark E. Russinovich and David A. Solomon, Microsoft Windows Internals, 4th Edition, Microsoft Press, Chapter 12 - File Systems NTFS On-Disk Structure (from pp. 732); File System Operation (from pp. 700) Chapter 11 - Cache Manager File System Interfaces (from pp. 674) Jeffrey Richter, Advanced Windows, 3rd Edition, Microsoft Press, September Chapter 14 - File Systems Directory Operations (from pp. 637) Johnson M. Hart, Windows System Programming, 3rd Edition, Addison-Wesley, 2004.