This WIP update to the latest revision adds fuse2fs(1), which is
a fuse(4) client for ext2/ext3/ext4.  At the moment this
tool is effectively a read-only mount.  I can read files with it,
and use mkdir to create new directories, but normal files are not
writeable, from my testing on amd64.  The behaviour is the same on
all three filesystems, except the fuse2fs mount warns that the
journal will not be written when you mount either an ext3 or ext4
filesystem.

My patch to misc/fuse2fs.c replaces the undefined FUSE_MAKE_VERSION
tests but my interpretation may be incorrect, so I may be the cause
of the operational issue noted above..

Additionally, my patches to lib/ext2fs/imager.c and misc/e2fuzz.c
revise loff_t to off_t -- as loff_t is not defined in sys/types.h.
This may not be an appropriate solution.

Comments, recommendations, and cluebats welcome.
diff --git a/sysutils/e2fsprogs/patches/patch-doc_Makefile_in 
b/sysutils/e2fsprogs/patches/patch-doc_Makefile_in
index cb9ae719e8a..948ad6160fd 100644
--- a/sysutils/e2fsprogs/patches/patch-doc_Makefile_in
+++ b/sysutils/e2fsprogs/patches/patch-doc_Makefile_in
@@ -1,6 +1,7 @@
 $OpenBSD: patch-doc_Makefile_in,v 1.4 2014/04/30 11:40:04 ajacoutot Exp $
---- doc/Makefile.in.orig       Sun Dec 29 05:18:02 2013
-+++ doc/Makefile.in    Wed Apr 30 10:36:56 2014
+Index: doc/Makefile.in
+--- doc/Makefile.in.orig
++++ doc/Makefile.in
 @@ -17,9 +17,9 @@ INFO=@MAKEINFO@
  HTML=makeinfo --html --no-split
  PS2PDF=ps2pdf
@@ -11,14 +12,14 @@ $OpenBSD: patch-doc_Makefile_in,v 1.4 2014/04/30 11:40:04 
ajacoutot Exp $
 -install-doc-libs: libext2fs.info libext2fs.dvi
 +install-doc-libs: libext2fs.info
        $(Q) $(RM) -rf $(DESTDIR)$(infodir)/libext2fs.info*
-       $(E) "  MKINSTALLDIRS $(infodir)"
-       $(Q) $(MKINSTALLDIRS) $(DESTDIR)$(infodir)
+       $(E) "  MKDIR_P $(infodir)"
+       $(Q) $(MKDIR_P) $(DESTDIR)$(infodir)
 @@ -27,8 +27,6 @@ install-doc-libs: libext2fs.info libext2fs.dvi
                echo "  INSTALL_DATA $(infodir)/$$i" ; \
                $(INSTALL_DATA) $$i $(DESTDIR)$(infodir)/$$i ; \
        done
 -      $(E) "  GZIP $(infodir)/libext2fs.info*"
--      -$(Q) gzip -9 $(DESTDIR)$(infodir)/libext2fs.info*
+-      -$(Q) gzip -9n $(DESTDIR)$(infodir)/libext2fs.info*
  
  uninstall-doc-libs:
        $(RM) -rf $(DESTDIR)$(infodir)/libext2fs.info*
diff --git a/sysutils/e2fsprogs/patches/patch-lib_Makefile_elf-lib 
b/sysutils/e2fsprogs/patches/patch-lib_Makefile_elf-lib
index 23245203bc5..79c5db0e331 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_Makefile_elf-lib
+++ b/sysutils/e2fsprogs/patches/patch-lib_Makefile_elf-lib
@@ -3,8 +3,9 @@ $OpenBSD: patch-lib_Makefile_elf-lib,v 1.7 2013/06/21 22:35:51 
sthen Exp $
 Don't generate library symlinks.
 Don't run ldconfig.
 
---- lib/Makefile.elf-lib.orig  Wed Aug 15 21:43:55 2012
-+++ lib/Makefile.elf-lib       Wed Jun 19 14:25:04 2013
+Index: lib/Makefile.elf-lib
+--- lib/Makefile.elf-lib.orig
++++ lib/Makefile.elf-lib
 @@ -32,7 +32,6 @@ $(ELF_LIB): $(OBJS)
        $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \
                `echo $(my_dir) | sed -e 's;lib/;;'`/$(ELF_LIB) $(ELF_LIB))
@@ -12,7 +13,7 @@ Don't run ldconfig.
 -      $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) $(ELF_LIB) $(ELF_SONAME))
  
  installdirs-elf-lib::
-       $(E) "  MKINSTALLDIRS $(ELF_INSTALL_DIR) $(libdir)"
+       $(E) "  MKDIR_P $(ELF_INSTALL_DIR) $(libdir)"
 @@ -44,14 +43,6 @@ installdirs:: installdirs-elf-lib
  install-shlibs install:: $(ELF_LIB) installdirs-elf-lib $(DEP_INSTALL_SYMLINK)
        $(E) "  INSTALL-ELF-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
diff --git a/sysutils/e2fsprogs/patches/patch-lib_blkid_getsize_c 
b/sysutils/e2fsprogs/patches/patch-lib_blkid_getsize_c
index 83626d1612b..ea35bcf592d 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_blkid_getsize_c
+++ b/sysutils/e2fsprogs/patches/patch-lib_blkid_getsize_c
@@ -1,7 +1,8 @@
 $OpenBSD: patch-lib_blkid_getsize_c,v 1.3 2014/11/08 11:28:04 sthen Exp $
---- lib/blkid/getsize.c.orig   Sat Aug  2 21:26:22 2014
-+++ lib/blkid/getsize.c        Sat Nov  8 10:41:17 2014
-@@ -25,6 +25,7 @@
+Index: lib/blkid/getsize.c
+--- lib/blkid/getsize.c.orig
++++ lib/blkid/getsize.c
+@@ -29,6 +29,7 @@
  #include <fcntl.h>
  #ifdef HAVE_SYS_IOCTL_H
  #include <sys/ioctl.h>
diff --git a/sysutils/e2fsprogs/patches/patch-lib_e2p_Makefile_in 
b/sysutils/e2fsprogs/patches/patch-lib_e2p_Makefile_in
index 1840bb582a9..0de426472bd 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_e2p_Makefile_in
+++ b/sysutils/e2fsprogs/patches/patch-lib_e2p_Makefile_in
@@ -1,7 +1,8 @@
 $OpenBSD: patch-lib_e2p_Makefile_in,v 1.3 2013/06/21 22:35:51 sthen Exp $
---- lib/e2p/Makefile.in.orig   Fri Sep 21 17:30:42 2012
-+++ lib/e2p/Makefile.in        Wed Jun 19 14:25:06 2013
-@@ -34,8 +34,8 @@ HFILES= e2p.h
+Index: lib/e2p/Makefile.in
+--- lib/e2p/Makefile.in.orig
++++ lib/e2p/Makefile.in
+@@ -36,8 +36,8 @@ HFILES= e2p.h
  LIBRARY= libe2p
  LIBDIR= e2p
  
diff --git a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_Makefile_in 
b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_Makefile_in
index 1a49f34b164..173e65e3ec0 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_Makefile_in
+++ b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_Makefile_in
@@ -1,7 +1,8 @@
 $OpenBSD: patch-lib_ext2fs_Makefile_in,v 1.6 2014/11/08 11:28:04 sthen Exp $
---- lib/ext2fs/Makefile.in.orig        Sat Aug  2 21:26:22 2014
-+++ lib/ext2fs/Makefile.in     Sat Nov  8 10:41:17 2014
-@@ -203,8 +203,8 @@ HFILES_IN=  ext2_err.h ext2_types.h
+Index: lib/ext2fs/Makefile.in
+--- lib/ext2fs/Makefile.in.orig
++++ lib/ext2fs/Makefile.in
+@@ -233,8 +233,8 @@ HFILES_IN=  ext2_err.h ext2_types.h
  LIBRARY= libext2fs
  LIBDIR= ext2fs
  
diff --git a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_blkmap64_rb_c 
b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_blkmap64_rb_c
index 8a4043a6e33..b1ecb13a54d 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_blkmap64_rb_c
+++ b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_blkmap64_rb_c
@@ -1,7 +1,8 @@
 $OpenBSD: patch-lib_ext2fs_blkmap64_rb_c,v 1.1 2016/09/10 13:03:43 ajacoutot 
Exp $
---- lib/ext2fs/blkmap64_rb.c.orig      Sat Sep 10 12:30:47 2016
-+++ lib/ext2fs/blkmap64_rb.c   Sat Sep 10 12:31:10 2016
-@@ -15,6 +15,7 @@
+Index: lib/ext2fs/blkmap64_rb.c
+--- lib/ext2fs/blkmap64_rb.c.orig
++++ lib/ext2fs/blkmap64_rb.c
+@@ -16,6 +16,7 @@
  #include <unistd.h>
  #endif
  #include <fcntl.h>
diff --git a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_ext2_fs_h 
b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_ext2_fs_h
index 0c19a2ff8a4..e921db557ce 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_ext2_fs_h
+++ b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_ext2_fs_h
@@ -1,7 +1,8 @@
 $OpenBSD: patch-lib_ext2fs_ext2_fs_h,v 1.1 2016/03/28 20:08:56 kili Exp $
---- lib/ext2fs/ext2_fs.h.orig  Sat Aug  2 22:26:22 2014
-+++ lib/ext2fs/ext2_fs.h       Tue Mar 22 22:26:56 2016
-@@ -344,6 +344,7 @@ struct ext4_new_group_input {
+Index: lib/ext2fs/ext2_fs.h
+--- lib/ext2fs/ext2_fs.h.orig
++++ lib/ext2fs/ext2_fs.h
+@@ -374,6 +374,7 @@ struct ext4_new_group_input {
  #define _IOT_ext2_new_group_input _IOT (_IOTS(__u32), 5, _IOTS(__u16), 2, 0, 
0)
  #endif
  
@@ -9,7 +10,7 @@ $OpenBSD: patch-lib_ext2fs_ext2_fs_h,v 1.1 2016/03/28 20:08:56 
kili Exp $
  #define EXT2_IOC_GETFLAGS             _IOR('f', 1, long)
  #define EXT2_IOC_SETFLAGS             _IOW('f', 2, long)
  #define EXT2_IOC_GETVERSION           _IOR('v', 1, long)
-@@ -354,6 +355,7 @@ struct ext4_new_group_input {
+@@ -384,6 +385,7 @@ struct ext4_new_group_input {
  #define EXT2_IOC_GROUP_ADD            _IOW('f', 8,struct ext2_new_group_input)
  #define EXT4_IOC_GROUP_ADD            _IOW('f', 8,struct ext4_new_group_input)
  #define EXT4_IOC_RESIZE_FS            _IOW('f', 16, __u64)
diff --git a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_imager_c 
b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_imager_c
new file mode 100644
index 00000000000..5f0f0772073
--- /dev/null
+++ b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_imager_c
@@ -0,0 +1,14 @@
+$OpenBSD$
+loff_t is not in sys/types.h
+Index: lib/ext2fs/imager.c
+--- lib/ext2fs/imager.c.orig
++++ lib/ext2fs/imager.c
+@@ -67,7 +67,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int
+       blk64_t         blk;
+       ssize_t         actual;
+       errcode_t       retval;
+-      loff_t          r;
++      off_t           r;
+ 
+       buf = malloc(fs->blocksize * BUF_BLOCKS);
+       if (!buf)
diff --git a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_unix_io_c 
b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_unix_io_c
index 0854b3c6442..24e389e27f4 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_ext2fs_unix_io_c
+++ b/sysutils/e2fsprogs/patches/patch-lib_ext2fs_unix_io_c
@@ -1,11 +1,12 @@
 $OpenBSD: patch-lib_ext2fs_unix_io_c,v 1.2 2013/06/21 22:35:51 sthen Exp $
---- lib/ext2fs/unix_io.c.orig  Wed Jan  2 00:47:20 2013
-+++ lib/ext2fs/unix_io.c       Wed Jun 19 14:25:04 2013
-@@ -39,6 +39,7 @@
+Index: lib/ext2fs/unix_io.c
+--- lib/ext2fs/unix_io.c.orig
++++ lib/ext2fs/unix_io.c
+@@ -51,6 +51,7 @@
  #include <sys/ioctl.h>
  #endif
  #ifdef HAVE_SYS_MOUNT_H
 +#include <sys/param.h>
  #include <sys/mount.h>
  #endif
- #if HAVE_SYS_STAT_H
+ #ifdef HAVE_SYS_PRCTL_H
diff --git a/sysutils/e2fsprogs/patches/patch-lib_support_mkquota_c 
b/sysutils/e2fsprogs/patches/patch-lib_support_mkquota_c
new file mode 100644
index 00000000000..00f13664f73
--- /dev/null
+++ b/sysutils/e2fsprogs/patches/patch-lib_support_mkquota_c
@@ -0,0 +1,11 @@
+$OpenBSD:$
+--- lib/support/mkquota.c.orig Wed Jan  2 00:47:20 2013
++++ lib/support/mkquota.c      Wed Jun 19 14:25:04 2013
+@@ -7,6 +7,7 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
++#include <stdint.h>
+ #include <errno.h>
+ #include <string.h>
+ #include <fcntl.h>
diff --git a/sysutils/e2fsprogs/patches/patch-lib_uuid_gen_uuid_c 
b/sysutils/e2fsprogs/patches/patch-lib_uuid_gen_uuid_c
index b80e5d59fc7..31f8a5ad176 100644
--- a/sysutils/e2fsprogs/patches/patch-lib_uuid_gen_uuid_c
+++ b/sysutils/e2fsprogs/patches/patch-lib_uuid_gen_uuid_c
@@ -1,6 +1,7 @@
 $OpenBSD: patch-lib_uuid_gen_uuid_c,v 1.1 2014/11/10 20:38:50 sthen Exp $
---- lib/uuid/gen_uuid.c.orig   Sat Nov  8 10:51:53 2014
-+++ lib/uuid/gen_uuid.c        Sat Nov  8 11:12:57 2014
+Index: lib/uuid/gen_uuid.c
+--- lib/uuid/gen_uuid.c.orig
++++ lib/uuid/gen_uuid.c
 @@ -167,8 +167,17 @@ static int get_random_fd(void)
        return fd;
  }
@@ -28,7 +29,7 @@ $OpenBSD: patch-lib_uuid_gen_uuid_c,v 1.1 2014/11/10 20:38:50 
sthen Exp $
  
  /*
   * Get the ethernet hardware address, if we can find it...
-@@ -663,7 +673,17 @@ void uuid_generate_random(uuid_t out)
+@@ -679,7 +689,17 @@ void uuid_generate_random(uuid_t out)
  }
  
  
@@ -46,7 +47,7 @@ $OpenBSD: patch-lib_uuid_gen_uuid_c,v 1.1 2014/11/10 20:38:50 
sthen Exp $
   * This is the generic front-end to uuid_generate_random and
   * uuid_generate_time.  It uses uuid_generate_random only if
   * /dev/urandom is available, since otherwise we won't have
-@@ -676,3 +696,4 @@ void uuid_generate(uuid_t out)
+@@ -692,3 +712,4 @@ void uuid_generate(uuid_t out)
        else
                uuid_generate_time(out);
  }
diff --git a/sysutils/e2fsprogs/patches/patch-misc_e2fuzz_c 
b/sysutils/e2fsprogs/patches/patch-misc_e2fuzz_c
new file mode 100644
index 00000000000..fd4357dc675
--- /dev/null
+++ b/sysutils/e2fsprogs/patches/patch-misc_e2fuzz_c
@@ -0,0 +1,17 @@
+$OpenBSD$
+loff_t not in sys/types.h
+Index: misc/e2fuzz.c
+--- misc/e2fuzz.c.orig
++++ misc/e2fuzz.c
+@@ -181,9 +181,9 @@ static int process_fs(const char *fsname)
+       int flags, fd;
+       ext2_filsys fs = NULL;
+       ext2fs_block_bitmap corrupt_map;
+-      loff_t hsize, count, off, offset, corrupt_bytes;
++      off_t hsize, count, off, offset, corrupt_bytes;
+       unsigned char c;
+-      loff_t i;
++      off_t i;
+ 
+       /* If mounted rw, force dryrun mode */
+       ret = ext2fs_check_if_mounted(fsname, &flags);
diff --git a/sysutils/e2fsprogs/patches/patch-misc_fsck_8_in 
b/sysutils/e2fsprogs/patches/patch-misc_fsck_8_in
index 3eaa13b7d50..9f939b1b6aa 100644
--- a/sysutils/e2fsprogs/patches/patch-misc_fsck_8_in
+++ b/sysutils/e2fsprogs/patches/patch-misc_fsck_8_in
@@ -1,10 +1,11 @@
 $OpenBSD: patch-misc_fsck_8_in,v 1.3 2013/06/21 22:35:51 sthen Exp $
---- misc/fsck.8.in.orig        Thu Aug 13 02:39:57 2009
-+++ misc/fsck.8.in     Wed Jun 19 14:25:04 2013
+Index: misc/fsck.8.in
+--- misc/fsck.8.in.orig
++++ misc/fsck.8.in
 @@ -2,11 +2,11 @@
  .\" Copyright 1993, 1994, 1995 by Theodore Ts'o.  All Rights Reserved.
  .\" This file may be copied under the terms of the GNU Public License.
- .\" 
+ .\"
 -.TH FSCK 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version 
@E2FSPROGS_VERSION@"
 +.TH PFSCK 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version 
@E2FSPROGS_VERSION@"
  .SH NAME
diff --git a/sysutils/e2fsprogs/patches/patch-misc_fuse2fs_c 
b/sysutils/e2fsprogs/patches/patch-misc_fuse2fs_c
new file mode 100644
index 00000000000..f4897efd95c
--- /dev/null
+++ b/sysutils/e2fsprogs/patches/patch-misc_fuse2fs_c
@@ -0,0 +1,55 @@
+$OpenBSD$
+FUSE_MAKE_VERSION undefined
+Index: misc/fuse2fs.c
+--- misc/fuse2fs.c.orig
++++ misc/fuse2fs.c
+@@ -72,7 +72,7 @@ static ext2_filsys global_fs; /* Try not to use this d
+ # define dbg_printf(f, a...)
+ #endif
+ 
+-#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
++#if FUSE_VERSION >= 28
+ # ifdef _IOR
+ #  ifdef _IOW
+ #   define SUPPORT_I_FLAGS
+@@ -3255,7 +3255,7 @@ static int ioctl_fitrim(ext2_filsys fs, struct fuse2fs
+ }
+ #endif /* FITRIM */
+ 
+-#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
++#if FUSE_VERSION >= 28
+ static int op_ioctl(const char *path EXT2FS_ATTR((unused)), int cmd,
+                   void *arg EXT2FS_ATTR((unused)),
+                   struct fuse_file_info *fp,
+@@ -3332,7 +3332,7 @@ out:
+       return ret;
+ }
+ 
+-#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 9)
++#if FUSE_VERSION >= 29
+ # ifdef SUPPORT_FALLOCATE
+ static int fallocate_helper(struct fuse_file_info *fp, int mode, off_t offset,
+                           off_t len)
+@@ -3603,7 +3603,7 @@ static struct fuse_operations fs_ops = {
+       .ftruncate = op_ftruncate,
+       .fgetattr = op_fgetattr,
+       .utimens = op_utimens,
+-#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 9)
++#if FUSE_VERSION >= 29
+ # if defined(UTIME_NOW) || defined(UTIME_OMIT)
+       .flag_utime_omit_ok = 1,
+ # endif
+@@ -3613,11 +3613,11 @@ static struct fuse_operations fs_ops = {
+       .lock = op_lock,
+       .poll = op_poll,
+ #endif
+-#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
++#if FUSE_VERSION >= 28
+       .ioctl = op_ioctl,
+       .flag_nullpath_ok = 1,
+ #endif
+-#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 9)
++#if FUSE_VERSION >= 29
+       .flag_nopath = 1,
+ # ifdef SUPPORT_FALLOCATE
+       .fallocate = op_fallocate,

Reply via email to