mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-25 18:40:19 -04:00
Add best-effort Linux disk instance mappings using boot_id and diskseq
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
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:
parent
7275872c80
commit
4054832c7e
2 changed files with 34 additions and 0 deletions
3
HISTORY
3
HISTORY
|
|
@ -3,6 +3,9 @@ SnapRAID HISTORY
|
|||
|
||||
15.1 2026/10
|
||||
============
|
||||
* Add synthetic device IDs on Linux, allowing SnapRAID Daemon to
|
||||
preserve history for devices without unique hardware IDs while
|
||||
they remain connected within the same boot.
|
||||
* Fix a failed internal inconsistency check when '--gui-touch-before'
|
||||
is used before the first sync when no content file exists yet.
|
||||
Also ensure that commands that can save the content file ('touch',
|
||||
|
|
|
|||
|
|
@ -4447,6 +4447,7 @@ int devmap(void)
|
|||
{
|
||||
#if HAVE_LINUX_DEVICE
|
||||
char path[PATH_MAX];
|
||||
char boot_id[64];
|
||||
DIR* d = opendir("/sys/block");
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -4454,6 +4455,22 @@ int devmap(void)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* optional boot identity: failure must not affect hardware mappings */
|
||||
if (sysattr("/proc/sys/kernel/random/boot_id", boot_id, sizeof(boot_id)) != 0 || strlen(boot_id) != 36) {
|
||||
boot_id[0] = 0;
|
||||
} else {
|
||||
for (unsigned i = 0; i < 36; ++i) {
|
||||
if (i == 8 || i == 13 || i == 18 || i == 23) {
|
||||
if (boot_id[i] == '-')
|
||||
continue;
|
||||
} else if (hexval(boot_id[i]) >= 0) {
|
||||
continue;
|
||||
}
|
||||
boot_id[0] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct dirent* dd;
|
||||
while (1) {
|
||||
char buf[256];
|
||||
|
|
@ -4517,6 +4534,20 @@ int devmap(void)
|
|||
if (sysattr(path, buf, sizeof(buf)) == 0 && buf[0] != 0) {
|
||||
log_tag("map:/dev/%s:%s\n", dd->d_name, esc_tag(buf));
|
||||
}
|
||||
|
||||
/*
|
||||
* This identifies the kernel device instance within one boot, not
|
||||
* persistent hardware across reconnections. Missing attributes are optional.
|
||||
*/
|
||||
if (boot_id[0] != 0) {
|
||||
pathprint(path, sizeof(path), "/sys/block/%s/diskseq", dd->d_name);
|
||||
if (sysattr(path, buf, sizeof(buf)) == 0) {
|
||||
char* end;
|
||||
unsigned long long diskseq = strtonll(buf, &end, 10);
|
||||
if (buf[0] >= '0' && buf[0] <= '9' && diskseq != 0 && end != buf && *end == 0)
|
||||
log_tag("map:/dev/%s:linux-diskseq.%s.%llu\n", esc_tag(dd->d_name), esc_tag(boot_id), diskseq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue