- LPU MCA Semester 1
- CAP366
- Unit 8
CAP366 · Unit 8: Protection and disk management
File access methods and protection
10 practice questions · in the ETE syllabus
Key points
- Sequential, direct and indexed access
- rwx = 4, 2, 1 for owner, group, others
- Directory execute means search/traverse
- umask clears bits from 666 (files) or 777
Access methods describe how records of a file are read. Sequential access processes records in order; direct (relative) access jumps to any record number, so record n of size r starts at byte n x r (block = n x r / block size). Indexed access uses an index to locate records.
Protection controls who may do what. UNIX gives each file three permission triples for the owner, group and others, each with read (4), write (2) and execute (1). The string rwxr-xr-- is octal 754: owner 7, group 5, others 4. The first matching class decides: if the user is the owner, owner bits apply; otherwise group; otherwise others. On a directory, read lets you list names, write lets you create or delete entries, and execute (search) lets you pass through the directory to reach entries by name. Opening /a/b/c.txt needs search permission on every directory in the path.
The umask removes bits from the default mode of new files: 666 with umask 022 gives 644.
Worked example: record 37 of 128 bytes with 512-byte blocks is at byte 4736, so block 9, offset 128.
Exam trap: execute on a directory does not mean running it; it means searching it.
Try two questions
A direct-access file has 128-byte records and 512-byte blocks. Where is record numbered 37 (counting from 0)?
- block 9, byte 0
- block 8, byte 384
- block 10, byte 128
- block 9, byte 128
Show the answer
D. 37 * 128 = 4736 bytes from the start; 4736 / 512 = 9 remainder 128.
Why not A: Byte 0 would be record 36.
Why not B: Block 8 holds records 32 to 35.
Why not C: Block 10 starts at record 40.
A UNIX file has the mode string rwxr-xr--. What is its octal permission value?
- 755
- 754
- 764
- 654
Show the answer
B. Owner rwx = 7, group r-x = 5, others r-- = 4, giving 754.
Why not A: 755 gives others read and execute.
Why not C: 764 gives the group write.
Why not D: 654 gives the owner no execute.