The document discusses file systems and file management. It defines a file as a named collection of related information stored in physical storage. It describes fundamental file concepts like file attributes, operations, and structures. It also covers file system techniques like file types and extensions. Finally, it discusses file management systems and their objectives to provide data management and I/O support across storage devices.
The document discusses file systems and file management. It defines a file as a named collection of related information stored in physical storage. It describes fundamental file concepts like file attributes, operations, and structures. It also covers file system techniques like file types and extensions. Finally, it discusses file management systems and their objectives to provide data management and I/O support across storage devices.
File Systems Outlines • Fundamental concepts on file
• File system techniques
• Special purpose file systems
Fundamental concepts on file Computer store information in storage media such as disk, tape drives, and optical disks. • The operating system provides a logical view of the information stored in the disk. This logical storage unit is a file. • The information stored in files are non-volatile, means they are not lost during power failures. • A file is named collection of related information that is stored on physical storage. Fundamental concepts on file… • Data cannot be written to a computer unless it is written to a file. • A file, in general, is a sequence of bits, bytes, lines, or records defined by its owner or creator. • The file has a structure defined by its owner or creator and depends on the file type. Text file – It has a sequence of characters. Image file – It has visual information such as photographs, vectors art and so on. Source file – It has subroutines and function that are compiled later. Object file – It has a sequence of bytes, organized into bytes and used by the linker. Executable file – The binary code that the loader brings to memory for execution is stored in an exe file. Fundamental concepts on file… File Attributes • A file has a single editable name given by its creator. • The name never changes unless a user has necessary permission to change the file name. • The names are given because it is humanly understandable. • The properties of a file can be different on many systems, however, some of them are common: Name – unique name for a human to recognize the file. Identifier – A unique number tag that identifies the file in the file system, and non-human readable. Fundamental concepts on file… Type – Information about the file to get support from the system. Size – The current size of the file in bytes, kilobytes, or words. Access Control – Defines who could read, write, execute, change, or delete the file in the system. Time, Date, and User identification – This information kept for date created, last modified, or accessed and so on. Operations, organization and buffering in file File Operations A file is an abstract data type. To define a file properly, we need to consider the operations that can be performed on files. The operating system can provide system calls to create, write, read, reposition, delete, and truncate files. Let's examine what the operating system must do to perform each of these six basic file operations. Operations, organization and buffering in file… Creating a file Two steps are necessary to create a file. First, space in the file system must be found for the file. Second, an entry for the new file must be made in the directory. Writing a file To write a file, we make a system call specifying both the name of the file and the information to be written to the file. Given the name of the file, the system searches the directory to find the file's location. The system must keep a write pointer to the location in the file where the next write is to take place. The write pointer must be updated whenever a write occurs Operations, organization and buffering in file… Reading a file To read from a file, we use a system call that specifies the name of the file and where (in memory) the next block of the file should be put. Again the directory is searched for the associated entry, and the system needs to keep a read pointer to the location in the file where the next read is to take place. Once the read has taken place, the read pointer is updated. Because a process is usually either reading from writing to a file, the current operation location can be kept as a per-process current file- position pointer. Both the read and write operations use this same pointer, saving space and reducing system complexity Operations, organization and buffering in file… Repositioning within a file The directory is searched for the appropriate entry, and the current-file-position pointer is repositioned to a given value, Repositioning writing a file need not involve any actual I/O. This file operation is also known as a file seek. Deleting a file To delete a file, we search the directory for the named file. Having found the associated directory entry, we release all file space, so that it can be reused by other files, and erase the directory entry. Operations, organization and buffering in file… Truncating a file The user may want to erase the contents of a file but keep its attributes. Rather than forcing the user to delete the file and then recreate it, this function allows all attributes to remain unchanged -except for file length-but lets the file be reset to length zero and its file space released. File system techniques • A file is a collection of similar record which is treated as a single entity by users and applications and may be referred by name. • Files have unique file names and may be created and deleted. • Restrictions on access control usually apply at the file level. • A file is a container for a collection of information. File system techniques… • The file manager provides a protection mechanism to allow user‘s administrator how processes executing on behalf of different users can access the information in a file. • File protection is a fundamental property of files because it allows different people to store their information on a shared computer. • File represents programs and data. • Data files may be numeric, alphabetic, binary or alpha numeric. • Files may be free form, such as text files. In general, file is sequence of bits, bytes, lines or records. File system techniques… A file has a certain defined structure according to its type. 1. Text File 2. Source File 3. Executable File 4. Object File File system techniques… File Structure • Field • Record • Database File system techniques… • A field is the basic element of data. • An individual field contains a single value. • A record is a collection of related fields that can be treated as a unit by some application program. • A file is a collection of similar records. • The file is treated as a single entity by users and applications and may be referenced by name. • Files have file names and maybe created and deleted. • Access control restrictions usually apply at the file level. File system techniques… • A database is a collection of related data. • Database is designed for use by a number of different applications. • A database may contain all of the information related to an organization or project, such as a business or a scientific study. • The database itself consists of one or more types of files. • Usually, there is a separate database management system that is independent of the operating system. File system techniques… File Types – Name, Extension • A common technique for implementing file types is to include the type as part of the file name. • The name is split into two parts: a name and an extension. • Following table gives the file type with usual extension and function. File system techniques… File Type Usual Extension Function Read to run machine Executable exe, com, bin language program. Compiled, machine Object obj, o language, not linked Source code in various Source Code c, cc, java, pas asm, a language Textual data, Text txt, doc documents File Management Systems • A file management system is the set of system software that provides services to users and applications in the use of files. • Following objectives for a file management system: To meet the data management needs and requirements of the user which include storage of data and the ability to perform the operations. To guarantee, to the extent possible, that the data in the file are valid. To optimize performance, both from the system point of view in terms of overall throughput. File Management Systems… To provide I/O support for a variety of storage device types. To minimize or eliminate the potential for lost or destroyed data. To provide a standardized set of I/O interface routines to use processes. File Management Systems… To provide I/O support for multiple users, in the case of multiple-user systems File System Architecture. At the lowest level, device drivers communicate directly with peripheral devices or their controllers A device driver is responsible for starting I/O operations on a device and processing the completion of an I/O request. For file operations, the typical devices controlled are disk and tape drives. Device drivers are usually considered to be part of the operating system. • The I/O control consists of device drivers and interrupt handlers to transfer information between the memory and the disk system. • A device driver can be thought of as a translator. • The basic file system needs only to issue generic commands to the appropriate device driver to read and write physical blocks on the disk. • The file-organization module knows about files and their logical blocks, as well as physical blocks. By knowing the type of file allocation used and the location of the file, the file organization module can translate logical block addresses to physical block addresses for the basic file system to transfer. Each file's logical blocks are numbered from 0 (or 1) through N, whereas the physical blocks containing the data usually do not match the logical numbers, so a translation is needed to locate each block. The file-organization module also includes the free-space manager, which tracks unallocated and provides these blocks to the file organization module when requested. The logical file system uses the directory structure to provide the file- organization module with the information the latter needs, given a symbolic file name. The logical file system is also responsible for protection and security. To create a new file, an application program calls the logical file system. The logical file system knows the format of the directory structures. So, it reads the appropriate directory into memory, updates it with the new entry, and writes it back to the disk. Once the file is found, the associated information such as size, owner, access permissions and data block locations are generally copied into a table in memory, referred to as the open-file table, consisting of information about all the currently opened files. The first reference to a file (normally an open) causes the directory structure to be searched and the directory entry for this file to be copied into the table of opened files. The index into this table is returned to the user program, and all further references are made through the index rather than with a symbolic name. The name given to the index varies. UNIX systems64 refer to it as a file descriptor, Windows/NT as a file handle, and other systems as a file control block. Consequently, as long as the file is not closed, all file operations are done on the open-file table. When the file is closed by all users that have opened it, the updated file information is copied back to the disk-based directory structure.