4.2.33 · D1 · HinglishOperating Systems

FoundationsDirectory structure — tree, DAG (hard links, symbolic links)

2,249 words10 min read↑ Read in English

4.2.33 · D1 · Coding › Operating Systems › Directory structure — tree, DAG (hard links, symbolic links)

Parent note padhne se pehle — jo trees, DAGs, hard links aur symbolic links ke baare mein hai — aapko har ek word ka matlab samajhna hoga. Yeh page unhe ek-ek karke define karta hai, har ek ke saath ek picture hai, aur har ek pehle waale par build karta hai. Agar aapne kabhi inode, link count, ya DAG words nahi dekhe, toh line one se shuru karo aur kuch bhi skip mat karo.


1. Ek file, zero se

Figure — Directory structure — tree, DAG (hard links, symbolic links)

Yeh topic is split ko zaroorat hai kyunki har advanced idea — hard links, symbolic links, DAG — bas names ko numbered lockers se connect karne ka ek alag tarika hai.


2. Inode — numbered locker

Aapko inode ki zaroorat hai kyunki yahi "ek blob" hai jise kai names share karenge. Iska metadata (especially ek counter) sharing ko safe banata hai. Poore contents ke liye dekho Inodes and File Metadata, aur block pointers real disk tak kaise pahunchte hain uske liye dekho File System Implementation — Block Allocation.


3. Directory — sticky notes ki wall

Figure — Directory structure — tree, DAG (hard links, symbolic links)
Recall Ek directory entry ke do columns kya hain?

Question ::: Har entry (name, inode number) mein kya store hota hai, aur kaunsa file ki "identity" hai? Answer ::: Ek human-readable name aur ek numeric inode number. Inode number file ki sacchi identity hai; name sirf uski taraf point karne wala label hai.


4. Path — walls ke through rasta

/ se kisi target tak path follow karna path resolution kehlaata hai; Unix ka routine jo yeh karta hai namei() kahlata hai (dekho Path Resolution and the namei() routine). Yeh jo tool question answer karta hai woh hai: names ki ek string di gayi, main kis inode par khatam hota hun?


Figure — Directory structure — tree, DAG (hard links, symbolic links)

Aapko chahiye kyunki iske bina, jis waqt aapke paas ek file ke liye do names hote, kisi ko nahi pata tha ki ek naam delete karne se data bhi free hona chahiye. Counter iska jawab deta hai.


6. Trees vs DAGs — poore map ki shape

Figure — Directory structure — tree, DAG (hard links, symbolic links)

7. Doosra name add karne ke do tarike (preview)

Parent note upar ki sab cheezein lekar do mechanisms banata hai. Bas itna jaanna kaafi hai ki har ek kya hai:

Ab aapke paas har woh symbol hai jo parent note assume karta hai: file, inode, inode number, directory, directory entry, path, root, ./.., link count , node/edge, tree, aur DAG.


Yeh foundations topic ko kaise feed karte hain

bytes vs name split

inode = numbered locker

directory = list of name to inode

inode number identity

path resolution walk

link count n

tree default shape

free when n equals zero

two names one inode

DAG shape

hard links and symbolic links

Ise upar se neeche padho: split (A) alag inodes (B) aur directories (C) force karta hai, jo inode number (D) par milte hain. Wahan se paths walk karna (E), counter (F), default tree (G) milta hai, aur — jab do names ek inode share karte hain (I) — woh DAG (J) banta hai jis par hard aur symbolic links build hoti hain.


Equipment checklist

Right side cover karo aur khud test karo. Agar koi bhi jawab fuzzy lage, parent note se pehle woh section dobara padho.

  • Ek file do cheezein alag karti hai — kaun si do? ::: Bytes (data) aur naam (label); sirf ek inode number se jode hue.
  • Inode kya hai, aur woh deliberately kya store NAHI karta? ::: File ke metadata aur data-block pointers ka record; yeh file ka naam store nahi karta.
  • Ek directory entry ke do columns kya hain? ::: (name, inode number).
  • . aur .. kahan point karte hain? ::: . directory ke apne inode ki taraf point karta hai; .. uske parent ke inode ki taraf point karta hai.
  • Words mein, link count kya hai? ::: Us inode ki taraf currently point karne wali directory entries ki sankhya.
  • Ek filesystem file ke data blocks kab free kar sakta hai? ::: Jab aur koi bhi process file ko abhi open na rakh raha ho.
  • Kya cheez ek graph ko tree banati hai? ::: Root ke alawa har node ka exactly ek parent hota hai, aur koi cycles nahi hote — isliye har file tak ek unique path hota hai.
  • DAG ko define karne wali teen properties kya hain? ::: Directed edges, koi cycles nahi (acyclic), lekin ek node mein ek se zyada incoming edges ho sakte hain.
  • Kaunsi single event tree ko DAG mein badal deti hai? ::: Do alag names (paths) same inode ki taraf point karna, use ek se zyada incoming arrow dena.
  • Directory cycles kyun forbid honi chahiye? ::: Taaki traversal terminate ho aur "reachable ⇒ link count > 0" well-defined rahe.