mkfs.f2fs: check overwrite before make filesystem
PATCH v3 2/2 mkfs.f2fs: check overwrite before make filesystem
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.
v3, add the missing update of SYNOPSIS
v2, add the manpages description of -f.
Signed-off-by Kinglong Mee <[email protected]>
--- configure.ac | 20 +++++++++-- man/mkfs.f2fs.8 | 8 +++++ mkfs/Makefile.am | 4 +-- mkfs/f2fs_format_main.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 117 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])
man/mkfs.f2fs.8 +8 -0
@@ -24,6 +24,9 @@ mkfs.f2fs \- create an F2FS file system .I extension-list ] [ +.B \-f +] +[ .B \-l .I volume-label ]
@@ -87,6 +90,11 @@ The data of files having those extensions will be stored to the cold log. The default list includes most of multimedia file extensions such as jpg, gif, mpeg, mkv, and so on. .TP +.BI \-f +Force overwrite when an existing filesystem is detected on the device. +By default, mkfs.f2fs will not write to the device if it suspects that +there is a filesystem or partition table on the device already. +.TP .BI \-l " volume-label" Specify the volume label to the partition mounted as F2FS. .TP
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 +89 -1
130 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