Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University.

Similar presentations


Presentation on theme: "The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University."— Presentation transcript:

1 The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University

2 Introduction File: logically a container for data. Filesystem: represent and organize the system’s storage resources.

3 Introduction Cont’d Some portions of a file tree are handled by traditional disk based implementation; others are fielded by separate drivers within the kernel. A complicated factor in UNIX filesystems is that they tend to support more than one type of disk-based file systems.

4 Main Components Namespace: a way of naming and arranging things in a hierarchy. API (Application Programming Interface) : a set of system calls for navigating and manipulating nodes. Security Model: protection mechanism to enable sharing. Implementation: code that ties the logical model to the actual disk.

5 Pathnames Unix organizes files in a single hierarchy. It starts at root directory /. It continues through an arbitrary number of subdirectories. List of directory to be traversed to locate a file forms the pathname. No restriction on depth of filesystem.

6 / binvmunix hostspasswd etcdevusr locallib A directory tree

7 Pathnames Cont’d Pathnames can be either absolute (starting at the root directory) or relative (starting at the current directory). Each component of a pathname can not be more than 255 characters in length. To access a file with pathname longer than 1023 characters, “cd” to an intermediate directory and use a relative pathname. No restrictions on naming of files except they are limited in length and must not contain the “/” character or nulls. The space character is supported. Quote the file name containing spaces: % more “My Excellent file.txt”

8 Mounting One file system is configured to be the “root file system” and its root directory becomes the “system root directory”. Other file systems are attached to the root file system by mounting each new file system onto a directory in the root file system. That “mounted on” directory is also called the “mount point”. The previous contents of the mount point become inaccessible.

9 Mounting one filesystem to another / usr sys dev etc bin / local adm users bin fs0 fs1 usr /

10 Unmounting File systems are detached with the unmount command. In order to unmount a file system: 1) No files or process should be open or running. 2) If a file system contains executable programs, they must not be running.

11 Unmounting Cont’d Do not use command unmount –f. It forces a busy filesystem to be unmounted and may cause crash. Earlier versions : a) lockfs –h dir to “hard lock” the file system. b) unmount it normally. To determine exactly what the offending processes are, run ps with a list of the PIDs returned by fuser.

12 To find out why a file system is busy, run the fuser -c dir command. Example: % fuser -c /usr /usr: 157tom 315ctom …… c: a process that has a current directory on the filesystem. o: an open file. t: a running program. m: a mapped file (shared libraries usually). r: a process whose root directory is on the file system. Unmounting Cont’d

13 Organization of the File Tree Root file system contains the root directory and a minimal set of files and subdirectories. File containing the kernel is called unix or vmunix, and it resides in either the root directory or in a subdirectory such as /kernel or /stand. Part of the root filesystem are: /dev -- for device files. /etc -- for critical system files. /sbin and /bin -- for important utilities. /tmp -- for temporary files.

14 Organization of the File Tree Cont’d Some systems keep shared libraries and the C preprocessor in the /lib directory. Others have moved this into /usr/lib. /usr contains most of the user programs and online manuals etc. /var provides a home for spool directories, log files, accounting information etc. Home directories of users should be kept on different file systems and mounted beneath /usr.

15 File Types Regular Files. Directories. Character Device Files. Block Device Files. UNIX domain sockets. Named pipes (FIFOs). Symbolic links. A few systems do not support UNIX domain sockets and named pipes.

16 File Types Cont’d Directories Current directory:. Parent directory:.. Create:mkdir Delete:rmdir (empty directory) Delete:rm -r (nonempty directory)

17 File Types Cont’d Character and block device files Create:mknod Delete:rm Unix domain sockets Create:socket() Delete:rm or unlink()

18 File Types Cont’d Named pipes Create:mknod Delete:rm Symbolic links Create:ln -s Delete:rm

19 File Attributes Mode: 9 permission bits control who can read, write and execute the contents of the file. 3 bits affect the operation of executable programs. the 12 bits can be changed by the owner of the file or the superuser by using the chmod command. 16-bit word 12 bits together with 4 bits of file type information. The 4 file type bits are set when the file is first created and can’t be changed

20 File Attributes Cont’d The setuid and setgid bits: bits with octal values 4000 and 2000. They allow programs to access files and processes that would be otherwise off-limits to the user that runs them. The sticky bit: octal value 1000. If this bit is set, most UNIX systems don’t allow you to delete them unless You are superuser, the owner of directory, or the owner of the file. The permission bits: remaining 9 bits are permission bits. There are sets of permissions for the owner, group owner and everyone else.

21 File Attributes Cont’d use ls -l to view file attributes. Example: % ls -l /bin/sh -rwxr-xr-x 1 root bin 85924 Sep 27 1997 /bin/sh -regular file rwxr-xr-xthree sets of permission bits 1link count for the file rootowner of the file bingroup owner of the file 85924size of the file in bytes Sep 27 1997the date of last modification /bin/shname of the file

22 File Attributes Cont’d chmod: changes the permissions on a file. chown: changes a file's ownership. chgrp: changes a file’s group ownership. umask: asigns the default permissions.

23 Thanks


Download ppt "The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University."

Similar presentations


Ads by Google