0% found this document useful (0 votes)
7 views4 pages

Files

The document provides an overview of files, their attributes, operations, and directory structures in computer systems. It discusses file creation, reading, writing, and deletion, as well as access methods such as sequential and direct access. Additionally, it covers directory structures including single-level, two-level, tree-structured, and cyclic-graph directories, along with protection mechanisms like access-control lists and user classifications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Files

The document provides an overview of files, their attributes, operations, and directory structures in computer systems. It discusses file creation, reading, writing, and deletion, as well as access methods such as sequential and direct access. Additionally, it covers directory structures including single-level, two-level, tree-structured, and cyclic-graph directories, along with protection mechanisms like access-control lists and user classifications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

FILES

A file is a named collection of related information that is recorded on secondary storage.


The information in a file is defined its creator. Many different types of information may
be stored in a file.
File attributes: -A file is named and for the users convince is referred to by its name. A
name is usually a string of characters. One user might create file, where as another user
might edit that file by specifying its name. There are different types of attributes.
1) Name: - the name can be in the human readable form.
2) Type: - this information is needed for those systems that support different types.
3) Location: - this information is used to a device and to the location of the file on that
device.
4) Size: - this indicates the size of the file in bytes or words.
5) Protection:-
6) Time, date, and user identifications:-
The information about all files is kept in the directory structure that also resides on
secondary storage.
File operations: -
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. The directory entry records the name of the file and the location in the system.
Writing a file:-To write files give the name of the file, the system search the directory to
find the location of the file. The system must keep the writer 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.
Reading a file: - to read from a file, specifies the name of the file and directory is search
for the associated directory entry, and the system needs to keep read pointer to the
location in the file where the next read is to take place. Once the read has taken place,
read pointer is updated.
Repositioning with in a file: - as a file seek. The directory is searched for the
appropriate entry and the current file position is set to given value. This is also known
Deleting a file: - to delete a file, we search the directory for the name file. Found that file
in the directory entry, we release all file space and erase the directory entry.
Truncate a file: - this function allows all attributes to remain unchanged (except for file
length) but for the file to be reset to length zero.
Appending:- add new information to the end of an existing file .
Renaming:- give new name to an existing file.
Open a file: -if file need to be used, the first step is to open the file, using the open
system call.
Close:- close is a system call used to terminate the use of an already used file.
File Types: - A common technique for implementing file type is to include the type as
part of the file name. The name is split in to two parts.
1) The name 2) and an extension.
The system uses the extension to indicate the type of the file and the type of
operations that can be done on that file. See fig 10.2
ACCESSMETHODS: -
There are several ways that the information in the file can be accessed.
1) Sequential method 2) direct access method 3) other access methods.
1) Sequential access method: - The simplest access method is S.A. information in the
file is processed in order, one after the other. The bulk of the operations on a file are
reads & writes. It is based on a tape model of a file. Fig 10.3
2) Direct access:- or relative access:-a file is made up of fixed length records, that
allow programs to read and write record rapidly in no particular order. For direct
access, file is viewed as a numbered sequence of blocks or records. A direct access
file allows, blocks to be read & write.
So we may read block15, block 54 or write block10. There are no restrictions on the
order of reading or writing for a direct access file. It is great useful for immediate
access to large amount of information.
The file operations must be modified to include the block number as a parameter.
We have read n, where n is the block number.
3) Other access methods: - the other access methods are based on the index for the
file. The indexed contain pointers to the various blocks. To find an entry in the file,
we first search the index and then use the pointer to access the file directly and to find
the desired entry. With large files. The index file itself, may become too large to be
kept 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. Fig 10.5.
Directory structures: -
Operations that are be on a directory (read in text book)
Single level directory: - The simple directory structure is the single level directory.
All files are contained in the same directory. Which is easy to understand. Since all
files are in same directory, they must have unique names.
In a single level directory there is some limitations. When the no.of files
increases or when there is more than one user some problems can occurs. If the no.of
files increases, it becomes difficult to remember the names of all the files. FIG 10.7
Two-level directory: - The major disadvantages to a single level directory are the
confusion of file names between different users. The standard solution is to create
separate directory for each user.
In 2-level directory structure, each user has her own user file directory (ufd). Each
ufd has a similar structure, the user first search the master file directory. The mfd is
indexed by user name and each entry point to the ufd for that user. fig 10.8
To create a file for a user, the O.S search only that user’s ufd to find whether another
file of that name exists. To delete a file the O.S only search to the local ufd and it
cannot accidentally delete another user’s file that has the same name.
This solves the name collision problem, but it still has another. This is a
disadvantage when the user wants to cooperate on some task and to access one
another’s file. Some systems simply do not allow local user files to be accessed by
other user. Using path name accesses any file. Here the user name and a file name
define a path name. Ex:- user1/ob
In MS-DOS a file specification is
C:/directory name/file name
Tree structured directory: -
This allows users to create their own subdirectories and to organize their files
accordingly. Here the tree has a root directory. And every file in the system has a
unique path name. A path name is the path from the root, through all the
subdirectories to a specified file. FIG 10.9.
A directory contains a set of subdirectories or files. A directory is simply another
file, but it is treated in a special way. Here the path names can be of two types.
1) Absolute path and 2) relative path.
An absolute path name begins at the root and follows a path down to the specified
file, giving the directory name on the path.
Ex:- root/spell/mail/prt/first.
A relative pathname defines a path from the current directory ex:- prt/first is relative
path name.
To delete a directory first the O.S search that directory is empty or not. If it is empty
deleted directly. But if the directory is not empty, first clear all files, if it contains the
sub directories same procedure is applied recursively to clear them, after that delete
the directory. But in UNIX O.S give the rm command to delete the directory, if that
directory contains subdirectories or files automatically delete all.
A cyclic- graph directory:-
Consider two programmers who are working on a joint project. The files
associated with that project can be stored in a sub directory, separating them from
other projects and files of the two programmers. Both programmers can include that
sub directory in their own directories. That means a shared directory or file will exist
in the file system in two places at once. Notice that a shared file is not the same as
two copies of the file, each programmer can view the copy rather than the original but
if one programmer changes the file the changes will not appear in the others copy
with a shared file there is only one actual file, so any changes made by one person
would be immediately visible to the other.
A tree structure prohibits the sharing of files or directories. An acyclic graph
allows directories to have shared subdirectories and files
FIG 10.10. it is more complex and more flexible. Also several problems may occur at
the traverse and deleting the file contents.
Protection: -
 When the information is kept in a computer system, we want to keep if secure
from physical damages and from improper accesses.
 To provide reliability one way is to maintain the duplicate copies of files.
 Protection can be provided in many ways. For single user systems, we might
provide protection by physically removing the floppy disks and locking them
in desk drawer.
 For multi user systems use another approach: we could provide complete
protection by prohibiting accesses to the files.
 The most common way to provide the protection is dependent on the identity
of user.
 The most general scheme is implement identity of users is to maintain access-
control list (ACL). In ACL associate with each file and directory specifying
the user name and the types of accesses allowed for each user.
 When the user requesting access to a particular file, the O.S checks ACL with
that file. If the user is listed for the requested access, the access is allowed.
Other wise the protection violation occurs.
 But this technique has limitation: i.e constructing such list may be difficult,
because we do not know in advance the list of users in the system. The
solution for this problem is
 The system recognizes 3 classes of users with each file.
 Owner: the User who crated the file
 Group: The set of users who are sharing the file.
 Universe: All other users in the system.
 The O.S combine the ACL with owner, group, others access control scheme.
 Ex: In Unix each one has 3 bits, ie for each file totally 9 bits are there, these
bits indicate access permissions. Ex: rwxrw-r—
 Another approach for protection is to maintain the passwords with each file.
By using this we clearly provide the security. But it has one problem i.e
maintain the separate password foe each file, if the no. of files in the system
increases, than it is very difficult for the user to remember all passwords.

You might also like