util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix non-Linux build
@ 2012-08-08 15:19 Samuel Thibault
  2012-08-13 13:25 ` Karel Zak
  0 siblings, 1 reply; 5+ messages in thread
From: Samuel Thibault @ 2012-08-08 15:19 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

loopdev.c, test_pager, and get_max_number_of_cpus() are linux-specific.
get_linux_version will only work on Linux, let's introduce
system_supports_ext4_ext2() which assumes that mounting ext2 with ext4
is not supported on non-Linux systems.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index 6a6e9b2..78f6fe4 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -10,7 +10,6 @@ libcommon_la_SOURCES = \
 	lib/env.c \
 	lib/fileutils.c \
 	lib/ismounted.c \
-	lib/loopdev.c \
 	lib/mangle.c \
 	lib/match.c \
 	lib/mbsalign.c \
@@ -27,7 +26,9 @@ libcommon_la_SOURCES = \
 	lib/xgetpass.c
 
 if LINUX
-libcommon_la_SOURCES += lib/linux_version.c
+libcommon_la_SOURCES +=
+	lib/linux_version.c \
+	lib/loopdev.c
 endif
 
 if !HAVE_LANGINFO
@@ -41,7 +42,6 @@ check_PROGRAMS += \
 	test_fileutils \
 	test_ismounted \
 	test_mangle \
-	test_pager \
 	test_procutils \
 	test_randutils \
 	test_strutils \
@@ -54,7 +54,8 @@ check_PROGRAMS += test_cpuset
 endif
 check_PROGRAMS += \
 	test_sysfs \
-	test_loopdev
+	test_loopdev \
+	test_pager
 endif
 
 test_blkdev_SOURCES = lib/blkdev.c
diff --git a/lib/cpuset.c b/lib/cpuset.c
index 78efd53..cb4315a 100644
--- a/lib/cpuset.c
+++ b/lib/cpuset.c
@@ -54,6 +54,7 @@ static const char *nexttoken(const char *q,  int sep)
 	return q;
 }
 
+#ifdef __linux__
 /*
  * Number of bits in a CPU bitmask on current system
  */
@@ -85,6 +86,7 @@ int get_max_number_of_cpus(void)
 	}
 	return -1;
 }
+#endif
 
 /*
  * Allocates a new set for ncpus and returns size in bytes and size in bits
diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c
index 4066347..eff96a0 100644
--- a/libblkid/src/superblocks/ext.c
+++ b/libblkid/src/superblocks/ext.c
@@ -257,6 +257,15 @@ static int system_supports_ext4dev(void)
 	ret = (fs_proc_check("ext4dev") || check_for_modules("ext4dev"));
 	return ret;
 }
+
+static int system_supports_ext4_ext2(void)
+{
+#ifdef __linux__
+	return get_linux_version() >= EXT4_SUPPORTS_EXT2;
+#else
+	return 0;
+#endif
+}
 /*
  * reads superblock and returns:
  *	fc = feature_compat
@@ -352,7 +361,7 @@ static int probe_ext2(blkid_probe pr,
 	 */
 	if (!system_supports_ext2() &&
 	    (system_supports_ext4() || system_supports_ext4dev()) &&
-	    get_linux_version() >= EXT4_SUPPORTS_EXT2)
+	    system_supports_ext4_ext2())
 		return -BLKID_ERR_PARAM;
 
 	ext_get_info(pr, 2, es);
@@ -405,7 +414,7 @@ static int probe_ext4dev(blkid_probe pr,
 	if (!(fc & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
 	    !system_supports_ext2() && !system_supports_ext4() &&
 	    system_supports_ext4dev() &&
-	    get_linux_version() >= EXT4_SUPPORTS_EXT2)
+	    system_supports_ext4_ext2())
 		goto force_ext4dev;
 
 	/*
@@ -450,7 +459,7 @@ static int probe_ext4(blkid_probe pr,
 	 */
 	if (!(fc & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
 	    !system_supports_ext2() && system_supports_ext4() &&
-	    get_linux_version() >= EXT4_SUPPORTS_EXT2)
+	    system_supports_ext4_ext2())
 		goto force_ext4;
 
 	/* Ext4 has at least one feature which ext3 doesn't understand */

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] Fix non-Linux build
@ 2025-01-12 15:39 Samuel Thibault
  2025-01-14  9:32 ` Karel Zak
  0 siblings, 1 reply; 5+ messages in thread
From: Samuel Thibault @ 2025-01-12 15:39 UTC (permalink / raw)
  To: util-linux

This fixes non-Linux builds, by:

- making sfdisk discard option conditioned by availability of BLKDISCARD
- defining and using blkid_probe_get_buffer only if O_DIRECT is
  available
- always building src/fs_statmount.c and src/tab_listmount.c, they
  already contain proper conditions to make them void if support is not
  available.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 5e7c1d926..d8261c442 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -1370,6 +1370,7 @@ static int command_partattrs(struct sfdisk *sf, int argc, char **argv)
 	return write_changes(sf);
 }
 
+#ifdef BLKDISCARD
 /*
  * sfdisk --discard-free <device>
  */
@@ -1432,6 +1433,12 @@ done:
 	fdisk_unref_table(tb);
 	return rc;
 }
+#else /* BLKDISCARD */
+static int command_discard_free(struct sfdisk *sf, int argc, char **argv)
+{
+	fdisk_warnx(sf->cxt, _("Discard unsupported on your system."));
+}
+#endif /* BLKDISCARD */
 
 /*
  * sfdisk --disk-id <device> [<str>]
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 5a156251c..61b93021c 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -791,6 +791,7 @@ const unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64
 	return real_off ? bf->data + (real_off - bf->off + bias) : bf->data + bias;
 }
 
+#ifdef O_DIRECT
 /*
  * This is blkid_probe_get_buffer with the read done as an O_DIRECT operation.
  * Note that @off is offset within probing area, the probing area is defined by
@@ -817,6 +818,7 @@ const unsigned char *blkid_probe_get_buffer_direct(blkid_probe pr, uint64_t off,
 	}
 	return ret;
 }
+#endif
 
 /**
  * blkid_probe_reset_buffers:
diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c
index 7a9f8c9b9..c0779c233 100644
--- a/libblkid/src/superblocks/ext.c
+++ b/libblkid/src/superblocks/ext.c
@@ -164,6 +164,7 @@ static struct ext2_super_block *ext_get_super(
 		 * then declare a checksum mismatch.
 		 */
 		if (!blkid_probe_verify_csum(pr, csum, le32_to_cpu(es->s_checksum))) {
+#ifdef O_DIRECT
 			if (blkid_probe_reset_buffers(pr))
 				return NULL;
 
@@ -175,6 +176,9 @@ static struct ext2_super_block *ext_get_super(
 			csum = crc32c(~0, es, offsetof(struct ext2_super_block, s_checksum));
 			if (!blkid_probe_verify_csum(pr, csum, le32_to_cpu(es->s_checksum)))
 				return NULL;
+#else
+			return NULL;
+#endif
 		}
 	}
 	if (fc)
diff --git a/libmount/meson.build b/libmount/meson.build
index 05b31d4d4..29a43be02 100644
--- a/libmount/meson.build
+++ b/libmount/meson.build
@@ -24,6 +24,7 @@ lib_mount_sources = '''
   src/mountP.h
   src/cache.c
   src/fs.c
+  src/fs_statmount.c
   src/init.c
   src/iter.c
   src/lock.c
@@ -31,6 +32,7 @@ lib_mount_sources = '''
   src/optstr.c
   src/tab.c
   src/tab_diff.c
+  src/tab_listmount.c
   src/tab_parse.c
   src/tab_update.c
   src/test.c
@@ -43,8 +45,6 @@ lib_mount_sources = '''
 
 if LINUX
   lib_mount_sources += '''
-    src/fs_statmount.c
-    src/tab_listmount.c
     src/hooks.c
     src/monitor.c
     src/optlist.c
diff --git a/libmount/src/Makemodule.am b/libmount/src/Makemodule.am
index 49f6d6f03..5a5c787a4 100644
--- a/libmount/src/Makemodule.am
+++ b/libmount/src/Makemodule.am
@@ -11,6 +11,7 @@ libmount_la_SOURCES = \
 	libmount/src/mountP.h \
 	libmount/src/cache.c \
 	libmount/src/fs.c \
+	libmount/src/fs_statmount.c \
 	libmount/src/init.c \
 	libmount/src/iter.c \
 	libmount/src/lock.c \
@@ -19,6 +20,7 @@ libmount_la_SOURCES = \
 	libmount/src/optstr.c \
 	libmount/src/tab.c \
 	libmount/src/tab_diff.c \
+	libmount/src/tab_listmount.c \
 	libmount/src/tab_parse.c \
 	libmount/src/tab_update.c \
 	libmount/src/test.c \
@@ -30,8 +32,6 @@ libmount_la_SOURCES += \
 	libmount/src/context.c \
 	libmount/src/context_mount.c \
 	libmount/src/context_umount.c \
-	libmount/src/fs_statmount.c \
-	libmount/src/tab_listmount.c \
 	libmount/src/hooks.c \
 	libmount/src/hook_mount.c \
 	libmount/src/hook_mount_legacy.c \

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-14  9:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-08 15:19 [PATCH] Fix non-Linux build Samuel Thibault
2012-08-13 13:25 ` Karel Zak
2012-08-15 12:23   ` Samuel Thibault
  -- strict thread matches above, loose matches on Subject: below --
2025-01-12 15:39 Samuel Thibault
2025-01-14  9:32 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).