Top Banner
http://raj-os.blogspot.in/ 1 File Management Organization of data - Creating a file - Storing a file in required directory - Removing a file - Opening a file - Closing a file - Maintaining of file details - Name, Type, location, size , date and time of creation or modification - File Protection
29

File management53(1)

Oct 21, 2014

Download

Documents

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: File management53(1)

http://raj-os.blogspot.in/ 1

File Management Organization of data

- Creating a file

- Storing a file in required directory

- Removing a file

- Opening a file

- Closing a file

- Maintaining of file details

- Name, Type, location, size , date and time of creation or modification

- File Protection

Page 2: File management53(1)

http://raj-os.blogspot.in/ 2

File Attributes

- Name

- Type

- Location

- Size

- Protection

- Time, Date and User Identification

Page 3: File management53(1)

http://raj-os.blogspot.in/ 3

Name

- Given by the user

- Only information that is kept in human readable form

Type

- Information required by systems that support different

types

File Attributes

Page 4: File management53(1)

http://raj-os.blogspot.in/ 4

Location

- A pointer to a device and to the

location of the file on that device

Size

- Current size of file (in bytes or words )

- Max size allowed

File attributes

Page 5: File management53(1)

http://raj-os.blogspot.in/ 5

Protection

- Access control information

( read, write and execute privileges )

File Attributes

Page 6: File management53(1)

http://raj-os.blogspot.in/ 6

Time, date and user identification

- Creation

- Last modification

- Last use

(Useful for protection, security and usage monitoring )

File Attributes

Page 7: File management53(1)

http://raj-os.blogspot.in/ 7

Basic File Operations ( Minimal Set )

1. Creating a file

2. Repositioning within a file

3. Deleting a file

4. Truncating a file

5. Reading a file

6. Writing a file

Page 8: File management53(1)

http://raj-os.blogspot.in/ 8

1. Creating a file

• Allocation of space for the file in the file system

• Making an entry for the new file in the directory

Basic File Operations

Page 9: File management53(1)

http://raj-os.blogspot.in/ 9

2. Writing a file

• Use a system call specifying

- Name of the file

- Information to be written

• Search directory for the associated entry

• Keep a write pointer

• Update write pointer after every write

Basic File Operations

Page 10: File management53(1)

http://raj-os.blogspot.in/ 10

3. Reading a file

• Use a system call specifying

- Name of the file

- Address where to put the contents read

• Search directory for the associated entry

• Keep a read pointer

• Update read pointer after every read

Basic File Operations

Page 11: File management53(1)

http://raj-os.blogspot.in/ 11

4. Repositioning within a file

• Also known as file seek operation

• Search directory for the appropriate entry

• Set current-file-position to a given value

Basic File Operations

Page 12: File management53(1)

http://raj-os.blogspot.in/ 12

5.Deleting a file

• Search the directory for the named file

• Release all file space

• Erase the directory entry

Basic File Operations

Page 13: File management53(1)

http://raj-os.blogspot.in/ 13

6. Truncating a file

• File contents erased

• Name and attributes of file unchanged

Basic File Operations

Page 14: File management53(1)

http://raj-os.blogspot.in/ 14

Other File Operations• Appending

• Renaming

Appending

Add some information at the end of the file

Renaming Name of file changed

All other attributes unchanged

Page 15: File management53(1)

http://raj-os.blogspot.in/ 15

Basic file operations can be combined to implement other

operations

Ex : Creating a copy of a file

- Create a new file

- Read from old file

- Write to new file

Page 16: File management53(1)

http://raj-os.blogspot.in/ 16

Other Desirable Operations

Allow the user to get and set the various attributes of a file

Ex : i) get the file length

ii) set file attributes like file’s owner

Page 17: File management53(1)

http://raj-os.blogspot.in/ 17

Other Desirable Operations

Most file operations involve searching the directory for the

entry associated with the named file

Page 18: File management53(1)

http://raj-os.blogspot.in/ 18

To Avoid Constant Searching

• Many systems open a file when file first is used

• The operating system keeps a small table called the

Open file table

• Open file table contains information about open files

• When a file operation is requested, an index into the

open file table is used

Page 19: File management53(1)

http://raj-os.blogspot.in/ 19

Other File Operations

When a file is no longer actively used, it is closed by

the process and the O.S. removes its entry in the

Open file table

Page 20: File management53(1)

http://raj-os.blogspot.in/ 20

Other File Operations

• Some systems implicitly open a file when it is first referenced

• Close it automatically when the program that opened the file

terminates

Page 21: File management53(1)

http://raj-os.blogspot.in/ 21

Other File Operations

Most systems require that a file be opened explicitly by the

programmer with a system call ( open ) before that file can be

used

Page 22: File management53(1)

http://raj-os.blogspot.in/ 22

File Type Usual extension Function

Executable Exe, com, bin or none Ready to run machinelanguage program

Object obj, o Compiled, machine language, not linked

Source code c, p, pas, f77, asm, a Source code in various languages

Batch bat, sh Commands to the command interpreter

Text txt, doc textual data,documents

Word Processor

Wp, tex, rrf etc Various word processorformats

Library Lib, a Libraries of routines

Print or view ps, dvi, gif ASCII or binary file in a format for printing or viewing

Archive arc, zip, tar Related group of files for archiving or storage

Fig : Common File Types

Page 23: File management53(1)

http://raj-os.blogspot.in/ 23

File Type

One major consideration in designing a file system, and the

entire operating system, is whether the operating system should

recognize and support file types

Page 24: File management53(1)

http://raj-os.blogspot.in/ 24

File Type

• If the operating system recognizes the type of a file

• it can then operate on the file in reasonable ways

• Ex : An attempt to print a binary-object form of a

program file can be prevented

Page 25: File management53(1)

http://raj-os.blogspot.in/ 25

File Type

To implement file types, include the type as part of

the file name

For Ex : letters , documents

Page 26: File management53(1)

http://raj-os.blogspot.in/ 26

File Type

The file name is split into two parts

- a name

- an extension

Page 27: File management53(1)

http://raj-os.blogspot.in/ 27

File Type

• The file name is usually separated from the

extension by a period ( dot ) character

Ex : paycalc. cpp

• The name can consists up to 8 characters followed

by a period

Page 28: File management53(1)

http://raj-os.blogspot.in/ 28

File Type

The extension tells what the file type is

• Extension can be up to 3 characters

• System uses the extension to indicate the type of the

file

• Type of operations that can be done on that file

For ex : .com , .exe & .bat extension are executable

file

Page 29: File management53(1)

http://raj-os.blogspot.in/ 29

Summary In this class, you have learnt - file concept

- Understand file operations

- Know various file types