From 8c1be37e5b438bfdb640cfd39700bf074c66820c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 1 Dec 2016 20:25:26 +0100 Subject: util-lib: split out image dissecting code and loopback code from nspawn This adds two new APIs to systemd: - loop-util.h is a simple internal API for allocating, setting up and releasing loopback block devices. - dissect-image.h is an internal API for taking apart disk images and figuring out what the purpose of each partition is. Both APIs are basically refactored versions of similar code in nspawn. This rework should permit us to reuse this in other places than just nspawn in the future. Specifically: to implement RootImage= in the service image, similar to RootDirectory=, but operating on a disk image; to unify the gpt-auto-discovery generator code with the discovery logic in nspawn; to add new API to machined for determining the OS version of a disk image (i.e. not just running containers). This PR does not make any such changes however, it just provides the new reworked API. The reworked code is also slightly more powerful than the nspawn original one. When pointing it to an image or block device with a naked file system (i.e. no partition table) it will simply make it the root device. --- Makefile.am | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 124e1867cd..c47a07a1f0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1042,6 +1042,8 @@ libshared_la_SOURCES = \ src/shared/machine-image.h \ src/shared/machine-pool.c \ src/shared/machine-pool.h \ + src/shared/loop-util.c \ + src/shared/loop-util.h \ src/shared/resolve-util.c \ src/shared/resolve-util.h \ src/shared/bus-unit-util.c \ @@ -1053,7 +1055,9 @@ libshared_la_SOURCES = \ src/shared/fdset.c \ src/shared/fdset.h \ src/shared/nsflags.h \ - src/shared/nsflags.c + src/shared/nsflags.c \ + src/shared/dissect-image.c \ + src/shared/dissect-image.h if HAVE_UTMP libshared_la_SOURCES += \ @@ -1076,7 +1080,8 @@ libshared_la_CFLAGS = \ $(AM_CFLAGS) \ $(ACL_CFLAGS) \ $(LIBIDN_CFLAGS) \ - $(SECCOMP_CFLAGS) + $(SECCOMP_CFLAGS) \ + $(BLKID_CFLAGS) libshared_la_LIBADD = \ libsystemd-internal.la \ @@ -1085,7 +1090,8 @@ libshared_la_LIBADD = \ libudev-internal.la \ $(ACL_LIBS) \ $(LIBIDN_LIBS) \ - $(SECCOMP_LIBS) + $(SECCOMP_LIBS) \ + $(BLKID_LIBS) rootlibexec_LTLIBRARIES += \ libsystemd-shared.la @@ -1107,6 +1113,7 @@ libsystemd_shared_la_CFLAGS = \ $(ACL_CFLAGS) \ $(LIBIDN_CFLAGS) \ $(SECCOMP_CFLAGS) \ + $(BLKID_CFLAGS) \ -fvisibility=default # We can't use libshared_la_LIBADD here because it would @@ -1118,7 +1125,8 @@ libsystemd_shared_la_LIBADD = \ $(libudev_internal_la_LIBADD) \ $(ACL_LIBS) \ $(LIBIDN_LIBS) \ - $(SECCOMP_LIBS) + $(SECCOMP_LIBS) \ + $(BLKID_LIBS) libsystemd_shared_la_LDFLAGS = \ $(AM_LDFLAGS) \ @@ -1456,7 +1464,8 @@ manual_tests += \ test-btrfs \ test-acd \ test-ipv4ll-manual \ - test-ask-password-api + test-ask-password-api \ + test-dissect-image unsafe_tests = \ test-hostname \ @@ -2067,6 +2076,17 @@ test_ask_password_api_SOURCES = \ test_ask_password_api_LDADD = \ libsystemd-shared.la +test_dissect_image_SOURCES = \ + src/test/test-dissect-image.c + +test_dissect_image_CFLAGS = \ + $(AM_CFLAGS) \ + $(BLKID_CFLAGS) + +test_dissect_image_LDADD = \ + libsystemd-shared.la \ + $(BLKID_LIBS) + test_signal_util_SOURCES = \ src/test/test-signal-util.c -- cgit v1.2.3-54-g00ecf