Skip to content

Commit

Permalink
Use new aws_byte_buf_init_from_file_with_size_hint() function, so don…
Browse files Browse the repository at this point in the history
…'t waste 4KB on these short strings.
  • Loading branch information
graebm committed Oct 13, 2023
1 parent 12a9bc8 commit 93672d5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/linux/system_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
#include <aws/common/private/system_info_priv.h>

int aws_system_environment_load_platform_impl(struct aws_system_environment *env) {
aws_byte_buf_init_from_file(&env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/sys_vendor");
/* 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(&env->product_name, env->allocator, "/sys/devices/virtual/dmi/id/product_name");
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;
}
Expand Down

0 comments on commit 93672d5

Please sign in to comment.