Make .unrecoverable a persistent one-way recovery quarantine
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2026-08-29 21:25:49 +02:00
parent f3bed11cef
commit 9be2cbaac0
3 changed files with 233 additions and 140 deletions

View file

@ -36,16 +36,25 @@ struct snapraid_handle {
};
/**
* Create a file.
* The file is created if missing, and opened with write access.
* If the file is created, the handle->created is set.
* If a previous .unrecoverable file is opened, the handle->is_unrecoverable is set.
* Create or reopen a recovery file.
* A new recovery attempt always uses the normal filename, even if a previous .unrecoverable file exists.
* If the file is already marked FILE_IS_DAMAGED in the current run, its .unrecoverable file is reopened instead.
* If the normal file is created, the handle->created is set.
* If the .unrecoverable file is opened, the handle->is_unrecoverable is set.
* The initial size of the file is stored in the file->st struct.
* If the file cannot be opened for write access, it's opened with read-only access.
* The read-only access works only if the file has already the correct size and doesn't need to be modified.
*/
int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, int mode);
/**
* Move an opened file to its persistent .unrecoverable name.
* A previous .unrecoverable from an older recovery attempt is replaced.
* If already quarantined in the current run, do nothing.
* On error, log the failure and return -1 with errno set.
*/
int handle_quarantine(struct snapraid_handle* handle, struct snapraid_file* file, int mode);
/**
* Truncate a file if required.
*/
@ -86,4 +95,3 @@ int handle_utime(struct snapraid_handle* handle);
struct snapraid_handle* handle_mapping(struct snapraid_state* state, unsigned* diskmax);
#endif