Files

From COMP15212 Wiki
Revision as of 13:25, 9 May 2024 by gravatar U05730dg [userPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
On path: Filing 1: Filing System • 2: File Systems • 3: Files • 4: File Attributes • 5: File Types • 6: File Permissions • 7: File Access • 9: Filing System Implementation • 10: I-nodes • 11: Links • 12: File Descriptor
On path: IPC 1: Processes • 2: Interprocess Communication • 3: Shared Memory • 4: Files • 5: Unix Signals • 6: Pipes • 7: Sockets • 8: Synchronisation • 9: Synchronisation Barrier • 10: Atomicity • 11: Mutual exclusion • 12: Signal and Wait
Depends on Filing System

A file is the basic storage unit in a filing system. They are large but slow to access (relative to main memory structures), possibly accessible by many users and processes, and permanent.

Access to a file requires the appropriate sequence of system calls and is typically subject to access permissions.

Each file comprises a standard set of file attributes (e.g. the file size) and a variable number of blocks/“clusters” which contain the data. It is normal (but not compulsory) to keep only one type of data in each file.

Files

The data may be structured into records, either by the filing system itself or through user preference. Most modern file systems leave any structuring to the user and regard the body of the file as a large array of (usually) bytes.

Historically, some files may have been only serially accessible: start at the beginning and read as a stream. Although this is still possible – and, sometimes, convenient – it is usually possible to move the point of reading/writing to an arbitrary position. However this can still require a sequence of system calls.

Some operating systems may allow the virtual mapping of a file into the address space for added convenience.

When reading (or writing) a file there is an associated position; this is not part of the file though but is maintained by the access process. It is possible to have multiple processes reading the same file at different places simultaneously.

A file will typically have some type part of which may be maintained by the file system and some from the user’s knowledge. Each file has some unique identifier but the user will usually have a human-readable name by which it can be identified. This “file name” may or may not be part of the file’s attributes. For example, in a Unix filing system the file name is separate from the file and one file can have multiple different names.

File links


Also refer to: Operating System Concepts, 10th Edition: Chapter 13.1, pages 529-539