Skip to contentSkip to conversation

libmount: only invoke loopcxt on linux

PATCH In review Andreas Henriksson 2 participants 6 messages Sep 18, 2014 – Sep 22, 2014 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 libmount: only invoke loopcxt on linux

This is part of an attempt to make libmount buildable on non-linux.

The support for /dev/loop* is Linux-specific so just disable it on non-linux for now.

---
 libmount/src/cache.c | 2 ++
 libmount/src/tab.c   | 2 ++
 2 files changed, 4 insertions(+)
libmount/src/cache.c +2 -0
index 8b2e656..fcd84fd 100644
@@ -633,6 +633,7 @@ char *mnt_pretty_path(const char *path, struct libmnt_cache *cache)
 	if (!pretty)
 		return strdup("none");
 
+#ifdef __linux__
 	/* users assume backing file name rather than /dev/loopN in
 	 * output if the device has been initialized by mount(8).
 	 */
@@ -653,6 +654,7 @@ char *mnt_pretty_path(const char *path, struct libmnt_cache *cache)
 		loopcxt_deinit(&lc);
 
 	}
+#endif
 
 done:
 	/* don't return pointer to the cache, allocate a new string */
libmount/src/tab.c +2 -0
index 4094fb8..011ba54 100644
@@ -1439,8 +1439,10 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
 			} else
 				flags = LOOPDEV_FL_OFFSET;
 
+#if __linux__
 			if (loopdev_is_used(mnt_fs_get_srcpath(fs), src, offset, flags))
 				break;
+#endif
 		}
 
 		if (root) {
Signature · 1 line
2.1.0.rc1
#1 lore raw

PATCH 2/5 libmount: only include context on linux

This is part of an attempt to make libmount buildable on non-linux.

The parts that need architecture specific porting is under the context*.c files and the rest of libmount is useful/used by for example fsck.

---
 libmount/src/Makemodule.am | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
libmount/src/Makemodule.am +8 -4
index d21179a..5a03520 100644
@@ -8,10 +8,6 @@ libmount_la_SOURCES = \
 	include/list.h \
 	\
 	libmount/src/cache.c \
-	libmount/src/context.c \
-	libmount/src/context_loopdev.c \
-	libmount/src/context_mount.c \
-	libmount/src/context_umount.c \
 	libmount/src/fs.c \
 	libmount/src/init.c \
 	libmount/src/iter.c \
@@ -28,6 +24,14 @@ libmount_la_SOURCES = \
 	libmount/src/version.c \
 	$(nodist_mountinc_HEADERS)
 
+if LINUX
+libmount_la_SOURCES += \
+	libmount/src/context.c \
+	libmount/src/context_loopdev.c \
+	libmount/src/context_mount.c \
+	libmount/src/context_umount.c
+endif
+
 nodist_libmount_la_SOURCES = libmount/src/mountP.h
 
 libmount_la_LIBADD = libcommon.la libblkid.la $(SELINUX_LIBS)
Signature · 1 line
2.1.0.rc1
#2 lore raw

PATCH 3/5 build-sys: build libmount everywhere

In reply to Andreas Henriksson

This enables libmount to build on non-linux, which also means we can build fsck on non-linux again. (Since the context part of libmount still needs porting, building the mount utility has instead been restricted to only build on Linux.)

This has been build-tested on Debian GNU/kFreeBSD.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index 387372f..ed3a65d 100644
@@ -799,7 +799,6 @@ AC_ARG_ENABLE([libmount],
   [], [UL_DEFAULT_ENABLE([libmount], [check])]
 )
 UL_BUILD_INIT([libmount])
-UL_REQUIRES_LINUX([libmount])
 UL_REQUIRES_BUILD([libmount], [libblkid])
 UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
 AM_CONDITIONAL([BUILD_LIBMOUNT], [test "x$build_libmount" = xyes])
@@ -856,6 +855,7 @@ AC_ARG_ENABLE([mount],
   [], [UL_DEFAULT_ENABLE([mount], [check])]
 )
 UL_BUILD_INIT([mount])
+UL_REQUIRES_LINUX([mount])
 UL_REQUIRES_BUILD([mount], [libmount])
 AM_CONDITIONAL([BUILD_MOUNT], [test "x$build_mount" = xyes])
 
Signature · 1 line
2.1.0.rc1
#3 lore raw

PATCH 4/5 build-sys: swaplabel needs libmount

In reply to Andreas Henriksson

The swaplabel utility uses libmount functionality and thus libmount has to be available if we want to build swaplabel. This change makes swaplabel be automatically disabled when we don't.

---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)
configure.ac +1 -0
index ed3a65d..f8b3397 100644
@@ -1143,6 +1143,7 @@ AM_CONDITIONAL([BUILD_WDCTL], [test "x$build_wdctl" = xyes])
 
 UL_BUILD_INIT([swaplabel], [check])
 UL_REQUIRES_BUILD([swaplabel], [libblkid])
+UL_REQUIRES_BUILD([swaplabel], [libmount])
 AM_CONDITIONAL([BUILD_SWAPLABEL], [test "x$build_swaplabel" = xyes])
 
 
Signature · 1 line
2.1.0.rc1
#4 lore raw

PATCH 5/5 logger: gettimeofday needs <sys/time.h>

In reply to Andreas Henriksson

Either works on linux, but kfreebsd build fails
if we don't use the <sys/time.h> include.

According to man gettimeofday the correct include is <sys/time.h>

---
 misc-utils/logger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
misc-utils/logger.c +1 -1
index 99a5569..2994dc0 100644
@@ -40,7 +40,7 @@
 #include <limits.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <time.h>
+#include <sys/time.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
Signature · 1 line
2.1.0.rc1
maintainer
#5 lore raw
Quoted 3 lines · Andreas Henriksson
 libmount/src/cache.c | 2 ++
 libmount/src/tab.c   | 2 ++
 2 files changed, 4 insertions(+)
Quoted 2 lines · Andreas Henriksson
 libmount/src/Makemodule.am | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 2 lines · Andreas Henriksson
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 2 lines · Andreas Henriksson
 misc-utils/logger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

All applied, thanks.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com