<<

File-System Structure Contiguous Allocation

• File structure • Each file occupies a set of contiguous blocks on the disk. – Logical storage unit • Simple – only starting location (block #) and length (number of – Collection of related information blocks) are required. resides on secondary storage (disks). Each file • Random access. system on a separate disk partition. • • File control block – storage structure consisting of information • Wasteful of space (dynamic storage-allocation problem). about a file. • Files cannot grow. • OSes use different allocation methods • Non of the common OSes uses this method. – An allocation method refers to how disk blocks are allocated for files: 7 Contiguous allocation 7 Linked allocation 7 Indexed allocation

Operating System Concepts 12.1 Silberschatz and Galvin  2004 revised by Wiseman Concepts 12.2 Silberschatz and Galvin  2004 revised by Wiseman

Contiguous Allocation of Disk Space Linked Allocation

• Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. • Each block contains data and a pointer to the next block. • Simple - needs only starting address • Free-space management system - no waste of space. • No random access. • File-allocation table (FAT) - disk-space allocation used by MS- DOS and OS/2 employs this method.

Operating System Concepts 12.3 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.4 Silberschatz and Galvin  2004 revised by Wiseman Linked Allocation File-Allocation Table

Operating System Concepts 12.5 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.6 Silberschatz and Galvin  2004 revised by Wiseman

Indexed Allocation Indexed Allocation (Cont.)

• Brings all pointers together into the index block. • Needs an index table. • Random access. • Dynamic access without external fragmentation, but has overhead of index block.

Operating System Concepts 12.7 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.8 Silberschatz and Galvin  2004 revised by Wiseman Two-level index UNIX File System (UFS)

#

outer-index

index table file

Operating System Concepts 12.9 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.10 Silberschatz and Galvin  2004 revised by Wiseman

Free-Space Management Linked list (free list)

• Bit vector (n blocks) • Each freed block contains a pointer to the next free block. No need for space of the bit vector, but needs a space for the 01 2 n-1 • pointers. (FAT anyway has a space for a pointer in each block) … • Cannot get contiguous space easily.

0 ⇒ block[i] free • Error in one pointer can be crucial. bit[i] = 1 ⇒ block[i] occupied  • Bit map requires extra space, but usually a small one. Example: block size = 212 bytes disk size = 230 bytes (1 gigabyte) n = 230/212 = 218 bits (or 32K bytes) • Easy to get contiguous files.

Operating System Concepts 12.11 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.12 Silberschatz and Galvin  2004 revised by Wiseman Linked list (Cont.) Buffer Cache

• Separate section of main memory for frequently used blocks. • Memory-mapped I/O uses Buffer Cache.

Operating System Concepts 12.13 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.14 Silberschatz and Galvin  2004 revised by Wiseman

Recovery Journaling

• If is shut down abruptly, buffer cache may not be • Journaling File System (or Log structured File Systems) flashed into the disk ⇒ The disk may have some inconsistencies. records each update to the file system as a transaction. • Consistency checking – compares data in structure with • All transactions are written to a log. The log is on the disk. A data blocks on disk, and tries to fix inconsistencies. transaction is considered committed once it is written to the log. E.g. try to find blocks which are not free, but don't belonged to However, the file system may not be updated yet. any file. • The transactions in the log are asynchronously written to the file • scandisk on Windows and fsck on UNIX can try to automatically system. When the file system is modified, the transaction is fix such inconsistencies. removed from the log. • If the file system crashes, all remaining transactions in the log must still be performed.

Operating System Concepts 12.15 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.16 Silberschatz and Galvin  2004 revised by Wiseman File System Mounting Swap-Space Management

• A file system must be mounted before it can be accessed. • Swap-space - Virtual memory uses disk space as an extension of the main memory. • An unmounted file system is mounted a mount point. • Swap-space can be: – carved out of the normal file system (Windows) – in a separate disk partition (UNIX). • UNIX does the swapping faster, while changing the size of the swap area is easier on Windows.

Operating System Concepts 12.17 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.18 Silberschatz and Galvin  2004 revised by Wiseman

The UNIX (NFS) NFS (Cont.)

• An implementation and a specification of a system for accessing remote files across LANs. • NFS is designed to operate in a heterogeneous environment of different machines, operating systems, and network • Interconnected workstations with independent file systems, allow architectures. sharing a part of these file systems in a transparent manner. • At the client: Mount operation includes name of remote directory • A remote directory is mounted over a local file system directory. to be mounted and name of machine storing it. The mounted directory looks like an integral subtree of the local file system. • At the server: Export list – specifies local file systems that server exports for mounting, along with names of machines that are • If there is a subtree with the same name, descending from the permitted to mount them. local directory, it will be replaced by the remote subtree. • NFS path-name translation is performed by breaking the path • Specification of the remote directory for the mount operation is into component names and performing a separate NFS lookup nontransparent; the host name of the remote directory and the call for each directory. directory's name have to be provided. Files in the remote directory can then be accessed in a transparent manner. • To make lookup faster, a directory name lookup cache on the client’s side holds the location of least recently used remote • Subject to access-rights accreditation, potentially any file system directories. (or directory within a file system), can be mounted remotely on top of any local directory.

Operating System Concepts 12.19 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.20 Silberschatz and Galvin  2004 revised by Wiseman LDAP - Directory Service LDAP Features

• Tim Howes at the University of Michigan develops LDAP as a • Single Sign-on: A can use the same username and lightweight directory access protocol on 1998. to log onto many different machines. – The administrator no longer has to setup a user account on • It maintains a database with information on the users and each machine that the user needs access to. on your network. • Redirected Profiles/Folder: Users' files are stored in a central • LDAP Versions: location. users' desktop, and files appear to follow them to – UNIX/LINUX: LDAP, OpenLDAP whatever machine they use. 7 There was a pre-"directory services" on UNIXes before – Backing up important files becomes easier. LDAP called NIS (or yp); however NIS lacks encryption, • : configuring many computers simultaneously; e.g.: object oriented and in most of its versions NIS lacks GUI. specifying that: – : ActiveDirectory – Applications be automatically installed on certain computers. – Lotus: Domino/Notes – Certain users cannot use specific programs or Applets. – Novell: NDS and GroupWise – specific machines should not run specific services.

Operating System Concepts 12.21 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.22 Silberschatz and Galvin  2004 revised by Wiseman

LDAP Features (cont.) LDAP organization

• Group Hierarchy: Groups can be grouped into bigger groups • LDAP is well suited for: forming trees of groups. – Information that is referenced by many entities and – Can help reducing the needs of multiplied lists. applications. – The data is more organized. – Information that needs to be accessed from more then one • Replication: LDAP can be easily replicated between two or more location. machines. – Information that is read more often than it is written. – Redundancy. If one machine dies, LDAP can continue to run. • LDAP is not well suited for – All the LDAP servers have up-to-date databases, therefore – Information that changes often. It is not a relational some users can use different servers; yielding load database and for each change it compiles the entire file balancing and better performance. again. • Interface: LDAP can be accessed by GUI, Command Line Utilities, Shell, JavaScript, , Perl and C/C++.

Operating System Concepts 12.23 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.24 Silberschatz and Galvin  2004 revised by Wiseman DHCP SAMBA

• DHCP stands for Dynamic Host Configuration Protocol. DHCP server assigns dynamic IP addresses (identifiers for a • SAMBA stands for Session Message Block. computer or device) to devices on a network. With dynamic • addressing, a device can have a different IP address every time it • SAMBA is a protocol for sharing connects to the network. – files – In some systems, the device's IP address can even change while it is still connected. – printers – serial ports • DHCP also supports a mix of static and dynamic IP addresses. – communications abstractions such as named pipes – The client sends its MAC (Media Access Control) address to the dhcp server and gets an IP number. • Using SAMBA, UNIX machines and Windows machines can see • Dynamic addressing simplifies network administration because and understand each other files and directories. DHCP keeps track of IP addresses rather than requiring an administrator to manage the task. – This means that a new computer can be added to a network without the hassle of manually assigning it a unique IP address. • Many ISPs use dynamic IP addressing for dial-up users.

Operating System Concepts 12.25 Silberschatz and Galvin  2004 revised by Wiseman Operating System Concepts 12.26 Silberschatz and Galvin  2004 revised by Wiseman