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