Report actual directory creation separately from durability errors

This commit is contained in:
evgeny committed 2026-10-06 11:25:18 +02:00
1 parent 69f04dec87
commit e76dc6cb82
2 files changed
+11 -4

No files matched your search

+9 -3
View File
@@ -148,10 +148,12 @@ int mf_disk_stat(struct mf_disk_root* root, const char* path, struct mf_disk_inf
int mf_disk_info(int fd, struct mf_disk_info* info) { return disk_handle_info((HANDLE)_get_osfhandle(fd), info); }
int mf_disk_mkdir(struct mf_disk_root* root, const char* path) {
int mf_disk_mkdir(struct mf_disk_root* root, const char* path, int* created) {
if (created) *created = 0;
struct disk_parent p; int rc = disk_parent_open(root, path, &p);
if (rc) return rc;
if (!CreateDirectoryW(p.path, NULL)) rc = disk_win_error("mkdir");
else if (created) *created = 1;
disk_parent_close(&p); return rc;
}
@@ -291,11 +293,15 @@ int mf_disk_info(int fd, struct mf_disk_info* info) {
struct stat st;
return fstat(fd, &st) ? disk_error("fstat", NULL) : disk_posix_info(&st, info);
}
int mf_disk_mkdir(struct mf_disk_root* root, const char* path) {
int mf_disk_mkdir(struct mf_disk_root* root, const char* path, int* created) {
if (created) *created = 0;
struct disk_parent p; int rc = disk_parent_open(root, path, &p);
if (rc) return rc;
if (mkdirat(p.fd, p.leaf, 0700)) rc = disk_error("mkdir", path);
else if (fsync(p.fd)) rc = disk_error("sync mkdir", path);
else {
if (created) *created = 1;
if (fsync(p.fd)) rc = disk_error("sync mkdir", path);
}
close(p.fd); return rc;
}
int mf_disk_remove(struct mf_disk_root* root, const char* path, int directory) {
+2 -1
View File
@@ -21,7 +21,8 @@ void mf_disk_root_close(struct mf_disk_root* root);
int mf_disk_open(struct mf_disk_root* root, const char* path, int create, int writable, int* fd);
int mf_disk_stat(struct mf_disk_root* root, const char* path, struct mf_disk_info* info);
int mf_disk_info(int fd, struct mf_disk_info* info);
int mf_disk_mkdir(struct mf_disk_root* root, const char* path);
/* created, если не NULL, показывает факт создания даже при последующей ошибке sync. */
int mf_disk_mkdir(struct mf_disk_root* root, const char* path, int* created);
int mf_disk_remove(struct mf_disk_root* root, const char* path, int directory);
int mf_disk_rename(struct mf_disk_root* root, const char* from, const char* to);
typedef int (*mf_disk_entry_fn)(void* arg, const char* name, const struct mf_disk_info* info);