Add a nooverwrite flag to struct hw_impl. When set, vendor and model
name already provided by the kernel in /proc/cpuinfo are preserved
rather than being overwritten by the hardcoded lookup tables. The
tables serve as a fallback when the kernel does not provide the
information.
This approach keeps all implementer entries in the table, which is
also required for "lscpu --arm-id" to list all known vendors and
part IDs.
Addresses: https://github.com/util-linux/util-linux/pull/4362
Signed-off-by: Karel Zak <kzak@redhat.com>
{ -1, "unknown" },
};
+#define HW_IMPL_NOOVERWRITE true /* don't overwrite vendor and model from /proc/cpuinfo */
+
struct hw_impl {
const int id;
const struct id_part *parts;
const char *name;
+ const bool nooverwrite;
};
static const struct hw_impl hw_implementer[] = {
return 0;
/* decode vendor */
- free(ct->vendor);
- ct->vendor = xstrdup(hw->name);
+ if (!ct->vendor || !hw->nooverwrite) {
+ free(ct->vendor);
+ ct->vendor = xstrdup(hw->name);
+ }
/* decode model */
part = parse_model_id(ct);
for (j = 0; hw->parts[j].id != -1; j++) {
if (hw->parts[j].id == part) {
- free(ct->modelname);
- ct->modelname = xstrdup(hw->parts[j].name);
+ if (!ct->modelname || !hw->nooverwrite) {
+ free(ct->modelname);
+ ct->modelname = xstrdup(hw->parts[j].name);
+ }
break;
}
}