diff options
author | Karel Zak | 2012-11-05 12:23:55 +0100 |
---|---|---|
committer | Karel Zak | 2012-11-23 14:58:21 +0100 |
commit | ca01695b77815d175814e0826968d2b680e1c629 (patch) | |
tree | eae87478ad4784e1140ce04b4f066808df34a2fa /sys-utils | |
parent | ipcs: add /proc and /sys path definitions (diff) | |
download | kernel-qcow2-util-linux-ca01695b77815d175814e0826968d2b680e1c629.tar.gz kernel-qcow2-util-linux-ca01695b77815d175814e0826968d2b680e1c629.tar.xz kernel-qcow2-util-linux-ca01695b77815d175814e0826968d2b680e1c629.zip |
lib/path: rename functions to be more explicit
... and to have names compatible with lib/sysfs.c
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/chcpu.c | 22 | ||||
-rw-r--r-- | sys-utils/lscpu.c | 35 |
2 files changed, 29 insertions, 28 deletions
diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c index 0209fe9bf..da6f65887 100644 --- a/sys-utils/chcpu.c +++ b/sys-utils/chcpu.c @@ -83,7 +83,7 @@ static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable) printf(_("CPU %d is not hot pluggable\n"), cpu); continue; } - online = path_getnum(_PATH_SYS_CPU "/cpu%d/online", cpu); + online = path_read_s32(_PATH_SYS_CPU "/cpu%d/online", cpu); if ((online == 1) && (enable == 1)) { printf(_("CPU %d is already enabled\n"), cpu); continue; @@ -93,9 +93,9 @@ static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable) continue; } if (path_exist(_PATH_SYS_CPU "/cpu%d/configure", cpu)) - configured = path_getnum(_PATH_SYS_CPU "/cpu%d/configure", cpu); + configured = path_read_s32(_PATH_SYS_CPU "/cpu%d/configure", cpu); if (enable) { - rc = path_writestr("1", _PATH_SYS_CPU "/cpu%d/online", cpu); + rc = path_write_str("1", _PATH_SYS_CPU "/cpu%d/online", cpu); if ((rc == -1) && (configured == 0)) printf(_("CPU %d enable failed " "(CPU is deconfigured)\n"), cpu); @@ -109,7 +109,7 @@ static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable) "(last enabled CPU)\n"), cpu); continue; } - rc = path_writestr("0", _PATH_SYS_CPU "/cpu%d/online", cpu); + rc = path_write_str("0", _PATH_SYS_CPU "/cpu%d/online", cpu); if (rc == -1) printf(_("CPU %d disable failed (%m)\n"), cpu); else { @@ -126,7 +126,7 @@ static int cpu_rescan(void) { if (!path_exist(_PATH_SYS_CPU_RESCAN)) errx(EXIT_FAILURE, _("This system does not support rescanning of CPUs")); - if (path_writestr("1", _PATH_SYS_CPU_RESCAN) == -1) + if (path_write_str("1", _PATH_SYS_CPU_RESCAN) == -1) err(EXIT_FAILURE, _("Failed to trigger rescan of CPUs")); printf(_("Triggered rescan of CPUs\n")); return EXIT_SUCCESS; @@ -138,11 +138,11 @@ static int cpu_set_dispatch(int mode) errx(EXIT_FAILURE, _("This system does not support setting " "the dispatching mode of CPUs")); if (mode == 0) { - if (path_writestr("0", _PATH_SYS_CPU_DISPATCH) == -1) + if (path_write_str("0", _PATH_SYS_CPU_DISPATCH) == -1) err(EXIT_FAILURE, _("Failed to set horizontal dispatch mode")); printf(_("Successfully set horizontal dispatching mode\n")); } else { - if (path_writestr("1", _PATH_SYS_CPU_DISPATCH) == -1) + if (path_write_str("1", _PATH_SYS_CPU_DISPATCH) == -1) err(EXIT_FAILURE, _("Failed to set vertical dispatch mode")); printf(_("Successfully set vertical dispatching mode\n")); } @@ -165,7 +165,7 @@ static int cpu_configure(cpu_set_t *cpu_set, size_t setsize, int configure) printf(_("CPU %d is not configurable\n"), cpu); continue; } - current = path_getnum(_PATH_SYS_CPU "/cpu%d/configure", cpu); + current = path_read_s32(_PATH_SYS_CPU "/cpu%d/configure", cpu); if ((current == 1) && (configure == 1)) { printf(_("CPU %d is already configured\n"), cpu); continue; @@ -181,13 +181,13 @@ static int cpu_configure(cpu_set_t *cpu_set, size_t setsize, int configure) continue; } if (configure) { - rc = path_writestr("1", _PATH_SYS_CPU "/cpu%d/configure", cpu); + rc = path_write_str("1", _PATH_SYS_CPU "/cpu%d/configure", cpu); if (rc == -1) printf(_("CPU %d configure failed (%m)\n"), cpu); else printf(_("CPU %d configured\n"), cpu); } else { - rc = path_writestr("0", _PATH_SYS_CPU "/cpu%d/configure", cpu); + rc = path_write_str("0", _PATH_SYS_CPU "/cpu%d/configure", cpu); if (rc == -1) printf(_("CPU %d deconfigure failed (%m)\n"), cpu); else @@ -262,7 +262,7 @@ int main(int argc, char *argv[]) if (maxcpus < 1) errx(EXIT_FAILURE, _("cannot determine NR_CPUS; aborting")); if (path_exist(_PATH_SYS_CPU_ONLINE)) - onlinecpus = path_cpulist(maxcpus, _PATH_SYS_CPU_ONLINE); + onlinecpus = path_read_cpulist(maxcpus, _PATH_SYS_CPU_ONLINE); setsize = CPU_ALLOC_SIZE(maxcpus); cpu_set = CPU_ALLOC(maxcpus); if (!cpu_set) diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index a111561dc..a840548c0 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -384,7 +384,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod) if (path_exist(_PATH_SYS_SYSTEM "/cpu/kernel_max")) /* note that kernel_max is maximum index [NR_CPUS-1] */ - maxcpus = path_getnum(_PATH_SYS_SYSTEM "/cpu/kernel_max") + 1; + maxcpus = path_read_s32(_PATH_SYS_SYSTEM "/cpu/kernel_max") + 1; else if (mod->system == SYSTEM_LIVE) /* the root is '/' so we are working with data from the current kernel */ @@ -398,7 +398,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod) setsize = CPU_ALLOC_SIZE(maxcpus); if (path_exist(_PATH_SYS_SYSTEM "/cpu/possible")) { - cpu_set_t *tmp = path_cpulist(maxcpus, _PATH_SYS_SYSTEM "/cpu/possible"); + cpu_set_t *tmp = path_read_cpulist(maxcpus, _PATH_SYS_SYSTEM "/cpu/possible"); desc->ncpuspos = CPU_COUNT_S(setsize, tmp); cpuset_free(tmp); } else @@ -408,19 +408,20 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod) /* get mask for present CPUs */ if (path_exist(_PATH_SYS_SYSTEM "/cpu/present")) { - desc->present = path_cpulist(maxcpus, _PATH_SYS_SYSTEM "/cpu/present"); + desc->present = path_read_cpulist(maxcpus, _PATH_SYS_SYSTEM "/cpu/present"); desc->ncpus = CPU_COUNT_S(setsize, desc->present); } /* get mask for online CPUs */ if (path_exist(_PATH_SYS_SYSTEM "/cpu/online")) { - desc->online = path_cpulist(maxcpus, _PATH_SYS_SYSTEM "/cpu/online"); + size_t setsize = CPU_ALLOC_SIZE(maxcpus); + desc->online = path_read_cpulist(maxcpus, _PATH_SYS_SYSTEM "/cpu/online"); desc->nthreads = CPU_COUNT_S(setsize, desc->online); } /* get dispatching mode */ if (path_exist(_PATH_SYS_SYSTEM "/cpu/dispatching")) - desc->dispatching = path_getnum(_PATH_SYS_SYSTEM "/cpu/dispatching"); + desc->dispatching = path_read_s32(_PATH_SYS_SYSTEM "/cpu/dispatching"); else desc->dispatching = -1; } @@ -611,13 +612,13 @@ read_topology(struct lscpu_desc *desc, int num) if (!path_exist(_PATH_SYS_CPU "/cpu%d/topology/thread_siblings", num)) return; - thread_siblings = path_cpuset(maxcpus, _PATH_SYS_CPU + thread_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU "/cpu%d/topology/thread_siblings", num); - core_siblings = path_cpuset(maxcpus, _PATH_SYS_CPU + core_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU "/cpu%d/topology/core_siblings", num); book_siblings = NULL; if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/book_siblings", num)) { - book_siblings = path_cpuset(maxcpus, _PATH_SYS_CPU + book_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU "/cpu%d/topology/book_siblings", num); } @@ -683,7 +684,7 @@ read_polarization(struct lscpu_desc *desc, int num) return; if (!desc->polarization) desc->polarization = xcalloc(desc->ncpuspos, sizeof(int)); - path_getstr(mode, sizeof(mode), _PATH_SYS_CPU "/cpu%d/polarization", num); + path_read_str(mode, sizeof(mode), _PATH_SYS_CPU "/cpu%d/polarization", num); if (strncmp(mode, "vertical:low", sizeof(mode)) == 0) desc->polarization[num] = POLAR_VLOW; else if (strncmp(mode, "vertical:medium", sizeof(mode)) == 0) @@ -703,7 +704,7 @@ read_address(struct lscpu_desc *desc, int num) return; if (!desc->addresses) desc->addresses = xcalloc(desc->ncpuspos, sizeof(int)); - desc->addresses[num] = path_getnum(_PATH_SYS_CPU "/cpu%d/address", num); + desc->addresses[num] = path_read_s32(_PATH_SYS_CPU "/cpu%d/address", num); } static void @@ -713,7 +714,7 @@ read_configured(struct lscpu_desc *desc, int num) return; if (!desc->configured) desc->configured = xcalloc(desc->ncpuspos, sizeof(int)); - desc->configured[num] = path_getnum(_PATH_SYS_CPU "/cpu%d/configure", num); + desc->configured[num] = path_read_s32(_PATH_SYS_CPU "/cpu%d/configure", num); } static int @@ -752,7 +753,7 @@ read_cache(struct lscpu_desc *desc, int num) int type, level; /* cache type */ - path_getstr(buf, sizeof(buf), + path_read_str(buf, sizeof(buf), _PATH_SYS_CPU "/cpu%d/cache/index%d/type", num, i); if (!strcmp(buf, "Data")) @@ -763,7 +764,7 @@ read_cache(struct lscpu_desc *desc, int num) type = 0; /* cache level */ - level = path_getnum(_PATH_SYS_CPU "/cpu%d/cache/index%d/level", + level = path_read_s32(_PATH_SYS_CPU "/cpu%d/cache/index%d/level", num, i); if (type) snprintf(buf, sizeof(buf), "L%d%c", level, type); @@ -773,14 +774,14 @@ read_cache(struct lscpu_desc *desc, int num) ca->name = xstrdup(buf); /* cache size */ - path_getstr(buf, sizeof(buf), + path_read_str(buf, sizeof(buf), _PATH_SYS_CPU "/cpu%d/cache/index%d/size", num, i); ca->size = xstrdup(buf); } /* information about how CPUs share different caches */ - map = path_cpuset(maxcpus, + map = path_read_cpuset(maxcpus, _PATH_SYS_CPU "/cpu%d/cache/index%d/shared_cpu_map", num, i); @@ -806,7 +807,7 @@ read_nodes(struct lscpu_desc *desc) /* information about how nodes share different CPUs */ for (i = 0; i < desc->nnodes; i++) - desc->nodemaps[i] = path_cpuset(maxcpus, + desc->nodemaps[i] = path_read_cpuset(maxcpus, _PATH_SYS_SYSTEM "/node/node%d/cpumap", i); } @@ -1338,7 +1339,7 @@ int main(int argc, char *argv[]) mod->mode = c == 'p' ? OUTPUT_PARSABLE : OUTPUT_READABLE; break; case 's': - path_setprefix(optarg); + path_set_prefix(optarg); mod->system = SYSTEM_SNAPSHOT; break; case 'x': |