MCPcopy Create free account
hub / github.com/coreboot/coreboot / new_sysfs_path

Function new_sysfs_path

util/cbmem/sysfs_drv.c:56–73  ·  view source on GitHub ↗

* Create new path for CBMEM entry of a requested type. free() path_out after use. * * @param id CBMEM_ID_* value. * @param t path type. * @param path_out output pointer to created path. */

Source from the content-addressed store, hash-verified

54 * @param path_out output pointer to created path.
55 */
56static void new_sysfs_path(uint32_t id, enum cbmem_sysfs_path_type t, char *path_out, size_t path_out_max_size)
57{
58 const char *const type2str[] = {
59 [CBMEM_SYSFS_PATH_BASE] = "",
60 [CBMEM_SYSFS_PATH_ADDRESS] = "/address",
61 [CBMEM_SYSFS_PATH_MEM] = "/mem",
62 [CBMEM_SYSFS_PATH_SIZE] = "/size"
63 };
64
65 if (t >= ARRAY_SIZE(type2str))
66 die("Incorrect path type requested: %d\n", t);
67
68 if (snprintf(path_out, path_out_max_size, CBMEM_SYSFS_ENTRY_DIR_PATH_PRI_FMT "%s", id,
69 type2str[t]) <= 0)
70 die("Unable to create sysfs path string for coreboot table: %#" PRIx32
71 ". Path type: %d. Error: %s\n",
72 id, t, strerror(errno));
73}
74
75bool cbmem_sysfs_init(void)
76{

Callers 4

cbmem_sysfs_initFunction · 0.85
fetch_cbmem_entryFunction · 0.85

Calls 3

strerrorFunction · 0.85
dieFunction · 0.50
snprintfFunction · 0.50

Tested by

no test coverage detected