diff options
author | Karel Zak | 2018-05-09 15:54:12 +0200 |
---|---|---|
committer | Karel Zak | 2018-06-21 11:58:10 +0200 |
commit | 1ed21c80ed3683c17708caad3d545da4d8e09b02 (patch) | |
tree | 6a37d3f03c6c9e5031aa04d4554cebb6ef318e32 /lib/Makemodule.am | |
parent | lsblk: add partition table UUID and type fields. (diff) | |
download | kernel-qcow2-util-linux-1ed21c80ed3683c17708caad3d545da4d8e09b02.tar.gz kernel-qcow2-util-linux-1ed21c80ed3683c17708caad3d545da4d8e09b02.tar.xz kernel-qcow2-util-linux-1ed21c80ed3683c17708caad3d545da4d8e09b02.zip |
lib/path: new implementation
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>
Diffstat (limited to 'lib/Makemodule.am')
-rw-r--r-- | lib/Makemodule.am | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Makemodule.am b/lib/Makemodule.am index 2166d0384..2081ac927 100644 --- a/lib/Makemodule.am +++ b/lib/Makemodule.am @@ -18,7 +18,6 @@ libcommon_la_SOURCES = \ lib/md5.c \ lib/pager.c \ lib/parse-date.y \ - lib/path.c \ lib/pwdutils.c \ lib/randutils.c \ lib/setproctitle.c \ @@ -49,6 +48,7 @@ libcommon_la_SOURCES += lib/cpuset.c endif if HAVE_OPENAT +libcommon_la_SOURCES += lib/path.c libcommon_la_SOURCES += lib/procutils.c libcommon_la_SOURCES += lib/sysfs.c endif @@ -97,6 +97,7 @@ endif if HAVE_OPENAT check_PROGRAMS += test_procutils +check_PROGRAMS += test_path endif test_ttyutils_SOURCES = lib/ttyutils.c @@ -129,6 +130,15 @@ test_procutils_SOURCES = lib/procutils.c test_procutils_CFLAGS = $(AM_CFLAGS) -DTEST_PROGRAM_PROCUTILS endif +if HAVE_OPENAT +test_path_SOURCES = lib/path.c lib/fileutils.c +if HAVE_CPU_SET_T +test_path_SOURCES += lib/cpuset.c +endif +test_path_CFLAGS = $(AM_CFLAGS) -DTEST_PROGRAM_PATH +test_path_LDADD = $(LDADD) +endif + if LINUX test_cpuset_SOURCES = lib/cpuset.c test_cpuset_CFLAGS = $(AM_CFLAGS) -DTEST_PROGRAM_CPUSET |