mkfs.f2fs: check filesystem overwrite before formatting
PATCH 1/1 mkfs.f2fs: check filesystem overwrite before formatting
Mkfs.f2fs doesn't check the overwrite of exist filesystem. Avoid formatting an exist filesystem by mistake, a notice is important. The code is modified from xfsprogs.
Signed-off-by Kinglong Mee <[email protected]>
--- configure.ac | 20 +++++++++-- mkfs/Makefile.am | 4 +-- mkfs/f2fs_format_main.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 108 insertions(+), 5 deletions(-)
configure.ac +18 -2
@@ -48,8 +48,11 @@ AC_CHECK_HEADERS_ONCE([ # Test configure options. AC_ARG_WITH([selinux], AS_HELP_STRING([--without-selinux], - [Ignore presence of libselinux and disable selinux support]) -) + [Ignore presence of libselinux and disable selinux support])) + +AC_ARG_WITH([blkid], + AS_HELP_STRING([--without-blkid], + [Ignore presence of libblkid and disable blkid support])) # Checks for programs. AC_PROG_CC
@@ -74,6 +77,19 @@ AS_IF([test "x$have_selinux" = "xyes"], )] ) +AS_IF([test "x$with_blkid" != "xno"], + [PKG_CHECK_MODULES([libblkid], [blkid], + [have_blkid=yes], [have_blkid=no])], + [have_blkid=no] +) + +AS_IF([test "x$have_blkid" = "xyes"], + [AC_DEFINE([HAVE_LIBBLKID], [1], [Use blkid])], + [AS_IF([test "x$with_blkid" = "xyes"], + [AC_MSG_ERROR([blkid support requested but libblkid not found])] + )] +) + # Checks for header files. AC_CHECK_HEADERS([linux/fs.h linux/blkzoned.h fcntl.h mntent.h stdlib.h string.h \ sys/ioctl.h sys/mount.h unistd.h linux/falloc.h byteswap.h])
mkfs/Makefile.am +2 -2
@@ -1,10 +1,10 @@ ## Makefile.am -AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include +AM_CPPFLAGS = ${libuuid_CFLAGS} ${libblkid_CFLAGS} -I$(top_srcdir)/include AM_CFLAGS = -Wall -DWITH_BLKDISCARD sbin_PROGRAMS = mkfs.f2fs mkfs_f2fs_SOURCES = f2fs_format_main.c f2fs_format.c f2fs_format_utils.c f2fs_format_utils.h $(top_srcdir)/include/f2fs_fs.h -mkfs_f2fs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la +mkfs_f2fs_LDADD = ${libuuid_LIBS} ${libblkid_LIBS} $(top_builddir)/lib/libf2fs.la lib_LTLIBRARIES = libf2fs_format.la libf2fs_format_la_SOURCES = f2fs_format_main.c f2fs_format.c f2fs_format_utils.c
mkfs/f2fs_format_main.c +88 -1
123 lines not on this page · raw message
Signature · 6 lines
2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot