From 4dc4fc10e7a354027bac683a91df501eed486f4e Mon Sep 17 00:00:00 2001 From: "Jonathan M. Henson" Date: Thu, 5 Oct 2023 15:22:11 -0700 Subject: [PATCH] Add product name to the mix. --- bin/system_info/print_system_info.c | 2 ++ include/aws/common/private/system_info_priv.h | 2 ++ include/aws/common/system_info.h | 3 +++ source/linux/system_info.c | 4 ++++ source/system_info.c | 7 +++++++ 5 files changed, 18 insertions(+) diff --git a/bin/system_info/print_system_info.c b/bin/system_info/print_system_info.c index e01888627..722b7122c 100644 --- a/bin/system_info/print_system_info.c +++ b/bin/system_info/print_system_info.c @@ -23,6 +23,8 @@ int main(void) { struct aws_byte_cursor virtualization_vendor = aws_system_environment_get_virtualization_vendor(env); fprintf(stdout, " 'virtualization vendor': '" PRInSTR "'\n", (int)virtualization_vendor.len, virtualization_vendor.ptr); + struct aws_byte_cursor product_name = aws_system_environment_get_virtualization_product_name(env); + fprintf(stdout, " 'product name': '" PRInSTR "'\n", (int)product_name.len, product_name.ptr); fprintf(stdout, " 'number of processors': '%lu'\n", (unsigned long)aws_system_environment_get_processor_count(env)); size_t numa_nodes = aws_system_environment_get_cpu_group_count(env); diff --git a/include/aws/common/private/system_info_priv.h b/include/aws/common/private/system_info_priv.h index 85dbdd902..dbfd2d782 100644 --- a/include/aws/common/private/system_info_priv.h +++ b/include/aws/common/private/system_info_priv.h @@ -12,6 +12,7 @@ struct aws_system_environment { struct aws_allocator *allocator; struct aws_byte_buf virtualization_vendor; + struct aws_byte_buf product_name; enum aws_platform_os os; size_t cpu_count; size_t cpu_group_count; @@ -23,5 +24,6 @@ void aws_system_environment_destroy_platform_impl(struct aws_system_environment void aws_system_environment_load_virtualization_vendor_impl(struct aws_system_environment *env); +void aws_system_environment_load_virtualization_product_name_impl(struct aws_system_environment *env); #endif /* AWS_COMMON_SYSTEM_INFO_PRIV_H */ diff --git a/include/aws/common/system_info.h b/include/aws/common/system_info.h index 1476e0f44..65a93515c 100644 --- a/include/aws/common/system_info.h +++ b/include/aws/common/system_info.h @@ -35,6 +35,9 @@ void aws_system_environment_destroy(struct aws_system_environment *env); AWS_COMMON_API struct aws_byte_cursor aws_system_environment_get_virtualization_vendor(struct aws_system_environment *env); +AWS_COMMON_API +struct aws_byte_cursor aws_system_environment_get_virtualization_product_name(struct aws_system_environment *env); + AWS_COMMON_API size_t aws_system_environment_get_processor_count(struct aws_system_environment *env); diff --git a/source/linux/system_info.c b/source/linux/system_info.c index a48bb15ad..211e93f35 100644 --- a/source/linux/system_info.c +++ b/source/linux/system_info.c @@ -15,3 +15,7 @@ void aws_system_environment_destroy_platform_impl(struct aws_system_environment void aws_system_environment_load_virtualization_vendor_impl(struct aws_system_environment *env) { aws_byte_buf_init_from_file(&env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/sys_vendor"); } + +void aws_system_environment_load_virtualization_product_name_impl(struct aws_system_environment *env) { + aws_byte_buf_init_from_file(&env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/product_name"); +} diff --git a/source/system_info.c b/source/system_info.c index 02f5cdc5a..a2247a56f 100644 --- a/source/system_info.c +++ b/source/system_info.c @@ -13,6 +13,8 @@ struct aws_system_environment *aws_system_environment_load(struct aws_allocator } aws_system_environment_load_virtualization_vendor_impl(env); + aws_system_environment_load_virtualization_product_name_impl(env); + env->os = aws_get_platform_build_os(); env->cpu_count = aws_system_info_processor_count(); env->cpu_group_count = aws_get_cpu_group_count(); @@ -37,6 +39,11 @@ struct aws_byte_cursor aws_system_environment_get_virtualization_vendor(struct a return aws_byte_cursor_trim_pred(&vendor_string, aws_char_is_space); } +struct aws_byte_cursor aws_system_environment_get_virtualization_product_name(struct aws_system_environment *env) { + struct aws_byte_cursor product_name_str = aws_byte_cursor_from_buf(&env->product_name); + return aws_byte_cursor_trim_pred(&product_name_str, aws_char_is_space); +} + size_t aws_system_environment_get_processor_count(struct aws_system_environment *env) { return env->cpu_count; }