File System
How different files are saved (images vs sounds), UNIX file system, inodes.
10 flashcards · Computer Science · by lakesare
How are sound files stored in binary (e.g. .wav)?
metadata each bit is a sample of amplitude at a given moment.
How are raster image files stored in binary (e.g. jpg)?
metadata (image width&height, total file size, color depth) each bit is a rgb value of color depth at a given moment. Because metadata specified that our pic was 4x4, we know when another row starts.
What's a file in Unix system?
Any resource from/to which a sequence of bytes may be read/written. In the Unix Way of Doing Things: everything is a file. A directory is one (of many) type of special file. It doesn't contain data. Instead, it contains pointers to all of the files that are contained within the directory. Other types of special files: links sockets devices But because they are considered "files", you can ls them and rename them and move them and, depending on the type of special file, send data to/from them. On…
What's stored inside of the directory file?
Directories are files like any other, with: file-name, and inode number stored for every file within that directory. Whenever a user refers to a file by name, OS uses that name to look up the corresponding inode, the inode numbers and their corresponding inodes are held in inode tables. Directory associates file names with inodes.
What's assigned to a file on its creation?
file-name, and inode number
Name 5 things stored in an inode?
size of the file (in bytes) addresses of all the blocks (containing the file's data on a HDD) owner and group access permissions (i.e., which users are permitted to read, write and/or execute the file), timestamps telling when the inode was created, last modified and last accessed and reference count telling how many hard links point to the inode.
Name and explain 2 types of links.
hard link: like giving another name to the same inode. symbolic link: contains a text string that is automatically interpreted and followed by the operating system as a path to another file. Symbolic links are also called 'symlinks' and 'soft links'.
What happens when a symlink vs hard link get deleted?
If symlink is deleted - only this file is deleted. If hard link is deleted - only this file is deleted. UNLESS it's the last hard link to this inode, then inode itself and file are deleted too. Inode (and file it points to) only gets deleted when all the hard links are destroyed.
What happens if symlink's target gets renamed/moved/deleted?
Symlink is not automatically updated or deleted, but continues to exist and still points to the old target, now a non-existing path of a file.
What's an orphaned (broken/dead/dangling) symlink?
Symlink that points to nonexisting file (because it was moved/renamed/deleted).