summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/aws-c-common/source/linux/system_info.c
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2025-05-12 15:51:24 +0300
committerthegeorg <[email protected]>2025-05-12 16:06:27 +0300
commitd629bb70c8773d2c0c43f5088ddbb5a86d8c37ea (patch)
tree4f678e0d65ad08c800db21c657d3b0f71fafed06 /contrib/restricted/aws/aws-c-common/source/linux/system_info.c
parent92c4b696d7a1c03d54e13aff7a7c20a078d90dd7 (diff)
Update contrib/restricted/aws libraries to nixpkgs 24.05
commit_hash:f8083acb039e6005e820cdee77b84e0a6b6c6d6d
Diffstat (limited to 'contrib/restricted/aws/aws-c-common/source/linux/system_info.c')
-rw-r--r--contrib/restricted/aws/aws-c-common/source/linux/system_info.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/restricted/aws/aws-c-common/source/linux/system_info.c b/contrib/restricted/aws/aws-c-common/source/linux/system_info.c
new file mode 100644
index 00000000000..2d9c5a120db
--- /dev/null
+++ b/contrib/restricted/aws/aws-c-common/source/linux/system_info.c
@@ -0,0 +1,24 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include <aws/common/file.h>
+#include <aws/common/private/system_info_priv.h>
+
+int aws_system_environment_load_platform_impl(struct aws_system_environment *env) {
+ /* provide size_hint when reading "special files", since some platforms mis-report these files' size as 4KB */
+ aws_byte_buf_init_from_file_with_size_hint(
+ &env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/sys_vendor", 32 /*size_hint*/);
+
+ /* whether this one works depends on if this is a sysfs filesystem. If it fails, it will just be empty
+ * and these APIs are a best effort at the moment. We can add fallbacks as the loaders get more complicated. */
+ aws_byte_buf_init_from_file_with_size_hint(
+ &env->product_name, env->allocator, "/sys/devices/virtual/dmi/id/product_name", 32 /*size_hint*/);
+
+ return AWS_OP_SUCCESS;
+}
+
+void aws_system_environment_destroy_platform_impl(struct aws_system_environment *env) {
+ aws_byte_buf_clean_up(&env->virtualization_vendor);
+ aws_byte_buf_clean_up(&env->product_name);
+}