Control: retitle -1 fuse2fs: please provide fuseext2 interface and transitional 
package to replace src:fuse-umfuse-ext2
Control: reassign -1 fuse2fs
Control: tags -1 = patch

As discussed on -devel, here's a patch that adds
  Package: fuse-ext2
  Build-Profiles: <!pkg.e2fsprogs.no-fuse2fs>
  Depends: fuse2fs (>= 1.47.1-2), ${misc:Depends}
  Section: oldlibs
  Description: transitional package
   This is a transitional package. It can safely be removed.
and makes fuse2fs
  Breaks: fuseext2 (<< 0.4-1.5~)
  Replaces: fuseext2 (<< 0.4-1.5~)
and adds
  /usr/bin/fuse-ext2
  /usr/share/man/man1/fuse-ext2.1
with appropriate links to provide a drop-in replacement
for fuseext2 0.4-1.5 from src:fuse-umfuse-ext2.

I expect the shell script to be functionally equivalent to the option parsing in
  https://sources.debian.org/src/fuse-umfuse-ext2/0.4-1.5/fuse-ext2/fuse-ext2.c/
and I'm also attaching an intermediate parser in C which I believe to be 
identical.
Not that I think it really matters if fuse-ext2 or fuse2fs rejects a
nonexistent image, so long as the ro/rw/rw+/force thing behaves the same,
which it does in both.

Users are encouraged to migrate to fuse2fs in both the manual
and the usage string.


$ debdiff fuse2fs_1.47.1-1_amd64.deb fuse2fs_1.47.1-2_amd64.deb
Files in second .deb but not in first
-------------------------------------
-rw-r--r--  root/root   /usr/share/man/man1/fuse-ext2.1.gz
-rwxr-xr-x  root/root   /usr/bin/fuse-ext2
lrwxrwxrwx  root/root   /usr/bin/fuseext2 -> fuse-ext2
lrwxrwxrwx  root/root   /usr/sbin/mount.fuse-ext2 -> ../bin/fuse-ext2
lrwxrwxrwx  root/root   /usr/sbin/mount.fuseext2 -> mount.fuse-ext2
lrwxrwxrwx  root/root   /usr/share/man/man1/fuseext2.1.gz -> fuse-ext2.1.gz
lrwxrwxrwx  root/root   /usr/share/man/man8/mount.fuse-ext2.8.gz -> 
../man1/fuse-ext2.1.gz
lrwxrwxrwx  root/root   /usr/share/man/man8/mount.fuseext2.8.gz -> 
mount.fuse-ext2.8.gz


$ debdiff fuseext2_0.4-1.5_amd64.deb fuse2fs_1.47.1-2_amd64.deb
Files in second .deb but not in first
-------------------------------------
-rw-r--r--  root/root   /usr/share/doc/fuse2fs/changelog.Debian.gz
-rw-r--r--  root/root   /usr/share/doc/fuse2fs/copyright
-rw-r--r--  root/root   /usr/share/man/man1/fuse2fs.1.gz
-rwxr-xr-x  root/root   /usr/bin/fuse2fs

Files in first .deb but not in second
-------------------------------------
-rw-r--r--  root/root   /usr/share/doc/fuseext2/AUTHORS
-rw-r--r--  root/root   /usr/share/doc/fuseext2/README
-rw-r--r--  root/root   /usr/share/doc/fuseext2/changelog.Debian.gz
-rw-r--r--  root/root   /usr/share/doc/fuseext2/changelog.gz
-rw-r--r--  root/root   /usr/share/doc/fuseext2/copyright
/** SPDX-License-Identifier: GPL-2.0-or-later
 * adapted from src:fuse-umfuse-ext2 0.4-1.5 fuse-ext2/fuse-ext2.c
 *
 * Copyright (c) 2008-2010 Alper Akcan <alper.ak...@gmail.com>
 * Copyright (c) 2009-2010 Renzo Davoli <re...@cs.unibo.it>
 */

#include <err.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <stdio.h>

static char * options;
static void append(const char * str) {
	if((options = realloc(options, strlen(options ?: "") + 1 + strlen(str) + 1))) {
		strcat(options, ",");
		strcat(options, str);
	}
}

enum sopt { SOPT_VERBATIM = -1, SOPT_RO, SOPT_RW, SOPT_RWPLUS, SOPT_DEBUG, SOPT_SILENT, SOPT_FORCE };
static char * const sopt[] = {[SOPT_RO]     = "ro",      //
                              [SOPT_RW]     = "rw",      //
                              [SOPT_RWPLUS] = "rw+",     //
                              [SOPT_DEBUG]  = "debug",   //
                              [SOPT_SILENT] = "silent",  //
                              [SOPT_FORCE]  = "force",   //
                              NULL};


static const struct option lopt[] = {{"options", required_argument, NULL, 'o'},  //
                                     {"help", no_argument, NULL, 'h'},
                                     {"verbose", no_argument, NULL, 'v'},
                                     {}};
int main(int argc, char ** argv) {
	bool debug = false, readonly = false, force = false;

	for(int c; (c = getopt_long(argc, argv, "o:hv", lopt, NULL)) != -1;)
		switch(c) {
			case 'o':
				append(optarg);
				break;
			case 'h':
			usage:
				printf("usage: %s [-hv] [-o ro|force|allow_others[,...]]... device|image mountpoint\n"
				       "\n"
				       "Use fuse2fs instead.\n",
				       argv[0]);
				return 9;
			case 'v':
				/*
				 * We must handle the 'verbose' option even if
				 * we don't use it because mount(8) passes it.
				 */
				debug = true;
				break;
			default:
				return -1;
		}

	if(argc != optind + 2)
		goto usage;
	const char * device = argv[optind];
	const char * mountpoint = argv[optind + 1];

	if(access(device, F_OK))
		err(-3, "%s", device);


	char * original_options = options ? options + 1 : "";
	options                 = NULL;
	char * val;

	for(enum sopt o; *original_options && (o = getsubopt(&original_options, sopt, &val));) {
		printf("%p\n", val);
		printf("%d != %d\n", o , SOPT_VERBATIM);
		if(val && o != SOPT_VERBATIM)
			errx(-2, "%s: value given but not allowed", sopt[o]);

		switch(o) {
			case SOPT_RO: /* Read-only mount. */
				readonly = true;
				break;
			case SOPT_RW: /* Read-write mount */
				readonly = false;
				break;
			case SOPT_RWPLUS: /* Read-write mount */
				readonly = false;
				force    = true;
				break;
			case SOPT_DEBUG: /* enable debug */
				debug = true;
				append("debug");
				break;
			case SOPT_SILENT: /* keep silent */
				// no-op in this implementation
				break;
			case SOPT_FORCE: /* enable read/write */
				force = true;
				break;
			case SOPT_VERBATIM: /* Probably FUSE option. */
				append(val);
				break;
		}
	}

	if(!readonly && !force) {
		warnx("Mounting %s Read-Only. Use \'force\' or \'rw+\' options to enable Read-Write mode", device);
		readonly = true;
	}


	append(readonly ? "ro" : "rw");
	execl("/usr/bin/fuse2fs", "fuse2fs", device, mountpoint, "-o", options ? options + 1 : "", (char *)NULL);
	err(-5, "fuse2fs");
}
From c4e0dcc8a3cea7a8f74251ec93611a92008b764f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczlew...@nabijaczleweli.xyz>
Date: Thu, 24 Oct 2024 13:57:11 +0200
Subject: [PATCH] debian: provide fuse-ext2 in fuse2fs. add fuseext2
 transitional package (Closes: #1085590)
X-Mutt-PGP: OS

---
 debian/control         | 11 +++++++
 debian/copyright       | 40 +++++++++++++++++++++++++
 debian/fuse-ext2       | 65 ++++++++++++++++++++++++++++++++++++++++
 debian/fuse-ext2.1     | 67 ++++++++++++++++++++++++++++++++++++++++++
 debian/fuse2fs.install |  3 ++
 debian/fuse2fs.links   |  7 +++++
 6 files changed, 193 insertions(+)
 create mode 100755 debian/fuse-ext2
 create mode 100644 debian/fuse-ext2.1
 create mode 100644 debian/fuse2fs.links

diff --git a/debian/control b/debian/control
index e641b371..bc582cd8 100644
--- a/debian/control
+++ b/debian/control
@@ -13,12 +13,23 @@ Package: fuse2fs
 Build-Profiles: <!pkg.e2fsprogs.no-fuse2fs>
 Priority: optional
 Depends: ${shlibs:Depends}, ${misc:Depends}
+Breaks: fuseext2 (<< 1.47.1-2~)
+Replaces: fuseext2 (<< 1.47.1-2~)
 Architecture: linux-any kfreebsd-any
 Description: ext2 / ext3 / ext4 file system driver for FUSE
  fuse2fs is a FUSE file system client that supports reading and
  writing from devices or image files containing ext2, ext3, and ext4
  file systems.
 
+Package: fuseext2
+Build-Profiles: <!pkg.e2fsprogs.no-fuse2fs>
+Depends: fuse2fs (>= 1.47.1-2), ${misc:Depends}
+Architecture: all
+Priority: optional
+Section: oldlibs
+Description: transitional package
+ This is a transitional package. It can safely be removed.
+
 Package: logsave
 Priority: optional
 Depends: ${shlibs:Depends}, ${misc:Depends}
diff --git a/debian/copyright b/debian/copyright
index 77bd5ea1..1619b1f3 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -21,6 +21,15 @@ Copyright: 2003-2007 Theodore Ts'o <ty...@mit.edu>
            1995-1996 Michael Nonweiler <mr...@cam.ac.uk>
 License: GPL-2
 
+Files: debian/fuse-ext2
+Copyright: 2008-2010 Alper Akcan <alper.ak...@gmail.com>
+           2009-2010 Renzo Davoli <re...@cs.unibo.it>
+License: GPL-2+
+
+Files: debian/fuse-ext2.1
+Copyright: 2024 наб <nabijaczlew...@nabijaczleweli.xyz>
+License: 0BSD
+
 Files: lib/et/*
        lib/ss/*
 Copyright: 1987-1988 MIT Student Information Processing Board
@@ -471,6 +480,37 @@ Comment:
  On Debian systems, the complete text of the GNU General
  Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
 
+License: GPL-2+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program (in the main directory of the fuse-ext2
+ distribution in the file COPYING); if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+Comment:
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
+
+License: 0BSD
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
 License: LGPL-2
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public License as
diff --git a/debian/fuse-ext2 b/debian/fuse-ext2
new file mode 100755
index 00000000..ebd3b8a5
--- /dev/null
+++ b/debian/fuse-ext2
@@ -0,0 +1,65 @@
+#!/bin/sh
+usage() {
+	printf 'usage: %s [-hv] [-o ro|force|allow_others[,...]]... device|image mountpoint\n\nUse fuse2fs instead.\n' "${0##*/}"
+	exit 9
+}
+
+args="$(getopt -o 'hvo:' --long 'help,verbose,options:' -n "${0##*/}" -s 'sh' -- "$@")" || exit
+eval set -- "$args"
+
+original_options=
+readonly=
+force=
+while :; do
+	case "$1" in
+		-o|--options)
+			original_options="$original_options,$2"
+			shift 2
+			;;
+		-h|--help)
+			usage
+			shift
+			;;
+		-v|--verbose)
+			shift
+			;;
+		--)
+			shift
+			break
+			;;
+	esac
+done
+
+[ $# -eq 2 ] || usage
+device="$1"
+mountpoint="$2"
+
+# let fuse2fs check $device
+
+options=
+while [ -n "${original_options#,}" ]; do
+	original_options="${original_options#,}"
+	full="${original_options%%,*}"
+	original_options="${original_options#*,},"
+	case "${full%%=*}" in
+		"ro"    ) readonly=y               ;;  # Read-only mount.
+		"rw"    ) readonly=                ;;  # Read-write mount
+		"rw+"   ) readonly=; force=y       ;;  # Read-write mount
+		"silent")                          ;;  # keep silent
+		"force" ) force=y                  ;;  # enable read/write
+		*       ) options="$options,$full"; continue ;;
+	esac
+	[ "$full" = "${full%=*}" ] || {
+		printf '%s: %s: value given but not allowed\n' "${0##*/}" "$full" >&2
+		exit 254
+	}
+done
+
+[ -z "$readonly" ] && [ -z "$force" ] && {
+	printf '%s: Mounting %s Read-Only. Use '\''force'\'' or '\''rw+'\'' options to enable Read-Write mode\n' "${0##*/}" "$device" >&2
+	readonly=y
+}
+
+[ -n "$readonly" ] && options="$options,ro" || options="$options,rw"
+
+exec /usr/bin/fuse2fs "$device" "$mountpoint" -o "${options#,}"
diff --git a/debian/fuse-ext2.1 b/debian/fuse-ext2.1
new file mode 100644
index 00000000..b24ab56e
--- /dev/null
+++ b/debian/fuse-ext2.1
@@ -0,0 +1,67 @@
+.\" SPDX-License-Identifier: 0BSD
+.\"
+.Dd October 24, 2024
+.Dt FUSE-EXT2 1
+.Os fuse2fs
+.
+.Sh NAME
+.Nm fuse-ext2
+.Nd fuse2fs compatibility wrapper
+.Sh SYNOPSIS
+.Nm
+.Op Fl hv
+.Oo Fl o Cm ro Ns \&| Ns Cm force Ns \&| Ns Cm allow_others Ns Oo ,… Oc Oc Ns …
+.Ar device Ns \&| Ns Ar image
+.Ar mountpoint
+.
+.Sh DESCRIPTION
+This wrapper provides the
+.Nm
+interface via
+.Xr fuse2fs 1 ,
+which you should migrate to instead.
+.
+.Sh OPTIONS
+.Bl -tag -compact -width ".Fl o , -options Ar option Ns Op ,…"
+.It Fl h , -help
+Show usage string.
+.
+.It Fl v , -verbose
+Ignored.
+.
+.It Fl o , -options Ar option Ns Op ,…
+.Xr mount.fuse3 8
+options, of which these are handled specially:
+.Bl -tag -compact -offset 4n -width ".Cm silent"
+.It Cm ro
+Mount read-only.
+.
+.It Cm rw
+Mount read-write
+.Em if
+.Cm force
+also given.
+This is the default.
+.
+.It Cm rw+
+Same as
+.Fl o Cm rw , Ns Cm force
+.It Cm silent
+Ignored.
+.It Cm force
+If
+.Cm rw ,
+mount read-write.
+.El
+all other
+.Ar option Ns s
+are forwarded to
+.Nm fuse2fs
+directly.
+.Pp
+If
+.Cm rw
+but not
+.Cm force ,
+the mount is read-only and a warning is issued.
+.El
diff --git a/debian/fuse2fs.install b/debian/fuse2fs.install
index 2ed4c3c0..5ff8792d 100644
--- a/debian/fuse2fs.install
+++ b/debian/fuse2fs.install
@@ -1,2 +1,5 @@
 /usr/bin/fuse2fs
 /usr/share/man/man1/fuse2fs.1
+
+debian/fuse-ext2   /usr/bin/
+debian/fuse-ext2.1 /usr/share/man/man1/
diff --git a/debian/fuse2fs.links b/debian/fuse2fs.links
new file mode 100644
index 00000000..71cb0b6b
--- /dev/null
+++ b/debian/fuse2fs.links
@@ -0,0 +1,7 @@
+/usr/bin/fuse-ext2        /usr/bin/fuseext2
+/usr/bin/fuse-ext2        /usr/sbin/mount.fuse-ext2
+/usr/sbin/mount.fuse-ext2 /usr/sbin/mount.fuseext2
+
+/usr/share/man/man1/fuse-ext2.1       /usr/share/man/man1/fuseext2.1
+/usr/share/man/man1/fuse-ext2.1       /usr/share/man/man8/mount.fuse-ext2.8
+/usr/share/man/man8/mount.fuse-ext2.8 /usr/share/man/man8/mount.fuseext2.8
-- 
2.39.2

Attachment: signature.asc
Description: PGP signature

Reply via email to