* [PATCH 13/11] xfsprogs: Add a way to compile without blkid
@ 2015-08-13 14:10 Jan Tulak
2015-08-14 0:54 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Jan Tulak @ 2015-08-13 14:10 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Because not all platforms have up-to-date blkid with required
functions, allow at least partial functionality by adding
--enable-blkid=yes/no optional configure argument.
When blkid is disabled, signature detection and device geometry
detection doesn't work.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
configure.ac | 10 +++++++++-
include/builddefs.in | 1 +
mkfs/xfs_mkfs.c | 22 +++++++++++++++++++++-
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9ea8b22..a734926 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,11 @@ AC_ARG_ENABLE(gettext,
enable_gettext=yes)
AC_SUBST(enable_gettext)
+AC_ARG_ENABLE(blkid,
+[ --enable-blkid=[yes/no] Enable use of block device id library [default=yes]],,
+ enable_blkid=yes)
+AC_SUBST(enable_blkid)
+
AC_ARG_ENABLE(readline,
[ --enable-readline=[yes/no] Enable readline command editing [default=no]],
test $enable_readline = yes && libreadline="-lreadline",
@@ -115,11 +120,14 @@ AC_HAVE_FALLOCATE
AC_HAVE_FIEMAP
AC_HAVE_PREADV
AC_HAVE_SYNC_FILE_RANGE
-AC_HAVE_BLKID_TOPO
AC_HAVE_READDIR
AC_HAVE_MNTENT
AC_HAVE_FLS
+if test "$enable_blkid" = yes; then
+AC_HAVE_BLKID_TOPO
+fi
+
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([char *])
AC_TYPE_UMODE_T
diff --git a/include/builddefs.in b/include/builddefs.in
index 8851956..f3f8089 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -89,6 +89,7 @@ ENABLE_SHARED = @enable_shared@
ENABLE_GETTEXT = @enable_gettext@
ENABLE_EDITLINE = @enable_editline@
ENABLE_READLINE = @enable_readline@
+ENABLE_BLKID = @enable_blkid@
HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index d349b4f..656c3f9 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -18,7 +18,9 @@
#include "libxfs.h"
#include <ctype.h>
-#include <blkid/blkid.h>
+#ifdef ENABLE_BLKID
+# include <blkid/blkid.h>
+#endif /* ENABLE_BLKID */
#include "xfs_mkfs.h"
/*
@@ -298,6 +300,7 @@ calc_stripe_factors(
* 0 for nothing found
* -1 for internal error
*/
+#ifdef ENABLE_BLKID
static int
check_overwrite(
char *device)
@@ -451,6 +454,19 @@ out_free_probe:
_("warning: unable to probe device topology for device %s\n"),
device);
}
+#else /* ifdef ENABLE_BLKID */
+/*
+ * Without blkid, we can't do a good check for signatures.
+ * So instead of some messy attempts, just disable any checks
+ * and always return 'nothing found'.
+ */
+static int
+check_overwrite(
+ char *device)
+{
+ return 0;
+}
+#endif /* ENABLE_BLKID */
static void get_topology(
libxfs_init_t *xi,
@@ -483,16 +499,20 @@ static void get_topology(
} else
ft->psectorsize = ft->lsectorsize = BBSIZE;
} else {
+#ifdef ENABLE_BLKID
blkid_get_topology(dfile, &ft->dsunit, &ft->dswidth,
&ft->lsectorsize, &ft->psectorsize,
force_overwrite);
+#endif /* ENABLE_BLKID */
}
if (xi->rtname && !xi->risfile) {
int sunit, lsectorsize, psectorsize;
+#ifdef ENABLE_BLKID
blkid_get_topology(xi->rtname, &sunit, &ft->rtswidth,
&lsectorsize, &psectorsize, force_overwrite);
+#endif /* ENABLE_BLKID */
}
}
--
2.4.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 13/11] xfsprogs: Add a way to compile without blkid
2015-08-13 14:10 [PATCH 13/11] xfsprogs: Add a way to compile without blkid Jan Tulak
@ 2015-08-14 0:54 ` Dave Chinner
2015-08-14 6:48 ` [PATCH 13/11 v2] " Jan Tulak
0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2015-08-14 0:54 UTC (permalink / raw)
To: Jan Tulak; +Cc: xfs
On Thu, Aug 13, 2015 at 04:10:55PM +0200, Jan Tulak wrote:
> Because not all platforms have up-to-date blkid with required
> functions, allow at least partial functionality by adding
> --enable-blkid=yes/no optional configure argument.
>
> When blkid is disabled, signature detection and device geometry
> detection doesn't work.
>
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
.....
> +#else /* ifdef ENABLE_BLKID */
> +/*
> + * Without blkid, we can't do a good check for signatures.
> + * So instead of some messy attempts, just disable any checks
> + * and always return 'nothing found'.
> + */
> +static int
> +check_overwrite(
> + char *device)
> +{
> + return 0;
> +}
> +#endif /* ENABLE_BLKID */
I'd default the other way around, and always report that something
was found. That way we don't accidentally overwrite a block device
when someone fat-fingers the blockdev. It will mean you have to use
the force flag on OSX until such time that blkid is made to work,
but I think that's better than just overwriting the blockdev without
question....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 13/11 v2] xfsprogs: Add a way to compile without blkid
2015-08-14 0:54 ` Dave Chinner
@ 2015-08-14 6:48 ` Jan Tulak
0 siblings, 0 replies; 3+ messages in thread
From: Jan Tulak @ 2015-08-14 6:48 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
UPDATE: default to "signature found", so without blkid,
-f is mandatory.
Because not all platforms have up-to-date blkid with required
functions, allow at least partial functionality by adding
--enable-blkid=yes/no optional configure argument.
When blkid is disabled, signature detection and device geometry
detection doesn't work.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
configure.ac | 10 +++++++++-
include/builddefs.in | 1 +
mkfs/xfs_mkfs.c | 22 +++++++++++++++++++++-
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9ea8b22..a734926 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,11 @@ AC_ARG_ENABLE(gettext,
enable_gettext=yes)
AC_SUBST(enable_gettext)
+AC_ARG_ENABLE(blkid,
+[ --enable-blkid=[yes/no] Enable use of block device id library [default=yes]],,
+ enable_blkid=yes)
+AC_SUBST(enable_blkid)
+
AC_ARG_ENABLE(readline,
[ --enable-readline=[yes/no] Enable readline command editing [default=no]],
test $enable_readline = yes && libreadline="-lreadline",
@@ -115,11 +120,14 @@ AC_HAVE_FALLOCATE
AC_HAVE_FIEMAP
AC_HAVE_PREADV
AC_HAVE_SYNC_FILE_RANGE
-AC_HAVE_BLKID_TOPO
AC_HAVE_READDIR
AC_HAVE_MNTENT
AC_HAVE_FLS
+if test "$enable_blkid" = yes; then
+AC_HAVE_BLKID_TOPO
+fi
+
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([char *])
AC_TYPE_UMODE_T
diff --git a/include/builddefs.in b/include/builddefs.in
index 8851956..f3f8089 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -89,6 +89,7 @@ ENABLE_SHARED = @enable_shared@
ENABLE_GETTEXT = @enable_gettext@
ENABLE_EDITLINE = @enable_editline@
ENABLE_READLINE = @enable_readline@
+ENABLE_BLKID = @enable_blkid@
HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index d349b4f..56d2410 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -18,7 +18,9 @@
#include "libxfs.h"
#include <ctype.h>
-#include <blkid/blkid.h>
+#ifdef ENABLE_BLKID
+# include <blkid/blkid.h>
+#endif /* ENABLE_BLKID */
#include "xfs_mkfs.h"
/*
@@ -298,6 +300,7 @@ calc_stripe_factors(
* 0 for nothing found
* -1 for internal error
*/
+#ifdef ENABLE_BLKID
static int
check_overwrite(
char *device)
@@ -451,6 +454,19 @@ out_free_probe:
_("warning: unable to probe device topology for device %s\n"),
device);
}
+#else /* ifdef ENABLE_BLKID */
+/*
+ * Without blkid, we can't do a good check for signatures.
+ * So instead of some messy attempts, just disable any checks
+ * and always return 'nothing found'.
+ */
+static int
+check_overwrite(
+ char *device)
+{
+ return 1;
+}
+#endif /* ENABLE_BLKID */
static void get_topology(
libxfs_init_t *xi,
@@ -483,16 +499,20 @@ static void get_topology(
} else
ft->psectorsize = ft->lsectorsize = BBSIZE;
} else {
+#ifdef ENABLE_BLKID
blkid_get_topology(dfile, &ft->dsunit, &ft->dswidth,
&ft->lsectorsize, &ft->psectorsize,
force_overwrite);
+#endif /* ENABLE_BLKID */
}
if (xi->rtname && !xi->risfile) {
int sunit, lsectorsize, psectorsize;
+#ifdef ENABLE_BLKID
blkid_get_topology(xi->rtname, &sunit, &ft->rtswidth,
&lsectorsize, &psectorsize, force_overwrite);
+#endif /* ENABLE_BLKID */
}
}
--
2.4.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-14 6:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 14:10 [PATCH 13/11] xfsprogs: Add a way to compile without blkid Jan Tulak
2015-08-14 0:54 ` Dave Chinner
2015-08-14 6:48 ` [PATCH 13/11 v2] " Jan Tulak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox