/* sc_copy.h — состояние безопасного однофайлового copy-job PoC. */ #ifndef SC_COPY_H #define SC_COPY_H #include #define SC_COPY_PATH_CAPACITY 256u #define SC_COPY_CHUNK_SIZE 4096u #define SC_COPY_IDLE 0u #define SC_COPY_RUNNING 1u #define SC_COPY_DONE 2u #define SC_COPY_CANCELLED 3u #define SC_COPY_ERROR 4u #define SC_COPY_STEP_ERROR (-1) #define SC_COPY_STEP_DONE 0 #define SC_COPY_STEP_MORE 1 /* нужен ещё шаг; done==total означает pre-commit */ typedef struct { char source_path[SC_COPY_PATH_CAPACITY]; char target_path[SC_COPY_PATH_CAPACITY]; char temp_path[SC_COPY_PATH_CAPACITY]; uint32_t total; uint32_t done; uint16_t source_date; uint16_t source_time; int source_fd; int temp_fd; int error; uint8_t page; uint8_t state; uint8_t temp_exists; uint8_t source_attr; uint8_t existing_attr; uint8_t preserve_metadata; uint8_t replace_existing; uint8_t committed; } ScCopyJob; int sc_copy_begin(ScCopyJob *job, const char *source_dir, const char *target_dir, const char *name, uint32_t size, uint8_t page) __banked; /* source_name и target_name могут различаться; replace включает backup/rollback. */ int sc_copy_begin_policy(ScCopyJob *job, const char *source_dir, const char *target_dir, const char *source_name, const char *target_name, uint32_t size, uint8_t page, uint8_t replace) __banked; /* Для tree-job: CWD уже равен source-dir, а target_path подготовлен целиком. */ int sc_copy_begin_prepared(ScCopyJob *job, const char *name, uint32_t size, uint8_t page) __banked; int sc_copy_begin_prepared_policy(ScCopyJob *job, const char *name, uint32_t size, uint8_t page, uint8_t replace) __banked; int sc_copy_step(ScCopyJob *job) __banked; void sc_copy_cancel(ScCopyJob *job) __banked; #endif