From: Waldemar Kozaczuk <[email protected]> Committer: Nadav Har'El <[email protected]> Branch: master
sysfs: add /sys/devices/system/cpu/online This patch adds new pseudo file to the sysfs filesystem to list number of online cpus. This file lists number of cpus in the following format: 0-<# of cpus - 1> Signed-off-by: Waldemar Kozaczuk <[email protected]> Closes #1241 --- diff --git a/fs/sysfs/sysfs_vnops.cc b/fs/sysfs/sysfs_vnops.cc --- a/fs/sysfs/sysfs_vnops.cc +++ b/fs/sysfs/sysfs_vnops.cc @@ -89,6 +89,14 @@ sysfs_mount(mount* mp, const char *dev, int flags, const void* data) auto system = make_shared<pseudo_dir_node>(inode_count++); system->add("node", node); + auto cpu = make_shared<pseudo_dir_node>(inode_count++); + cpu->add("online", inode_count++, [] { + std::ostringstream os; + osv::fprintf(os, "0-%d", sched::cpus.size() - 1); + return os.str(); + }); + system->add("cpu", cpu); + auto devices = make_shared<pseudo_dir_node>(inode_count++); devices->add("system", system); -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000c940080602de0710%40google.com.
