File System in Linux - Operating Systems Computing - Lecture Slides, Slides of Operating Systems

Main points of this lecture are: File System in Linux, Directories, Special Files, Symbolic Links, File Access Control, File Status, File Mode, File System Implementation, Removable Filesystems, Super Block, Cylinder Groups, Filesystem Table

Typology: Slides

2012/2013

Uploaded on 04/23/2013

ashakiran
ashakiran 🇮🇳

4.5

(27)

261 documents

1 / 41

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The File System in Linux
The Linux file system is organized in a tree
structure. The files on this tree are one of the
following types:
An ordinary file
A directory file
A special file (representing an I/O device)
A link that points to another file
A socket that is used for interprocess communication
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29

Partial preview of the text

Download File System in Linux - Operating Systems Computing - Lecture Slides and more Slides Operating Systems in PDF only on Docsity!

The File System in Linux

– The Linux file system is organized in a tree

structure. The files on this tree are one of the

following types:

• An ordinary file

• A directory file

• A special file (representing an I/O device)

• A link that points to another file

• A socket that is used for interprocess communication

Directories

– A directory is a file whose content consists of

directory entries for the files in the directory.

• A directory entry contains the name of the file and a

pointer to the file. The pointer is an index called the i-

number to a table known as the i-list.

• Each entry in the i-list is an i-node containing status and

address information about a file or is free.

• The entire file system may contain several self-

contained filesystems , each with its own i-list.

Special Files

– Linux represents I/O devices such as terminals,

printers, tape, and disk drives as special files in the

file system.

• In this way, an application program can treat file and

device I/O in the same way.

• Each special file is stored in the directory /dev.

• A special file can be either a character special file or a

block special file.

  • A character special file represents a character-oriented I/O

device.

  • A block special represents a high-speed I/O device that

transfers data in blocks rather than bytes.

Links

– A directory entry may be a pointer to another file.

This is called a link. There are two kinds of links:

• hard links

• symbolic links

– A hard link is an entry in a directory with a name

and some other file’s i-number. The hard link is

not distinguishable from the original file.

• A file may have several links to it. The link must be to an

ordinary file in the same filesystem.

Symbolic Links

– A symbolic link is a directory entry that contains

the pathname of another file. The symbolic link

can be used as an argument in a command.

– The file pointed to can be removed and the link

will remain.

– A symbolic link can span filesystems and may

point to a directory.

– A symbolic link can be created using ln -s

File Access Control

• The file mode for a file as displayed by ls -l is,

for example:

-rw-rw-rw-

– The first position shows the file type: - for normal,

d for directory, l for symbolic link, c for character

special file, b for block special file.

– Positions 2-4 show read, write, and execute

permission for the owner of the file. A - means no

permission.

File Status

– A file status is kept in the i-node for each file in

the Linux file system. The file status include:

  • mode
  • number of links
  • owner, group
  • size
  • last access, last content change, last status change
  • i-number
  • device
  • block size
  • block count

File Mode

– The file mode consists of 16 bits. We have already

seen the low order 9 bits: the permissions. The

four high bits specify the file type while the next

three bits define the way in which an executable

file is run.

• Set userid: owner of a file changed to user during

execution.

• Set groupid: sets group id during execution.

• The stickybit keeps a shared binary in memory.

– The mode of a file may be changed using the

chmod command

Groups

• A user can belong to one or more groups

specified in the file /etc/group.

• Use the command ‘groups’ to see which

groups you belong to.

• Each file is associated with a group owner. To

change the group owner of a file use ‘chgrp’

– This allows groups to work on the same files (but

it doesn’t coordinate their changes!).

File System Implementation

– A Linux file is an array of bytes stored in a number

of data blocks in a specific filesystem.

– Originally, UNIX blocks were 512 bytes. Some

implementations now use 4K bytes per block.

Since the final block may waste space if it is not

full, it may be broken up into fragments of (e.g.)

1K bytes.

– As said previously, information on files is stored in

an i-node, where the i-nodes for a filesystem are

stored in an i-list.

Removable Filesystems

• One of the Linux filesystems is the root

filesystems. All of the other filesystems are

removable.

– Removable filesystems are attached to the root

filesystem at some leaf node using the mount

command: mount devfile directory [-r]

– The command umount is used to unmount a

removable filesystem.

Mount as read only

Super Block and Cylinder Groups

  • The super block of a filesystem records

information about the filesystem:

  • Size of the filesystem
  • Block/fragment size
  • Length of the i-node list
  • A list of free blocks and length of the list
  • A list of free i-nodes and length of the list
  • The super block is stored at the beginning of a

filesystem.

Filesystem Table

– Each filesystem is represented by its own block-

type special file. The name of this file along with

other information is kept in /etc/checklist or

/etc/fstab:

/dev/vg00/lvol1 / hfs defaults 0 1 31484 564 /dev/vg00/lvol2 swap ignore sw 0 0 16392 592 /dev/vg00/lvol3 /usr hfs defaults 0 2 0 /dev/vg00/lvol4 /tmp hfs defaults 0 2 13 16408

/dev/vg00/lvol5 /users hfs quota,defaults 0 2 0 /dev/vg00/lvol6 /mnt1 hfs rw,suid 0 3 0 /dev/dsk/c4d0s2 /client_server hfs quota,defaults 0 2 0 arthur.cba:/home0 /home0 nfs rw 0 2 0 arthur.cba:/home1 /home1 nfs rw 0 2 0 shamu.cba:/export/home0/userspace /userspace nfs rw 0 2 0

Filesystem Table

– The currently mounted tables are kept in

/etc/mtab:

/dev/vg00/lvol1 / hfs defaults 0 1 917804700 1

/dev/dsk/c4d0s2 /client_server hfs quota 0 2 917804709 1

/dev/vg00/lvol6 /mnt1 hfs defaults 0 3 917804709 1

/dev/vg00/lvol5 /users hfs quota 0 2 917804709 1

/dev/vg00/lvol4 /tmp hfs defaults 0 2 917804709 1

/dev/vg00/lvol3 /usr hfs defaults 0 2 917804709 1

shamu.cba:/export/home0/userspace /userspace nfs rw 0 2 917804764 0

arthur.cba:/home1 /home1 nfs rw 0 2 917804764 0

arthur.cba:/home0 /home0 nfs rw 0 2 917804764 0