1 / 18

Disks, Partitions, and Filesystems

Disks, Partitions, and Filesystems. Multiple systems in use S5, UFS, others Focus on standard S5 system HD’s divide into partitions, each of which can contain a file system. Filesystems. Filesystems contain boot block(s), a super block, an i-list, directory blocks and data blocks

haig
Télécharger la présentation

Disks, Partitions, and Filesystems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Disks, Partitions, and Filesystems Multiple systems in use S5, UFS, others Focus on standard S5 system HD’s divide into partitions, each of which can contain a file system

  2. Filesystems • Filesystems contain boot block(s), a super block, an i-list, directory blocks and data blocks • i-nodes contain most file info • directory blocks contain directory info • data blocks contain contents of file

  3. Directories • tables of filenames and associated i-nodes • directories always contain . and .. as table entries • directories are files, with i-nodes, .etc

  4. i-node • contains all info about file • type, access, size, etc. • pointers to data associated with file • count of links to i-node (hard links) • directory entries pointing to i-node • can be pointed to by multiple directory entries • directory entries must point to i-nodes in same file system

  5. link, unlink, remove, rename Functions • link creates directory entry for existing file • takes pathname, returns 0 OK, -1 error • unlink removes existing directory entry • takes pathname, returns 0 OK, -1 error • remove identical to unlink for files, rmdir for directories • takes pathname, returns 0 OK, -1 error • rename changes names of files/directories • takes oldpath, newpath; returns 0 OK -1 error

  6. link • creates directory entry for existing file • increments link count in i-node • operations atomic • only superuser can create links to directories (avoids filesystem loop problems)

  7. unlink • removes directory entry • decrements link count in i-node • must have wx permission in directory • if sticky bit set, must own file, own directory, or be superuser • file not deleted until link count 0 and file not in use

  8. remove • calls unlink for files, rmdir for directories • ANSI C standard (replacing unlink)

  9. rename Function • renames directory or file • if oldname is file • if newname exists, cannot be directory • newname removed, oldname becomes newname • write permission required for both • if oldname is directory • if newname exists, must be empty directory • newname removed, oldname becomes newname • newname cannot contain oldname in path

  10. Symbolic Links • not pointers to i-nodes • symbolic links contain pathname as data • i-node contains flag indicating symbolic link • not constrained to single filesystem, superuser creation of directory links.

  11. symlink and readlink Functions • symlink creates symbolic link • takes realpath, sympath; returns 0 OK, -1 error • can cross filesystems • can be used for directories by ordinary users • readlink manipulates symlink file itself • takes pathname, *buffer, bufsize • returns # bytes read, -1 error • combines open, read, close on symlink file

  12. File Times • last access time of data • system does not maintain i-node access time • last modification time of data • last modification time of i-node

  13. utime Function • changes access and mod times of files • takes pathname, *utimbuf structure • null pointer sets to current time • requires ownership or write permission • non-null pointer requires ownership or root • returns 0 OK, -1 error

  14. mkdir and rmdir Functions • mkdir creates directories • takes pathname, mode • usually want some execute permission • automatically creates . and .. entries • rmdir removes empty directories • takes pathname • both return 0 OK, -1 error

  15. Reading Directories • format of directories system dependent • opendir - open directory stream • takes pathname, returns DIR *, null on error • readdir - read directory • takes DIR *, returns dirent structure *, null on error or EOD • rewinddir - reset stream to beginning of directory • takes DIR *, returns nothing • closedir - close directory stream • takes DIR *, returns nothing

  16. chdir, fchdir, getcwd Functions • chdir, fchdir set current working directory of process • takes pathname, returns 0 OK, -1 on error • getcwd gets absolute pathname of cwd • takes buffer *, size of buffer; returns buff on success, NULL on error

  17. Special Device Files • block special, character special • identified by major/minor numbers • block special • ramdom access device (hard disk, cdrom, etc.) • character special • sequential access device (tape drive, modem, etc.)

  18. sync and fsync Functions • cause kernal buffers to be flushed • sync schedules a write and returns • Linux waits for completion • takes no arg, returns 0 OK, -1 on error • fsync flushes single file buffer, and waits for return • takes FD, returns 0 OK, -1 on error

More Related