File System and Directory Structure organization

एक directory structure एक organization system है जो मानव-पठनीय names को file locations से map करता है, अराजक single lists से संगठित multi-level trees की ओर बढ़ते हुए।

10 min read · 10 cards · 3 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

Shared Drive की टक्कर

कल्पना कीजिए LabOne पर अपना Unix assignment करने के लिए 30 classmates के साथ computer lab में जाना। हर student अपना code लिखता है और file को lab1.c नाम देता है। अगर operating system बस हर एक file को एक विशाल master list में save करता, क्या होता है जब Student 2 save दबाता है? यह तुरंत Student 1 की file overwrite कर देता है। एक operating system अलग users की files को पूरी तरह अलग कैसे रखता है बिना सबको अनोखे file names बनाने पर मजबूर किए?

Theory

Master Box बनाम Student Lockers

एक single-level structure को एक classroom के बीच में एक विशाल cardboard box की तरह सोचिए। अगर हर कोई अपनी notebooks उसमें फेंकता है, अपनी खोजने में हमेशा लगता है, और अगर दो किताबें एक जैसी दिखती हैं, उलझन चरम पर होती है। एक tree-structured directory हर student को एक समर्पित locker देने जैसा है, जिसके अंदर वे labeled boxes रख सकते हैं, और उन boxes के अंदर, ख़ास folders। आपके box में एक नीली notebook हो सकती है, और आपके दोस्त के box में एक नीली notebook हो सकती है, पूरी तरह अलग।

Theory

Directory Organization Structures

अराजकता रोकने के लिए, operating systems directory structures इस्तेमाल करके storage organize करते हैं। एक single-level directory सारी files को सभी users के लिए एक अकेली directory में store करता है, विशाल naming conflicts पैदा करते हुए। एक two-level directory individual User File Directories की ओर pointers रखता एक अलग Master File Directory बनाता है, users को अलग करते हुए पर निजी organization सीमित करते हुए। एक tree-structured directory एक root directory को files और subdirectories रखने देता है, एक multi-level hierarchy बनाते हुए जहाँ हर file का एक अनोखा path name होता है।

At a glance

तीन प्राथमिक directory organization methods की संरचनात्मक तुलना।

Structure TypeUser IsolationName ClashesLabOne व्यावहारिकता
Single-Levelकोई नहीं: सारी files साथ बैठती हैंऊँचा: कोई दो files एक नाम साझा नहीं कर सकतींअसंभव: 30 students एक-दूसरे को overwrite कर देते
Two-Levelबुनियादी: हर user को एक folder मिलता हैमध्यम: users में अनुमत, अंदर नहींख़राब: students custom subfolders नहीं बना सकते
Tree-Structuredपूर्ण: अनंत custom foldersकोई नहीं: अलग paths एक जैसे names अलग करते हैंPerfect: multi-user lab sessions सहजता से सँभालता है

Think first

एक File Path हल करना

मान लीजिए आप LabOne में student3 के रूप में logged in हैं और /home/student3/os/lab2.c पर स्थित एक file compile करना चाहते हैं। tap करके प्रकट करने से पहले विश्लेषण कीजिए कि operating system इस absolute path को कदम-दर-कदम कैसे हल करता है।

Show the answer

Step 1: OS root directory पर शुरू करता है, पहले forward slash द्वारा दर्शाया गया।

Step 2: यह root directory में home subdirectory खोजता है और इसका location पाता है।

Step 3: home के अंदर, यह student3 folder खोजता है, user isolation सुनिश्चित करते हुए।

Step 4: student3 के भीतर, यह os नामक custom user subdirectory खोजता है।

Step 5: os के अंदर, यह ख़ास target file lab2.c खोजता है और इसके physical disk blocks retrieve करता है।

Quiz

शुरुआती multi-user operating systems ने जल्दी two-level directory system को एक tree-structured directory के पक्ष में क्यों छोड़ दिया?

  1. क्योंकि two-level directories motherboard पर बहुत ज़्यादा hardware RAM खपत करती थीं
  2. क्योंकि users संबंधित files group करने के लिए अपनी ख़ुद की subdirectories नहीं बना सकते थे
  3. क्योंकि two-level systems users को किसी भी file names साझा करने से पूरी तरह मना करते थे
  4. क्योंकि एक tree structure एक flat index array से खोजने में तेज़ है
Show the answer

क्योंकि users संबंधित files group करने के लिए अपनी ख़ुद की subdirectories नहीं बना सकते थे

जबकि एक two-level directory अलग users को उनका अपना master folder देकर उनके बीच name clashes सुलझाती है, यह user को अपने ख़ुद के folder के अंदर subdirectories बनाने से प्रतिबंधित करती है। एक student operating systems, web development, और mathematics के लिए अलग folders नहीं बना सकता था।

Watch out

Path Ambiguity की ग़लती

university exams में एक आम ग़लती absolute paths को relative paths से उलझाना है। एक absolute path हमेशा root directory से एक forward slash के साथ शुरू होता है, जैसे /var/log/syslog। एक relative path आपकी मौजूदा working directory से शुरू होता है, जैसे os/lab2.c। अगर आप exam विवरण के दौरान एक slash के बिना शुरू होता एक path लिखते हैं, आप एक relative path का वर्णन कर रहे हैं, जो विफल होता है अगर user अपना सक्रिय directory context बदलता है।

Think first

Name Duplicate पहेली

क्या एक tree-structured directory उसी subdirectory के अंदर बिल्कुल एक ही नाम, जैसे main.c, वाली दो files रख सकती है? tap करने से पहले directory map नियमों के बारे में मन में सोचिए।

Show the answer

नहीं। एक tree-structured system में भी, एक अकेली directory एक जैसे नाम वाली दो entries नहीं रख सकती क्योंकि OS एक folder को name से linearly या एक hash map के ज़रिए खोजता है। अगर एक ही folder में दो entries एक नाम साझा करतीं, path lookup अस्पष्ट होता। पर, आप दो बिल्कुल अलग folders में main.c रख सकते हैं।

Theory

Linux Labs और भविष्य के Semesters

आप इस tree structure के साथ लगातार बातचीत करेंगे। Unit 4 में, जब हम अपने LabOne server पर Linux install करते हैं, आप cd और pwd जैसी command line utilities इस्तेमाल करके इस बिल्कुल tree को navigate करेंगे। पूरे system का root एक अकेला forward slash होगा। जब आप Semester 3 पर जाते हैं और Android applications बनाते हैं, आप पाएँगे कि Android का भीतरी file system user privacy की रक्षा के लिए यह बिल्कुल Linux directory structure विरासत में लेता है।

Summary

Key takeaways

  • Single-level directories सारी files को एक जगह में रखती हैं, multi-user systems में गंभीर naming conflicts पैदा करते हुए।
  • Two-level directories users को निजी folders में अलग करती हैं पर उन्हें nested folder trees बनाने से रोकती हैं।
  • Tree-structured directories files को hierarchically organize करती हैं, एक root directory से अनोखे absolute paths इस्तेमाल करते हुए।
  • Absolute paths हमेशा root directory पर शुरू होते हैं जबकि relative paths मौजूदा directory context पर निर्भर करते हैं।
  • Directories names को metadata pointers के साथ जोड़कर store करती हैं, कभी असल file content bytes नहीं।
  • Memory hook: Root आधार है, paths जगह खोजते हैं!

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from File and Memory Management

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

File System and Directory Structure organization · Operating System · Gri-Learn