e2fsprogs: Build external libblkid by default
PATCH 1/3 e2fsprogs: Build external libblkid by default
This commit changes configure script to build external libblkid library by default instead of building the local blkid. The reason is that the the external libblkid is where all the development takes place and it should be always preferred option. We still have an option '--enable-blkid' to enable local build of the blkid library.
--- configure | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--------- configure.in | 23 ++++++++++++--------- 2 files changed, 63 insertions(+), 20 deletions(-)
configure +50 -10
@@ -1497,7 +1497,7 @@ Optional Features: --enable-blkid-debug enable blkid debugging --disable-testio-debug disable the use of the test I/O manager for debugging --disable-libuuid do not build private uuid library - --disable-libblkid do not build private blkid library + --enable-libblkid build private blkid library --enable-quota enable quota support --disable-debugfs disable support of debugfs program --disable-imager disable support of e2image program
@@ -5168,16 +5168,56 @@ $as_echo "Enabling private blkid library" >&6; } fi else - LIBBLKID='$(LIB)/libblkid'$LIB_EXT -DEPLIBBLKID=$LIBBLKID -STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT -DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID -PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT -DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID -$as_echo "#define CONFIG_BUILD_FINDFS 1" >>confdefs.h + if test -z "$PKG_CONFIG"; then + as_fn_error $? "pkg-config not installed; please install it." "$LINENO" 5 +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for blkid_get_cache in -lblkid" >&5 +$as_echo_n "checking for blkid_get_cache in -lblkid... " >&6; } +if ${ac_cv_lib_blkid_blkid_get_cache+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lblkid $LIBBLKID $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char blkid_get_cache (); +int +main () +{ +return blkid_get_cache (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_blkid_blkid_get_cache=yes +else + ac_cv_lib_blkid_blkid_get_cache=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blkid_blkid_get_cache" >&5 +$as_echo "$ac_cv_lib_blkid_blkid_get_cache" >&6; } +if test "x$ac_cv_lib_blkid_blkid_get_cache" = xyes; then : + LIBBLKID=`$PKG_CONFIG --libs blkid`; + STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid` +else + as_fn_error $? "external blkid library not found" "$LINENO" 5 +fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling private blkid library by default" >&5 -$as_echo "Enabling private blkid library by default" >&6; } +BLKID_CMT=# +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Disabling private blkid library by default" >&5 +$as_echo "Disabling private blkid library by default" >&6; } fi
configure.in +13 -10
@@ -509,7 +509,7 @@ AC_SUBST(PROFILED_LIBUUID) AC_SUBST(DEPPROFILED_LIBUUID) AC_SUBST(UUID_CMT) dnl -dnl handle --disable-libblkid +dnl handle --enable-libblkid dnl PKG_PROG_PKG_CONFIG LIBBLKID=
@@ -521,7 +521,7 @@ DEPPROFILED_LIBBLKID= BLKID_CMT= AH_TEMPLATE([CONFIG_BUILD_FINDFS], [Define to 1 to compile findfs]) AC_ARG_ENABLE([libblkid], -[ --disable-libblkid do not build private blkid library], +[ --enable-libblkid build private blkid library], if test "$enableval" = "no" then if test -z "$PKG_CONFIG"; then
@@ -546,14 +546,17 @@ else AC_MSG_RESULT([Enabling private blkid library]) fi , -LIBBLKID='$(LIB)/libblkid'$LIB_EXT -DEPLIBBLKID=$LIBBLKID -STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT -DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID -PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT -DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID -AC_DEFINE(CONFIG_BUILD_FINDFS, 1) -AC_MSG_RESULT([Enabling private blkid library by default]) +if test -z "$PKG_CONFIG"; then + AC_MSG_ERROR([pkg-config not installed; please install it.]) +fi + +AC_CHECK_LIB(blkid, blkid_get_cache, + [LIBBLKID=`$PKG_CONFIG --libs blkid`; + STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid`], + [AC_MSG_ERROR([external blkid library not found])], + [$LIBBLKID]) +BLKID_CMT=# +AC_MSG_RESULT([Disabling private blkid library by default]) ) AC_SUBST(LIBBLKID) AC_SUBST(DEPLIBBLKID)
Signature · 1 line
1.7.7.6
PATCH 2/3 e2fsprogs: Add write_byte64 into struct_io_manager
Current implementation of write_byte() is not able to cover 64bit offsets. In order to preserve the ABI this commit introduces new function into struct_io_manager called write_byte64 which is able to accept 64bit offset.
All io managers are updated to implement write_byte64() and use it even for write_byte().
--- lib/ext2fs/ext2_io.h | 4 +++- lib/ext2fs/inode_io.c | 18 +++++++++++++++--- lib/ext2fs/io_manager.c | 20 ++++++++++++++++++++ lib/ext2fs/test_io.c | 32 ++++++++++++++++++++++++++++++++ lib/ext2fs/unix_io.c | 17 ++++++++++++++--- 5 files changed, 84 insertions(+), 7 deletions(-)
lib/ext2fs/ext2_io.h +3 -1
@@ -90,7 +90,9 @@ struct struct_io_manager { int count, const void *data);errcode_t (*discard)(io_channel channel,unsigned long long block,unsigned long long count); -long reserved[16 ]; +errcode_t (*write_byte64)(io_channel channel,unsigned long long offset, +int count,const void *data); +long reserved[15 ]; };#define IO_FLAG_RW 0x0001
lib/ext2fs/inode_io.c +15 -3
@@ -57,6 +57,9 @@ static errcode_t inode_write_blk(io_channel channel, unsigned long block,static errcode_t inode_flush (io_channel channel);static errcode_t inode_write_byte (io_channel channel,unsigned long offset,int size,const void *data); +static errcode_t inode_write_byte64 (io_channel channel, +unsigned long long offset, +int size,const void *data);static errcode_t inode_read_blk64 (io_channel channel,unsigned long long block,int count,void *data); static errcode_t inode_write_blk64(io_channel channel,
@@ -75,7 +78,9 @@ static struct struct_io_manager struct_inode_manager = {NULL ,NULL , inode_read_blk64, - inode_write_blk64 + inode_write_blk64, +NULL , + inode_write_byte64, };io_manager inode_io_manager = &struct_inode_manager;
@@ -259,8 +264,9 @@ static errcode_t inode_write_blk(io_channel channel, unsigned long block,return inode_write_blk64 (channel, block, count, buf); } -static errcode_t inode_write_byte (io_channel channel,unsigned long offset, -int size,const void *buf) +static errcode_t inode_write_byte64 (io_channel channel, +unsigned long long offset, +int size,const void *buf) {struct inode_private_data *data;errcode_t retval =0 ;
@@ -276,6 +282,12 @@ static errcode_t inode_write_byte(io_channel channel, unsigned long offset,return ext2fs_file_write (data->file, buf, size,0 ); } +static errcode_t inode_write_byte (io_channel channel,unsigned long offset, +int size,const void *buf) +{ +return inode_write_byte64 (channel, offset, size, buf); +} +/* * Flush data buffers to disk. */
lib/ext2fs/io_manager.c +20 -0
@@ -69,6 +69,26 @@ errcode_t io_channel_write_byte(io_channel channel, unsigned long offset,return EXT2_ET_UNIMPLEMENTED ; } +errcode_t io_channel_write_byte64 (io_channel channel,unsigned long long offset, +int count,const void *data) +{ +EXT2_CHECK_MAGIC (channel,EXT2_ET_MAGIC_IO_CHANNEL ); + +if (channel->manager->write_byte64) +return channel->manager->write_byte64 (channel, offset, + count, data); + +if ((offset >>32 ) !=0 ) +return EXT2_ET_IO_CHANNEL_NO_SUPPORT_64 ; + +if (channel->manager->write_byte) +return channel->manager->write_byte (channel, offset, + count, data); + +return EXT2_ET_UNIMPLEMENTED ; +} + +errcode_t io_channel_read_blk64 (io_channel channel,unsigned long long block,int count,void *data) {
lib/ext2fs/test_io.c +32 -0
@@ -55,6 +55,8 @@ struct test_private_data {void (*write_byte)(unsigned long block,int count,errcode_t err);void (*read_blk64)(unsigned long long block,int count,errcode_t err);void (*write_blk64)(unsigned long long block,int count,errcode_t err); +void (*write_byte64)(unsigned long long block,int count, +errcode_t err); };static errcode_t test_open (const char *name,int flags,io_channel *channel);
@@ -71,6 +73,9 @@ static errcode_t test_write_blk64(io_channel channel, unsigned long long block,static errcode_t test_flush (io_channel channel);static errcode_t test_write_byte (io_channel channel,unsigned long offset,int count,const void *buf); +static errcode_t test_write_byte64 (io_channel channel, +unsigned long long offset, +int count,const void *buf);static errcode_t test_set_option (io_channel channel,const char *option,const char *arg);static errcode_t test_get_stats (io_channel channel,io_stats *stats);
@@ -92,6 +97,7 @@ static struct struct_io_manager struct_test_manager = { test_read_blk64, test_write_blk64, test_discard, + test_write_byte64, };io_manager test_io_manager = &struct_test_manager;
@@ -113,6 +119,8 @@ void (*test_io_cb_set_blksize) (int blksize, errcode_t err) = 0;void (*test_io_cb_write_byte) (unsigned long block,int count,errcode_t err) =0 ; +void (*test_io_cb_write_byte64) + (unsigned long long block,int count,errcode_t err) =0 ;/* * Test flags
@@ -222,6 +230,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) data->write_blk = test_io_cb_write_blk; data->set_blksize = test_io_cb_set_blksize; data->write_byte = test_io_cb_write_byte; + data->write_byte64 = test_io_cb_write_byte64; data->read_blk64 = test_io_cb_read_blk64; data->write_blk64 = test_io_cb_write_blk64;
@@ -418,6 +427,29 @@ static errcode_t test_write_blk64(io_channel channel, unsigned long long block,return retval; } +static errcode_t test_write_byte64 (io_channel channel, +unsigned long long offset, +int count,const void *buf) +{ +struct test_private_data *data; +errcode_t retval =0 ; + +EXT2_CHECK_MAGIC (channel,EXT2_ET_MAGIC_IO_CHANNEL ); + data = (struct test_private_data *) channel->private_data; +EXT2_CHECK_MAGIC (data,EXT2_ET_MAGIC_TEST_IO_CHANNEL ); + +if (data->real && data->real->manager->write_byte64) + retval =io_channel_write_byte64 (data->real, offset, + count, buf); +if (data->write_byte64) + data->write_byte64 (offset, count, retval); +if (data->flags &TEST_FLAG_WRITE ) +fprintf (data->outfile, +"Test_io: write_byte64(%llu, %d) returned %s\n" , + offset, count, retval ?error_message (retval) :"OK" ); +return retval; +} +static errcode_t test_write_byte (io_channel channel,unsigned long offset,int count,const void *buf) {
lib/ext2fs/unix_io.c +14 -3
@@ -107,6 +107,9 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block,static errcode_t unix_flush (io_channel channel);static errcode_t unix_write_byte (io_channel channel,unsigned long offset,int size,const void *data); +static errcode_t unix_write_byte64 (io_channel channel, +unsigned long long offset, +int size,const void *data);static errcode_t unix_set_option (io_channel channel,const char *option,const char *arg);static errcode_t unix_get_stats (io_channel channel,io_stats *stats)
@@ -135,6 +138,7 @@ static struct struct_io_manager struct_unix_manager = { unix_read_blk64, unix_write_blk64, unix_discard, + unix_write_byte64, };io_manager unix_io_manager = &struct_unix_manager;
@@ -834,8 +838,9 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block,return unix_write_blk64 (channel, block, count, buf); } -static errcode_t unix_write_byte (io_channel channel,unsigned long offset, -int size,const void *buf) +static errcode_t unix_write_byte64 (io_channel channel, +unsigned long long offset, +int size,const void *buf) {struct unix_private_data *data;errcode_t retval =0 ;
@@ -860,7 +865,7 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset,return retval;#endif -if (lseek (data->dev, offset + data->offset,SEEK_SET ) <0 ) +if (ext2fs_llseek (data->dev, offset + data->offset,SEEK_SET ) <0 )return errno; actual =write (data->dev, buf, size);
@@ -870,6 +875,12 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset,return 0 ; } +static errcode_t unix_write_byte (io_channel channel,unsigned long offset, +int size,const void *buf) +{ +return unix_write_byte64 (channel, offset, size, buf); +} +/* * Flush data buffers to disk. */
Signature · 1 line
1.7.7.6
PATCH 3/3 e2fsprogs: use libblkid to wipe old signatures
In reply to Lukas CzernerCurrently we only attempt to wipe old raid signatures at the end of the device. However this might not be enough because some file system (btrfs) may still have their signatures on the device which can be confusing for userspace possibly resulting in the unmountable file system.
This patch adds a function which uses libblkid library to wipe all the signatures from the device. In case that libblkid lack the capability to do so we still use the old method of wiping off raid signatures and new method of wiping btrfs signatures (originally written by Eric Sandeed).
We attempt to wipe off signatures before creating the file system. Information about existing signatures is printed only in verbose mode.
--- configure | 2 +- configure.in | 1 + lib/config.h.in | 3 + misc/mke2fs.c | 210 +++++++++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 178 insertions(+), 38 deletions(-)
configure +1 -1
@@ -11091,7 +11091,7 @@ if test "$ac_res" != no; then : fi fi -for ac_func in __secure_getenv backtrace blkid_probe_get_topology chflags fallocate fallocate64 fchown fdatasync fstat64 ftruncate64 getdtablesize getmntinfo getpwuid_r getrlimit getrusage jrand48 llseek lseek64 mallinfo mbstowcs memalign mmap msync nanosleep open64 pathconf posix_fadvise posix_memalign prctl setmntent setresgid setresuid srandom strcasecmp strdup strnlen strptime strtoull sync_file_range sysconf usleep utime valloc +for ac_func in __secure_getenv backtrace blkid_probe_get_topology blkid_probe_step_back chflags fallocate fallocate64 fchown fdatasync fstat64 ftruncate64 getdtablesize getmntinfo getpwuid_r getrlimit getrusage jrand48 llseek lseek64 mallinfo mbstowcs memalign mmap msync nanosleep open64 pathconf posix_fadvise posix_memalign prctl setmntent setresgid setresuid srandom strcasecmp strdup strnlen strptime strtoull sync_file_range sysconf usleep utime valloc do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
configure.in +1 -0
@@ -1053,6 +1053,7 @@ AC_CHECK_FUNCS(m4_flatten([ __secure_getenv backtrace blkid_probe_get_topology + blkid_probe_step_back chflags fallocate fallocate64
lib/config.h.in +3 -0
@@ -64,6 +64,9 @@ /* Define to 1 if you have the `blkid_probe_get_topology' function. */ #undef HAVE_BLKID_PROBE_GET_TOPOLOGY +/* Define to 1 if you have the `blkid_probe_step_back' function. */ +#undef HAVE_BLKID_PROBE_STEP_BACK + /* Define to 1 if you have the `chflags' function. */ #undef HAVE_CHFLAGS
misc/mke2fs.c +163 -32
243 lines not on this page · raw message
Quoted 11 lines · Lukas Czerner
Date: Fri, 8 Feb 2013 12:07:01 +0100
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], Lukas Czerner <[email protected]>
Subject: [PATCH 1/3] e2fsprogs: Build external libblkid by defaultThis commit changes configure script to build external libblkid library by default instead of building the local blkid. The reason is that the the external libblkid is where all the development takes place and it should be always preferred option. We still have an option '--enable-blkid' to enable local build of the blkid library.
As we've previously discussed I'll drop the series, however I think that this particular patch might be actually useful. What do you think Ted ?
(I might need to rebase this one)
Thanks!
-Lukas
Quoted 135 lines
Signed-off-by Lukas Czerner <[email protected]>--- configure | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--------- configure.in | 23 ++++++++++++--------- 2 files changed, 63 insertions(+), 20 deletions(-)configure +50
-10@@ -1497,7 +1497,7 @@ Optional Features: --enable-blkid-debug enable blkid debugging --disable-testio-debug disable the use of the test I/O manager for debugging --disable-libuuid do not build private uuid library - --disable-libblkid do not build private blkid library + --enable-libblkid build private blkid library --enable-quota enable quota support --disable-debugfs disable support of debugfs program --disable-imager disable support of e2image program@@ -5168,16 +5168,56 @@ $as_echo "Enabling private blkid library" >&6; } fi else - LIBBLKID='$(LIB)/libblkid'$LIB_EXT -DEPLIBBLKID=$LIBBLKID -STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT -DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID -PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT -DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID -$as_echo "#define CONFIG_BUILD_FINDFS 1" >>confdefs.h + if test -z "$PKG_CONFIG"; then + as_fn_error $? "pkg-config not installed; please install it." "$LINENO" 5 +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for blkid_get_cache in -lblkid" >&5 +$as_echo_n "checking for blkid_get_cache in -lblkid... " >&6; } +if ${ac_cv_lib_blkid_blkid_get_cache+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lblkid $LIBBLKID $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char blkid_get_cache (); +int +main () +{ +return blkid_get_cache (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_blkid_blkid_get_cache=yes +else + ac_cv_lib_blkid_blkid_get_cache=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blkid_blkid_get_cache" >&5 +$as_echo "$ac_cv_lib_blkid_blkid_get_cache" >&6; } +if test "x$ac_cv_lib_blkid_blkid_get_cache" = xyes; then : + LIBBLKID=`$PKG_CONFIG --libs blkid`; + STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid` +else + as_fn_error $? "external blkid library not found" "$LINENO" 5 +fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling private blkid library by default" >&5 -$as_echo "Enabling private blkid library by default" >&6; } +BLKID_CMT=# +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Disabling private blkid library by default" >&5 +$as_echo "Disabling private blkid library by default" >&6; } ficonfigure.in +13
-10@@ -509,7 +509,7 @@ AC_SUBST(PROFILED_LIBUUID) AC_SUBST(DEPPROFILED_LIBUUID) AC_SUBST(UUID_CMT) dnl -dnl handle --disable-libblkid +dnl handle --enable-libblkid dnl PKG_PROG_PKG_CONFIG LIBBLKID=@@ -521,7 +521,7 @@ DEPPROFILED_LIBBLKID= BLKID_CMT= AH_TEMPLATE([CONFIG_BUILD_FINDFS], [Define to 1 to compile findfs]) AC_ARG_ENABLE([libblkid], -[ --disable-libblkid do not build private blkid library], +[ --enable-libblkid build private blkid library], if test "$enableval" = "no" then if test -z "$PKG_CONFIG"; then@@ -546,14 +546,17 @@ else AC_MSG_RESULT([Enabling private blkid library]) fi , -LIBBLKID='$(LIB)/libblkid'$LIB_EXT -DEPLIBBLKID=$LIBBLKID -STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT -DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID -PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT -DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID -AC_DEFINE(CONFIG_BUILD_FINDFS, 1) -AC_MSG_RESULT([Enabling private blkid library by default]) +if test -z "$PKG_CONFIG"; then + AC_MSG_ERROR([pkg-config not installed; please install it.]) +fi + +AC_CHECK_LIB(blkid, blkid_get_cache, + [LIBBLKID=`$PKG_CONFIG --libs blkid`; + STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid`], + [AC_MSG_ERROR([external blkid library not found])], + [$LIBBLKID]) +BLKID_CMT=# +AC_MSG_RESULT([Disabling private blkid library by default]) ) AC_SUBST(LIBBLKID) AC_SUBST(DEPLIBBLKID)