Debian Codegraph @

crt/aws-c-common/source/linux/system_info.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5 #include <aws/common/file.h>
6 #include <aws/common/private/system_info_priv.h>
7
8 int aws_system_environment_load_platform_impl(struct aws_system_environment *env) {
9 /* provide size_hint when reading "special files", since some platforms mis-report these files' size as 4KB */
10 aws_byte_buf_init_from_file_with_size_hint(
11 &env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/sys_vendor", 32 /*size_hint*/);
12
13 /* whether this one works depends on if this is a sysfs filesystem. If it fails, it will just be empty
14 * and these APIs are a best effort at the moment. We can add fallbacks as the loaders get more complicated. */
15 aws_byte_buf_init_from_file_with_size_hint(
16 &env->product_name, env->allocator, "/sys/devices/virtual/dmi/id/product_name", 32 /*size_hint*/);
17
18 return AWS_OP_SUCCESS;
19 }
20
21 void aws_system_environment_destroy_platform_impl(struct aws_system_environment *env) {
22 aws_byte_buf_clean_up(&env->virtualization_vendor);
23 aws_byte_buf_clean_up(&env->product_name);
24 }