summaryrefslogtreecommitdiffstats
path: root/include/path.h
Commit message (Collapse)AuthorAgeFilesLines
* include/path.h: remove duplicate header inclusionSami Kerola2019-02-181-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* choom: fix negative adjust score usageKarel Zak2018-12-101-0/+1
| | | | | | | | It's really bad idea to use uint64_t (ul_path_write_u64(()) when write signed number. Addresses: https://github.com/karelzak/util-linux/issues/723 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: allow to close dirfdKarel Zak2018-12-071-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/path: make sure PATH_MAX is definedKarel Zak2018-06-211-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: allow dir-path formattingKarel Zak2018-06-211-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: add ul_prefix_fopen(), improve cpuset funcsKarel Zak2018-06-211-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: add ul_path_read_buffer()Karel Zak2018-06-211-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: add ul_path_get_abspath()Karel Zak2018-06-211-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path lib/sysfs: add debugKarel Zak2018-06-211-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: new implementationKarel Zak2018-06-211-27/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to avoid duplicate code in path.c and sysfs.c and make it possible to define prefix for paths for all sysfs and procfs based utils. Now we have /proc snapshots (for tests) for lscpu only. It would be nice to have the same (for sysfs) for lsblk and another tools. * very simple API to read numbers, strings and symlinks * based on openat() pc = ul_new_path("/sys/block/sda"); ul_path_read_u64(pc, &size, "size"); ul_path_read_u64(pc, &lsz, "queue/logical_block_size"); * printf-like API to generate paths, for example: ul_path_readf_u64(pc, &num, "sda%d/size", partno) * allow to define prefix to redirect hardcoded paths to another location, for example: pc = ul_new_path("/sys/block/sda"); ul_path_set_prefix(pc, "/my/regression/dump"); ul_path_read_u64(pc, &num, "size"); to read /my/regression/dump/sys/block/sda/size * allow to extend the API by "dialects", for example for sysfs: pc = ul_new_path(NULL); sysfs_blkdev_init_path(pc, devno, NULL); and use ul_path_* functions to read from @pc initialized by sysfs_blkdev_init_path() * add test_path binary Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: make path_set_prefix() independent on cpu_set_tKarel Zak2017-10-231-5/+4Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsmem: fix, using freed memoryRuediger Meier2017-06-291-1/+4
| | | | | | | | | | | | | Simply avoiding strdup(). Error handling improved. This was the Clang Analyzer warning: Memory Error, Use-after-free sys-utils/lsmem.c:259:3: warning: Use of memory after it is freed err(EXIT_FAILURE, _("Failed to open %s"), path); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib/path: fix crash, pathbuf overflowRuediger Meier2017-06-271-1/+5
| | | | | | | | | | | | | | Before: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" Segmentation fault (core dumped) After: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" lscpu: invalid argument to --sysroot: File name too long Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib/path: add path_strdup()Karel Zak2014-01-061-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: add path_read_u64()Karel Zak2012-11-231-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: rename functions to be more explicitKarel Zak2012-11-231-6/+6
| | | | | | ... and to have names compatible with lib/sysfs.c Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: cleanup cpu_set_t usageKarel Zak2012-11-021-0/+10
| | | | | | | - make taskset depend on cpu_set_t - make cpuset.c optional for libcommon and lib/path.c Signed-off-by: Karel Zak <kzak@redhat.com>
* chcpu: convert to use lib/path.cHeiko Carstens2011-09-271-0/+2
| | | | | | | Use the common path access functions. In order to simplify chcpu also implement and use path_writestr() which writes a string to the path specified. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib,path: move path access functions from lscpu into lib/path.cHeiko Carstens2011-09-271-0/+15
A couple of these functions already have been copied to chcpu.c, so it makes sense to move these functions into an own file. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>