5.8 Special Attributes
KACS keeps two attributes for every file on a managed mount:
- Read-only. A read-only regular file cannot be opened for writing or deleted, by anyone, its owner included, until the flag is cleared.
- Created At, a settable creation date. It differs from the filesystem's
birth time, which
statxreports and nobody can set: Created At is the date a person sees, which a copy or a restore can carry across.
int ;
int ;
int ;
int ;
struct kacs_sattr holds both:
| Field | Meaning |
|---|---|
version | KACS_SATTR_VERSION. |
valid | On a write, which fields to change: KACS_SATTR_VALID_ATTRIBUTES, KACS_SATTR_VALID_CREATED_AT. A read sets both. |
attributes | KACS_SATTR_READONLY. |
flags | KACS_SATTR_CREATED_AT_SET if Created At is set. |
created_at_sec, created_at_nsec | Created At, since the Unix epoch. |
A read always fills the struct: a file that has never had either attribute
set reads as not read-only with no Created At. A write changes only the fields
its valid mask names, so two programs changing different attributes cannot
undo each other. The struct means the same in both directions: a write with
KACS_SATTR_VALID_CREATED_AT sets Created At if flags carries
KACS_SATTR_CREATED_AT_SET, and unsets it if not. A struct read from one file
can therefore be written to another to copy both attributes exactly.
Reading needs FILE_READ_ATTRIBUTES and writing FILE_WRITE_ATTRIBUTES:
through the descriptor's grant for the fd forms, or a live check for the path
forms. at_flags accepts AT_SYMLINK_NOFOLLOW.
/* Make a file read-only, leaving its Created At alone. */
struct kacs_sattr a = ;
if
5.8.1 The creation date #
int ;
int ;
A file's creation date is its Created At while that is set, and its birth time
otherwise. These calls apply that rule, so a program showing or copying a
creation date does not have to. They fail with ENODATA if the file has
neither, as on a filesystem that records no birth time.
A tool that copies files and wants the copy to keep its creation date should
read it with peios_file_creation_time and set it on the copy as Created At.
5.8.2 See also #
- Special Attributes — the kernel's rules, including what read-only refuses.