UNIT 8: FILE MANAGEMENT
Key unit competency
To be able to describe role of operating system in file management and explain file management.
Introductory ActivitySwitch
on your computer, open a new document of Microsoft word and type the following text: “The price of success is hard work, dedication to the job at hand, and the determination that whether we win or lose, we have applied the best of ourselves to the task at hand.” Vince LombardiSave the text on the desktop, then answer the following questions:
1. Why is it important to save the document?
2. As you have saved the document on the hard disk, can you give the location (physical address) precisely where it is saved on the Hard Disk?
3. Discuss hat happen when you save 2 documents having the same name?
4. Give the difference between document, file and folder?
5. List and explain properties of the saved document?
6. Explain why application software has different icons while folders always have the same icon?
7. Discuss precautions to protect your document from deletion and editing by unauthorized persons?
8. What are the file system used by operating systems?
8.1. Understanding computer file
Learning Activity 8.1.
1. Observe carefully the figure below and respond to the asked question
2. What do you think, the above figure represents?
3. Discuss the role of the root directory in the above figure.
4. Differentiate a file and folder in the above figure.
8.1.1 Definition of a computer file and folder
a) Definition of a computer file
A computer file is a collection of data or information that has a name, called the filename recorded on a memory storage device like hard drive, USB flash drives or portable SD card.
b) Definition of a folder
A folder is the virtual location for applications, documents, data or other sub-folders. It is a named collection of related files that can be retrieved, moved, and otherwise manipulated as one entity. So a folder is a special type of file on your computer’s file system which contains other files and folders.
c) Difference between File and Folder
•The basic difference between file and folder is that file stores data while folder stores files and other folders.
•The folders, often referred to as directories, are used to organize files on a computer. The folders themselves take up virtually no space on the hard drive.
•The files store data, while folders store files and other folders.
•The file is created by any application program while folder is created by the operating system. The folders are used to organize files on a computer.
•There are many types of files because there are thousands of application programs but folders don’t have types because there is only one operating system running the computer
•In case of Microsoft Windows, folders are opened through windows explorer and files are opened using a specific application program.
d) Properties of a File
The basic properties of a file are:
•Name: It is the only information which is in human readable form.
•Identifier: The file is identified by a unique tag (number) within file system.
•Type: It is needed for systems that support different types of files.
•Location: Pointer to file location on device.
•Size: The current size of the file.
•Protection: This controls and assigns the power of reading, writing, executing.
•Time, date, and user identification: This is the data for protection, security, and usage monitoring.
Note: In Microsoft Windows operating system, to view properties about a file or folder, right-click it and then select Properties. When a file or folder is selected, its properties can also be displayed by pressing Alt+ Enter.
8.1.2. File StructureA.
Definition
A file structure is defined according to the required format that the operating system can understand like:
•A file has a certain defined structure according to its type.
322Computer Science Senior 6 Student Book
•A text file is a sequence of characters organized into lines.
•A source file is a sequence of procedures and functions
.•An object file is a sequence of bytes organized into blocks that are understandable by the machine.
When an operating system defines different file structures, it also contains the code to support these file structure.
B. Classifications of file
There are two basic classification of the file: text file and binary file
.•Text files: the files that contain text. Each byte is an ANSII character or each 2 types is a Unicode character.
•Binary files: The bytes in a binary file do not necessarily contain characters. These files require a special interpretation.
C. File attributes
File attributes are settings associated with files that grant and deny certain rights to how a user and the operating system can access that file.
The following are file attributes for the windows operating system:
•Read-only attribute: it allows a file to be read only and nothing can be written to the file or changed
.•Archive attribute: it tells windows operating to back up the file.
•System attribute: system file
.•Hidden attribute: File will be hidden.
In Linux operating systems, there are three main file attributes: read (r), write (w), execute (x).
•Read: Designated as an “r”; it allows a file to be read, but nothing can be written to or changed in the file.
•Write: Designated as a “w”; it allows a file to be written to and changed.
•Execute: Designated as an “x”; it allows a file to be executed by users or the operating system.
D. File management operations
The operating system maintains a secure and well managed file system for all the users of the computer system. Mechanisms will have to exist to ensure correct and authorized use of any of the files under the file manager’s care. The file manager is the most visible to the user, as the user has specific file requirements and expects requirement results to be evidenced. The file manager aims to ensure data integrity and ensures that files are kept secure. In order to do this the file manager maintains accurate information about all the files, their use and their movement throughout any file management system. A file is created, modified or deleted in some way as a direct result of some form of processing activity - which in turn is undertaken by the process manager. As such the file manager needs to ensure that all its files are fully protected from misuse or accidental damage at all times.The File Manager (FM) has a predetermined policy that states how a file is created, used, stored and retrieved.
D. Typical responsibilities of a File Manager include:
•create and delete files•allocate and de-allocate file space - communicating availability to others
•track where files are stored - referring to files by symbolic name (the user does not have to worry about exact storage location)•store files efficiently
•identify and list all the files owned by a particular owner
•add or delete authorized users and their files•access files efficiently, e.g., to retrieve files just using their symbolic names
•share files
•control access to files, for example preventing a data file from being corrupted
•reallocate file space•protect files from the failure of the operating system (or hardware)
•be able to store files to new storage media, such as additional disks or drives
E. Directory structure
A directory is basically a set of linked files whereby they are organized in a way suited to the humans that they serve. The file manager will observe a set of rules (a policy) in which it will look after the directory and access rights to the files contained within. Directories are organized on a volume, (HDD, FDD, Tape, etc.). This organization provides a logical and controlled access to files. The normal organization is a tree structure. This provides easy and fast access and searches. Each directory entry will contain fields to indicate:
1. A symbolic name of the file
2. The size and the position of the file on the volume
3. The type of access permitted to the file
F. File Names
Files may be identified as follows:
-Absolute Name (complete name) Volume I Directory Path FileName.Ext
Example: (DOS) C:\public\help\test.hlp
•Relative Name: FileName.ext (short name) (Retrievable from current directory)
• Extension Indicates file type(contents & use of file)
8.1.3 File System
The File system is used to store and organize data on media, such on hard disk, USB flash disks or portable SD card.
The computers use particular kinds of file systems which depends on the operating system installed on the computer. Normally, the computers organize data in folders and folders contain files and other folders. The Microsoft Windows operating system have two types of file systems FAT (File Allocation Table) and NTFS (New Technology File System).
a) FAT File Systems
The FAT File System is simple, manageable and robust. It was created by Microsoft in 1977 and is widely used and found in different portable and embedded devices. Its organization is represented in the figure below.
Description:
The FAT file system originates from its prominent use of an index table that is allocated at the time of formatting. The index table is made up of clusters. A cluster is a unit of space which is used for storage of files and folders. Each cluster contains entries for storage in the disk. Each entry contains
•The total number of clusters in the file,
•An unused disk space,
•The special reserved areas of the disk.
The root directory of the disk contains the total number of cluster files in each file of that directory. The operating system then traverses the FAT table by looking through the cluster files of each disk file and then making a cluster chain till the end of the file is reached.
The FAT file system offers good performance in light-weight implementations. It makes the data sharing easy and convenient. It is also a useful format for solid state memory cards. Due to technology advancement and the increased need for more space, various versions of FAT file systems have evolved. Some of them are mentioned below:
•FAT 12: it was the first system introduced and had a storage capacity of 32 MB
•FAT16: it has a storage capacity of 2 GB
•FAT32: it is the third and latest file system and has a storage capacity of 8 GB
However, in FAT there is no security of data and it is not easily recoverable. This file system is also used to format the hard disk for ‘multi-booting’ the OS configuration.
b) NTFS file system
NTFS is a widely popular file system and it was introduced after the FAT file system. It was developed in 1993 and it was first used in the operating system MS Windows 3.1. Its mode of functioning is represented in the following figure.
Description:
It supports the data storage capacity up to 256 TB. It is used in all the latest versions of MS Windows such as MS Windows 10, MS Windows 8, MS Windows 7, MS Windows Vista, MS Windows XP, MS Windows 2000.
NTFS has an advanced data structure and sectors writing technique, improved security, and high capability of space utilization. NTFS has several improved features over FAT file system that are stated below:
•It is more stable and reliable
•It supports automatic recovery record the information in case of hard disk crash
•It has high speed to read and write data from the hard drive•It has high security over individual files and folders
•It supports multi-booting system
•The NTFS’s data can be shared and accessed over the network
•It has File Encryption
NTFS system is a better file system. It comes with high security and data safety whereas the FAT file system is low on data security and it can be easily modified and shared by anyone.
c) Comparison between NTFS and FAT File Systems
The File System is the most popular and widely used technique to store data on different types of storage memory devices such as a hard disk, memory card and USB Flash Disk. The data can also be upgraded or degraded while formatting the system. The devices write and store the data in their systems so that the data can be modified, accessed, deleted, or distributed at the time of need. Both NTFS and FAT are two different methods and they store the data in a structured way on a disk partition.
As there are various Operating Systems in the world, there are also numerous File Systems used and specific to each OS.
Linux File Systems are ext2, ext3 and ext4 while MAC OS file systems are APFS (Apple File System).
8.1.4. Hierarchical File System
A hierarchical file system shows how drives, folders and files are organized in the operating system. In a hierarchical file system, the drives, folders, and files are displayed in groups, which allows the users to see only files they are interested in.
The example below illustrates the hierarchical file system:
8.1.5. File manipulation functions
The File Manipulation functions allow the user to manipulate directories/folders by creating, opening, saving documents, etc. The following are some of the typical file operations:
1. Creating: It helps in creating a new file at the specified location in a computer system. The new file could be a word document, an image file or an excel worksheet.
2. Saving: It helps in saving the content written in a file at some specified location. The file can be saved by giving it a name of our choice.
3. Opening: It helps in viewing the contents of an existing file.
4. Modifying: It helps in changing the existing content or adding new to an existing file.
5. Closing: It helps in closing an already open file.
6. Renaming: It helps in changing the name of an existing file.
7. Deleting: It helps in removing a file from the memory of the computer system.
The application of the above functions will depend on the kind of operating system used. In this case Microsoft Windows is used.
8.1.5.1 Access files and folders using command prompt
Step1 1:Open Run command(Win key+R) and type cmd for command prompt then press enter key.
This will open the command prompt.
Step 2:Now write “Start file_name or start folder_name” in the command prompt ,
for example:- write “start mspaint” it will open ms-paint automatically.
Note: - These steps only allow you to access files, folder or software which is present in the “c” drive or system drive. To access file/folder from another driver you need to change drive in the command prompt, then you will access the files/folders from another drive. You can also hide files and folder using command prompt. To change one drive to another drive, type drive name followed by “:”. It will change default drive(c to your required drive
8.1.5.1 File and folder viewing using windows explorer
•Hide/Show hidden files
In most of the operating systems, system files are hidden because an accidental deletion of one of them can make the whole system failing or crashing. Sometimes, the user can decide to see the hidden folders and files or not. To hide or unhide files and folders, do the following actions:
1. Open Folder options on your Windows PC
2. Navigate to “View” tab on Folder Option.
3. Scroll down the horizontal scroll bar on the “Advanced setting” of the view tab till you get the option “Hidden files and folder“.
4. You will get two check boxes under “Hidden Files and folder” as
•Don’t show hidden files, folder or drives
•Show hidden files, folder and drives
5. Just select “Don’t show hidden files, folder or drives” to hide the hidden files and folder and select “Show hidden files, folder and drives” to show those hidden files and folder.
6. Now “Apply” all the changes and click on “ O K “.That is it.
Assigning the hidden attributes to File/folder in Windows
To assign the hidden attribute to files or folders, do the following steps:
1. Select the file/folder that you want to make hidden.
2. Right click of mouse on that file and choose “Properties“.
3. Navigate to “General” tab. (By default that will on the general tab. If not then navigate to it)
4. On the “Attributes” section you will get a check box “Hidden“.
5. Just tick that “hidden” check box.
6. Now “Apply” all the changes and click on “OK“.
7. Now the selected file/folder is hidden.Remove the hidden attribute from a file/folder in Windows
The steps to remove the hidden attributes are:
a. First you need to show the hidden files or folder to view the hidden files/
b. folder by following the above process.
c. Select the file/folder whose hidden attribute you want to remove. (Note: Hidden files/folder are viewed as faded)
d. Right click of mouse on those files/folder and choose “Properties“
e. Navigate to “General” tab. (By default that will on the general tab. If not then navigate to it)
f. On the “Attributes” section you will get an check box “Hidden”. Just unchecked that “Hidden” check box. Now “Apply” all the changes and click on “OK“.Now the hidden attribute for the selected file/folder is removed and it is converted to general file/folder.
Application Activity 8.1.
Question A
1. What do understand by a cluster?
2. List and explain various version of FAT file system?
3. Investigate why it important to organize file and folders in hierarchal model?
4. What are the advantage of NTFS file system over the FAT file system?
5. What is the difference between home directory and working directory?
6. Distinguish the absolute path name and relative path name?
Question B
1. How to view and change the file attributes in Windows 10
2. Is it possible to create a folder using application software? Justify your answer?
3. Is it possible to create a file using an operating system? Justify your answer?
4. Differentiate the folder and directory?
8.2. FILE TYPE
Learning Activity 8.2.
Observe carefully the figure below and respond to the asked question
1. What did you find in the figure above?
2. Discus why the above files do not have the same graphical representation?
3. How does the operating system recognize the application software that open the file?
4. How can an operating system make use of the file types that it recognizes?
8.2.1. Understanding file type
File type refers to the ability of the operating system to distinguish different types of file such as text files, source files, binary files and others. Many operating systems support many types of files and modern operating system has the following types of files:
a) Ordinary Files or Regular
FileTherefore, all files created by a user are Ordinary Files and belong to any type of application program. Ordinary Files are used for storing the information about the user Programs
Example: Notepad, Paint, C Program, Songs, Database, Image
b) Directory files
There are files stored into the particular directory or folder.
Example: a folder named songs which contains many songs.
c) Special Files
The special files are files which are not created by the user and are files needed to run a System and are created by the Operating System. It means all the files of an operating system are referred as special files.
2.2. File Extension
a) Definition of a file extension
A file extension also called a file suffix, is the character or group of characters after the period that makes up an entire file name.
Example:
Senior6mpc.vlc(the file extenstion here is vlc)
The File extension helps the operating system to determine which program on computer the specific file is associated with and indicates the file type.
When a user attempts to open a file, the operating system checks the file extension and open the file using the associated application program. The Operating system uses file extensions to indicate the type of each file.
b) Type File and File Extension
c) File Extensions vs File Formats
File extensions and file formats are often used as interchangeably terms which is not true. In reality, however, the file extension is just 3 or 4 characters after the period in the file name while the file format indicates the way in which the data in the file are organized ; in other words it specifies what type of file it is.
Example: In the file name marks.xls, the file extension is xls which indicating that this is a spreadsheet file created in MS Excel.
Application Activity 8.2.
1. File type can be represented by
a. file name
b. file extension
c. file identifier
d. none of the mentioned
2. Name and describe the two basic classifications of files.
3. Name and describe the two basic classifications of files.
4. Distinguish between a file type and a file extension.
5. List advantages of operating system “knowing” and supporting many file types.
6. What would happen if you give the name "myFile.jpg" to a text file?
7. Complete the 3rd column of the table below with appropriate extensions of files.
8.3. FILE ACCESS MECHANISMS
Learning Activity 8.3.
Using DOS command, Create a folder structure for the small business company with three departments namely: Accounts, Personnel and Marketing.
The Accounts department wants to organize its files into Invoices Client folder and Expenses Client folder, the Personnel department wants organize its files in Wages Clientfolder, Contract Client folder and Disciplinary Client folder and the Marketing department wants organize its files in Client folder and Public Relations Client folder. Answer the following questions:
1. How do you access disciplinary folder in personal department?
2. Give the full path to access the public relation folder
The File access mechanism refers to the manner in which the records of a file may be accessed. When a file is used with the Central Processing Unit (CPU), then the stored information in the file must be accessed and read into the memory of a computer system.
Various mechanisms are provided to access a file from the operating system. There are 3 ways to access files: Sequential access, Direct Access and Index Access
8.3.1 Sequential Access method
It is the simplest access mechanism in which information stored in a file are accessed in an order such that one record is processed after the other.
A sequential access is that in which the records are accessed in some sequence. The information in the file is accessed in order where one record is accessed after another. This access method is the most primitive one.
Sequential access generally supports a few operations:
•Read Next: Read a record and advance the tape to the next position.
•Write Next: Write a record and advance the tape to the next position
.•rewind
•Skip n records: It may or may not be supported. N may be limited to positive numbers, or may be limited to +/- 1.
Example:
•Editors and compilers usually access files in this manner
.•Magnetic tape (cassette) operation.
8.3.2 Direct / Access method
It is an alternative method for accessing a file, which is based on the disk model of a file, since disk allows random access to any block or record of a file. In access method, file is viewed as a numbered sequence of blocks or records which are read or written in an arbitrary manner i.e. there is no restriction on the order of reading or writing.
Direct / Random access is the file access method that access the records directly. Each record has its own address on the file with by the help of which it can be directly accessed for reading or writing. The records need not be in any sequence within the file and they need not be in adjacent locations on the storage medium.Random access jump directly to any record and read that record.
Operations supported by direct / random access method include:
•Read n: read record number n.
•Write n: write record number n.
•Jump to record n: could be 0 or the end of file.
•Query current record: used to return back to this record later.
Comparison between Random and Sequential Data Access
Comparing random versus sequential operations is one way of assessing file efficiency in terms of disk use.
a. Sequential file access
•Accessing data sequentially and is much faster than randomly access because of the way in which the disk hardware works.
•Sequential file access allows data to be read from a file or written to a file from beginning to end.
•It is not possible to read data starting in the middle of the file,
•It is not possible to write data to the file starting in the middle using sequential methods.
b.Random Access Files,
•Random access files permit non sequential access to the files’ contents.
8.3.3. Indexed sequential access method
In this method an index is created which contains a key field and pointers to the various block. To find an entry in the file for a key value, we first search the index and then use the pointer to directly access a file and find the desired entry. With large files, the index file itself may become too large to be keep in memory. One solution is to create an index for the index file. The primary index file would contain pointers to secondary index files, which would point to the actual data items.
Indexed Sequential Access Method allows records to be accessed either sequentially (in the order they were entered) or randomly /directly (with an index). Each index defines a different ordering of the records.
Application Activity 8.3.
1. Explain the Indexed Sequential Access Method
2. Compare sequential and direct file access.
3. Explain why it is not possible to write data in the middle of the file using sequential methods?
4. What are advantage of sequential access?
5. File access is independent of any physical medium.
a. How does the Operating System implement sequential access on a disk?
b. How does the Operating System implement direct access on a magnetic tape?
8.4. FILE SPACE ALLOCATION
Learning Activity 8.4.
Observe the below picture and answer below question
1. What do you think of the above figure?
2. How does an operating system track the file stored in the secondary memory?
3. Discuss mechanism used by the OS to allocate files memory space on secondary memory?
8.4.1. File space allocation
File space allocation is the method by which data is apportioned physical storage space in the operating system. The kernel allocates disk space to a file or directory in the form of logical blocks.
The logical blocks are not tangible entities. However, the data in a logical block consumes physical storage space on the disk. Each file or directory consists of 0 or more logical blocks. The main idea behind allocation is effective utilization of file space and fast access of the files. There are three types of allocation:
•Contiguous allocation
•Linked allocation
•Indexed allocation
In addition on storing the actual file data on the disk drive, the file system also stores metadata about the files: the name of each file, when it was last edited, exactly where it is on the disk.
8.4. 2 Contiguous allocationIn
contiguous allocation, each file occupies contiguous blocks on the disk. The location of a file is defined by the disk address of the first block and its length.
Both sequential access and direct/Random access are supported by the contiguous allocation. As it supports random access by using Disk Block Address we can jump directly on the required location.
8.4.3. Linked allocation
In linked allocation, each file is a linked list of disk blocks. The directory contains a pointer to the first and optionally the last block of the file.
Example: a file of 5 blocks which starts at block 4, might continue at block 7, then block 16, block 10, and finally block 27. Each block contains a pointer to the next block and the last block contains a NIL pointer. The value -1 may be used for NIL to differentiate it from block 0.
8.5.4. Indexed allocation
Linked allocation does not support random access of files, since each block can only be found from the previous. Indexed allocation solves this problem by bringing all the pointers together into an index block. One disk block is just used to store DBAs (disk block addresses) of a file.
Every file is associated with its own index node. If a file is very large then one disk block may not be sufficient to hold all associated DBAs of that file. If a file is very small, then some disk block space is wasted as DBAs are less and a single disk block could still hold more DBAs.
8.5. END UNIT ASSESSMENT
1. What do you understand by a file?
2. Using their respective attributes, compare a file and folder?
3. Discuss a situation where file is considered as Executable file?
4. Write a note about the Access methods available in file management?
5. What are the different directory structures available?
6. Discuss different methods for allocation in a File System
7. Discuss different operations that can be performed on a File?
8. Consider a system that supports the strategies of contiguous, linked, and indexed allocation. What criteria should be used in deciding which strategy is best utilized for a particular file?
9. Elaborate on the three major disk space allocation methods in detail?
10. Give an example of an application in which data in a file should be accessed in the following order:
a. Sequentially
b. Randomly