File Attributes - aryanjoshi0823/5143-Operating-System GitHub Wiki
File attributes are metadata associated with a file in a file system. These attributes provide information about the file's properties, such as permissions, size, timestamps, and access rights.
Key File Attributes
-
Name
- The identifier of the file (e.g.,
example.txt
). - Unique within its directory.
- The identifier of the file (e.g.,
-
Type
- Indicates the nature of the file:
- Regular file (text, binary, executable, etc.)
- Directory
- Special file (e.g., device files in Unix/Linux)
- Indicates the nature of the file:
-
Location
- The physical or logical address of the file on the storage device.
- Managed by the file system.
-
Size
- The total amount of space (in bytes) occupied by the file.
- May include file contents and metadata.
-
Protection (Permissions)
- Specifies who can read, write, or execute the file.
- Commonly represented in Unix/Linux as:
rwx rwx rwx
- Owner permissions (first set of
rwx
) - Group permissions (second set)
- Others' permissions (third set)
- Owner permissions (first set of
-
Ownership: Indicates the user (owner) and group associated with the file.
-
Timestamps:
- Provide information about key events related to the file:
- Creation Time: When the file was created.
- Modification Time: Last time the file's content was changed.
- Access Time: Last time the file was accessed (read or written).
- Provide information about key events related to the file:
-
File Status (Flags): Indicates special statuses such as: Hidden, Read-only, Archived, System (in Windows)
-
Links:
- Number of references (hard links) pointing to the file.
- Used to determine whether the file is still accessible after deletion.
-
File Identifier (Inode Number): A unique identifier for the file within the file system (used in Unix/Linux).
-
File Content Attributes: Compression status, Encryption status
-
System Attributes (OS-Specific):
- Immutable flag (Linux): File cannot be modified.
- No backup flag (MacOS): Excludes the file from system backups.
Some Other Attributes May Include:
Attributes related to flags. These Flags control or enable some specific property:
- Read-only flag: 0 for read/write; 1 for read-only.
- Hidden flag: 0 for normal; 1 for do not display in listings of all files.
- System flag: 0 for normal files; 1 for system files.
- Archive flag: 0 for has been backed up; 1 for needs to be backed up.
- ASCII/binary flag: 0 for ASCII file; 1 for binary file.
- Random access flag: 0 for sequential access only; 1 for random access.
- Temporary flag: 0 for normal; 1 for deleted file on process exit.
- Lock flags: 0 for unlocked; nonzero for locked.
Attribute related to keys. These are present in files which can be accessed using key:
- Record length: Number of bytes in a record.
- Key position: Offset of the key within each record.
- Key length: Number of bytes in the key field.