GATE / CS ARCHIVE

GATE CSE 1996 / QUESTION 23(a)

Directory capacity and file count

Operating Systems · File Systems · Full GATE CSE 1996 paper

GATE 1996, Q23(a) Descriptive
Report issue

File Systems

Question 23(a), GATE 1996: A one-level file system uses 4K-byte disk blocks. Disk block 0 contains a FAT with one 8-bit next-data-block address entry per data block. Disk block 1 is a directory with one 32-bit entry per file. Disk blocks 2,3,... are data blocks 1,2,... . Take K=1024. Find the maximum possible number of files.
Question 23(a), GATE 1996: A one-level file system uses 4K-byte disk blocks. Disk block 0 contains a FAT with one 8-bit next-data-block address entry per data block. Disk block 1 is a directory with one 32-bit entry per file. Disk blocks 2,3,... are data blocks 1,2,... . Take K=1024. Find the maximum possible number of files.
Tap to enlarge
Answer & solution

Answer: 1024 directory entries/files when empty files are permitted; nonempty-file capacity is additionally data-block limited. (no official key was published)

The directory occupies one block, so its storage is 4×1024=4096 bytes. A directory entry uses 32 bits=4 bytes. Hence it contains 4096/4=1024 entries and can name at most 1024 files. This is a directory-capacity bound; the FAT entry count must not be substituted into this division.

Attaining that many named files does not require one data block for every file if zero-length files are allowed. Empty files can occupy directory entries without owning data blocks, so the customary directory-capacity interpretation gives 1024 files. If instead the question requires every file to be nonempty, the result also depends on the number of addressable data blocks and the unspecified pointer conventions. Under a uniform 8-bit data-block address convention with all 256 patterns usable, at most 256 one-block nonempty files fit, and reserved FAT markers reduce that number.

There is a related source-design omission: a 4096-byte FAT can physically hold 4096 one-byte entries, but one-byte next pointers cannot name all 4096 positions under a uniform address scheme. Thus table capacity, pointer addressability, and directory capacity are three distinct quantities. The problem does not specify empty-file policy, reserved values, or actual disk capacity; 1024 is the unambiguous maximum directory entry count, not a proof that 1024 nonempty files can simultaneously occupy the disk.

Original paper, page 10