diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 52510d1..67e684f 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -7,30 +7,6 @@ "id": "1bd3c6c2ca7655f0", "type": "tabs", "children": [ - { - "id": "46800597ab6eb156", - "type": "leaf", - "state": { - "type": "image", - "state": { - "file": "Operating Systems/assets/Pasted image 20250505042548.png" - }, - "icon": "lucide-image", - "title": "Pasted image 20250505042548" - } - }, - { - "id": "33dc0f1ebcbf4c21", - "type": "leaf", - "state": { - "type": "image", - "state": { - "file": "Operating Systems/assets/Pasted image 20250505042548.png" - }, - "icon": "lucide-image", - "title": "Pasted image 20250505042548" - } - }, { "id": "565b9e04e8704d81", "type": "leaf", @@ -45,8 +21,7 @@ "title": "File Systems Management" } } - ], - "currentTab": 2 + ] } ], "direction": "vertical" @@ -225,13 +200,14 @@ }, "active": "565b9e04e8704d81", "lastOpenFiles": [ - "Operating Systems/Virtual Memory.md", + "Operating Systems/assets/Pasted image 20250505144352.png", + "Operating Systems/Inter-Process Communication.md", "Operating Systems/File Systems Management.md", + "Operating Systems/Memory Management.md", + "Operating Systems/assets/Pasted image 20250505042548.png", + "Operating Systems/Virtual Memory.md", "Operating Systems/Scheduling.md", "Operating Systems/Processes and Threads.md", - "Operating Systems/Memory Management.md", - "Operating Systems/Inter-Process Communication.md", - "Operating Systems/assets/Pasted image 20250505042548.png", "Operating Systems/assets/Pasted image 20250505042419.png", "Operating Systems/assets/Pasted image 20250204103541.png", "Operating Systems/Overview.md", @@ -262,7 +238,6 @@ "Functional Programming/Proofs.md", "Functional Programming/Recursion.md", "Functional Programming/Lists.md", - "Functional Programming/Eq and Num.md", "Languages & Machines/assets", "Languages & Machines", "Extracurricular/Misc/Proposed Routine Plan.canvas", diff --git a/Operating Systems/File Systems Management.md b/Operating Systems/File Systems Management.md index f8e3869..d2d908f 100644 --- a/Operating Systems/File Systems Management.md +++ b/Operating Systems/File Systems Management.md @@ -1,7 +1,125 @@ +--- +type: theoretical +backlinks: + - "[[Memory Management]]" +--- + + A file system consists of two parts - Collection of files - A directory structure -> provides information about all files in the system ## File - Logical view -> the unit of storing data -Files are mapped by the OS onto physical \ No newline at end of file +Files are mapped by the OS onto physical nonvolatile devices + +**Types:** +- Data + - Numeric + - Character + - Binary +- Program + + +**Attributes**: +- Name +- Identifier (unique number) +- Type[^2] +- Location -> pointer +- Size +- Protection (permissions) +- Datetime and user id + +### Logical Definition +- Named collection of related information +- Files may have free form (text files) or can be rigidly formatted[^1] + +### Operations +- Create +- Write +- Read +- Seek (reposition within file) +- Delete +- Truncate - shorten or cut off by removing data from the end +- Open (load to memory) +- Close (unload) + +### Open files +Tracked by an **open-file table**, counted by **file-open count**. + +In order to [avoid race conditions](Inter-Process%20Communication.md#Avoiding%20race%20conditions), we need to lock the files somehow. +- **Shared lock** -> several processes can acquire concurrently, used for reads +- **Exclusive lock** -> writer lock +- Mandatory vs. advisory -> access is denied depending on locks held and requested vs. processes can find status of locks and decide what to do + + +### Structure +Could be many: +- None +- Simple record + - Lines + - Fixed length + - Variable length +- Complex + - Formatted document + - Relocatable load file [^3] + + +## Directories +Collection of nodes containing information about all files. Also resides on disk. + +**Operations**: +- Search for a file +- Create a file +- Delete a file +- List a directory +- Rename a file +- Traverse file system + +### Single level directory +A single directory for all users. + +Clearly, we need unique names, which can become a problem real fast. That shit is gonna grow super big. + +### Two-level directory +Users have different directories. In Linux -> `/home/user` is separate, allowing for the same file names. Linux, however, uses a multi-level: + +### Tree-Structured Directories +- Efficient searching +- Grouping +- Absolute v. relative path + +### Acyclic-Graph +Have shared subdirectories and files. Symlinks achieve this. + +## Symlinks +**Hard** vs **Soft**. Hard is a literal copy of the file but keep the same inode info, while soft is just a pointer. + +>[!IMPORTANT] +>We only allow links to files to avoid cycles Every time a new link is added we also use a cycle detection algorithm to determine whether it is OK +## Disk +Can be subdivided into **partitions**. + +Disk/partition can be used **raw** (no file system) or can be **formatted**. The entity containing the file system is known as a volume. + +> [!NOTE]- Typical fs organization +> ![](Pasted%20image%2020250505144352.png) + + +## Access lists and groups +Read, write and execute. +Three classes of users on Linux +1. Owner -> 7 (Read Write Execute) +2. Group -> 6 (RW) +3. Public -> 1 (X) + + + + +--- + +[^1]: **Columnar**, fixed-format ASCII Files have fixed field lengths, as opposed to **delimited**, i.e. fields can be as large as we want them to + +[^2]: Extension (.pdf, .txt) as opposed to format, which specifies the [grammar](Regular%20languages.md) of the file + +[^3]: contains information about where to place different parts of the program in memory. diff --git a/Operating Systems/assets/Pasted image 20250505144352.png b/Operating Systems/assets/Pasted image 20250505144352.png new file mode 100644 index 0000000..e78eb35 Binary files /dev/null and b/Operating Systems/assets/Pasted image 20250505144352.png differ