Read-Only Files

In Windows NT, there is a privilege level that allows a directory or file to be deleted even if it has the read-only file attribute set. This privilege level is called Full Control privilege. Full Control privilege, like other file system security features in Windows NT, applies to the NT file system (NTFS). Based on the behavior of Windows NT CreateFile and other file-manipulation functions, it appears that the Full Control privilege level in Windows NT is the default privilege level for FAT and other file systems as well. The Windows NT implementation of file access privileges differs from the OS/2 implementation:

┌─────────────────────────┬─────────────────────────┬─────────────────────────┐
│FAT                      │Never Full Control       │Always Full Control      │
│                         │privilege                │privilege                │
├─────────────────────────┼─────────────────────────┼─────────────────────────┤
│HPFS                     │Never Full Control       │Always Full Control      │
│                         │privilege                │privilege                │
├─────────────────────────┼─────────────────────────┼─────────────────────────┤
│NTFS                     │                         │Optional Full Control    │
│                         │                         │privilege                │
└─────────────────────────┴─────────────────────────┴─────────────────────────┘

In OS/2, the OS/2 behavior is preserved instead of emulating the Windows NT behavior with regards to the handling of read-only files. For example, CreateFile can be passed a parameter called CREATE_ALWAYS. If the file to be created has the same name as a file that already exists, the CREATE_ALWAYS parameter causes the existing file to be overwritten. In Windows NT, if the CREATE_ALWAYS parameter is used, CreateFile deletes the existing file, regardless of its attributes, and regardless of the access mode set by fdwAccess (another parameter that tells CreateFile to open the file as writable or read-only). In OS/2, CreateFile fails if CREATE_ALWAYS is used and the access mode is set to read-only. In OS/2, CreateFile also fails if any attempt is made to open an existing file with write access when the file's read-only attribute is set. The OS/2 implementation of other file-manipulation functions, including DeleteFile and WriteFile, similarly respects file attributes.

Programmers using the OS/2 implementation should be aware that a file's attributes must be set appropriately before the file can be deleted or opened with write access. Furthermore, the implementation requires that a file must be opened with write access before data can be written to the file.


[Back: Pattern Brushes]
[Next: Registry]