Compare commits

...

8 commits

Author SHA1 Message Date
Andrea Mazzoleni
836480951e Fix leak on termination on Windows
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-win (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-05-20 20:00:56 +02:00
Andrea Mazzoleni
b50332db54 Fix a double close in Windows 2026-05-20 20:00:38 +02:00
Andrea Mazzoleni
6bfbc6e3b2 Fix potential division by zero with minuscule devices 2026-05-20 19:22:50 +02:00
Andrea Mazzoleni
00e50bd965 Fix wrong sizeof 2026-05-20 00:27:12 +02:00
Andrea Mazzoleni
10c327a558 Fixed syncing of the directory of the content file 2026-05-20 00:27:12 +02:00
Andrea Mazzoleni
4d09bffb94 Support the root filesystem as data and parity disk 2026-05-20 00:21:10 +02:00
Andrea Mazzoleni
b428cd80cc Verify the number of splits 2026-05-20 00:17:46 +02:00
Andrea Mazzoleni
9d7dcdd479 If skip_access is enabled, don't call fsinfo on the device 2026-05-20 00:17:18 +02:00
3 changed files with 33 additions and 19 deletions

View file

@ -2989,14 +2989,12 @@ static int devup(uint64_t device, const char* name, const char* wfile)
if (!CloseHandle(h)) {
DWORD error = GetLastError();
CloseHandle(h);
VirtualFree(buffer, 0, MEM_RELEASE);
windows_errno(error);
log_tag("device:%s:%s:error:%lu\n", file, name, error);
return -1;
}
CloseHandle(h);
VirtualFree(buffer, 0, MEM_RELEASE);
log_tag("attr:%s:%s:power:up\n", file, name);
@ -3346,17 +3344,21 @@ int windows_key_create(windows_key_t* key, void (*destructor)(void*))
return 0;
}
int windows_key_delete(windows_key_t key)
int windows_key_delete(windows_key_t void_key)
{
struct windows_key_context* context = key;
struct windows_key_context* key = void_key;
/* remove from the list of destructors */
if (context->func)
tommy_list_remove_existing(&windows_key_list, &context->node);
/* use the destructor for the local variable and remove from the list of destructors */
if (key->func) {
void* value = windows_getspecific(key);
if (value)
key->func(value);
tommy_list_remove_existing(&windows_key_list, &key->node);
}
TlsFree(context->key);
TlsFree(key->key);
free(context);
free(key);
return 0;
}

View file

@ -310,9 +310,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
}
/* skip data disks that are not accessible */
if (disk->skip_access)
continue;
if (!state->opt.skip_parity_access) {
for (l = 0; l < state->level; ++l) {
@ -724,10 +722,9 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
pathimport(device, sizeof(device), split_map[s]);
slash = strrchr(device, '/');
if (slash)
*slash = 0;
slash[1] = 0;
else
pathcpy(device, sizeof(device), ".");
if (stat(device, &st) == 0) {
dev = st.st_dev;
@ -877,7 +874,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
pathimport(device, sizeof(device), buffer);
slash = strrchr(device, '/');
if (slash)
*(slash + 1) = 0;
slash[1] = 0;
else
pathcpy(device, sizeof(device), ".");
if (stat(device, &st) == 0) {
@ -1802,6 +1799,9 @@ void state_refresh(struct snapraid_state* state)
/* LCOV_EXCL_STOP */
}
if (disk->skip_access)
continue;
ret = fsinfo(disk->dir, 0, 0, &total_space, &free_space, disk->fstype, sizeof(disk->fstype), disk->fslabel, sizeof(disk->fslabel));
if (ret != 0) {
/* LCOV_EXCL_START */
@ -1828,6 +1828,9 @@ void state_refresh(struct snapraid_state* state)
state->parity[l].total_blocks = 0;
state->parity[l].free_blocks = 0;
if (state->parity[l].skip_access)
continue;
for (s = 0; s < state->parity[l].split_mac; ++s) {
struct snapraid_split* split = &state->parity[l].split_map[s];
uint64_t total_space;
@ -3084,6 +3087,14 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
if (v_split_mac > SPLIT_MAX) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal(ECONTENT, "Too many splits '%u' in the content file!\n", v_split_mac);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (v_level >= LEV_MAX) {
/* LCOV_EXCL_START */
decoding_error(path, f);
@ -4537,9 +4548,9 @@ static void state_rename_content(struct snapraid_state* state)
pathcpy(dir, sizeof(dir), content->content);
slash = strrchr(tmp, '/');
slash = strrchr(dir, '/');
if (slash)
*slash = 0;
slash[1] = 0;
else
pathcpy(dir, sizeof(dir), ".");
@ -5244,7 +5255,7 @@ int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_o
str_cpu[0] = 0;
}
if (out_temperature) {
snprintf(str_temp, sizeof(str_eta), "%u", out_temperature);
snprintf(str_temp, sizeof(str_temp), "%u", out_temperature);
} else {
str_temp[0] = 0;
}

View file

@ -2101,7 +2101,8 @@ static int devup(dev_t device, const char* name)
}
/* select a random offset */
offset = (random_u64() % (size / 4096)) * 4096;
uint64_t blocks = size / 4096;
offset = blocks > 0 ? (random_u64() % blocks) * 4096 : 0;
#if HAVE_POSIX_FADVISE
/* clear cache */