summaryrefslogtreecommitdiff
path: root/sys-fs
diff options
context:
space:
mode:
authorRoy Marples <uberlord@gentoo.org>2007-09-15 08:54:26 +0000
committerRoy Marples <uberlord@gentoo.org>2007-09-15 08:54:26 +0000
commit6f64934cee09cc3c414cc1670040c4d638e34ce6 (patch)
tree0a98348f00b3fad22b4738a0a9a228bcedfb573a /sys-fs
parentfix #192289 (diff)
downloadgentoo-2-6f64934cee09cc3c414cc1670040c4d638e34ce6.tar.gz
gentoo-2-6f64934cee09cc3c414cc1670040c4d638e34ce6.tar.bz2
gentoo-2-6f64934cee09cc3c414cc1670040c4d638e34ce6.zip
Add the fsck_ext2fs helper and man page for FreeBSD and add a patch for 1.40.2 to work on FreeBSD.
(Portage version: 2.1.3.9)
Diffstat (limited to 'sys-fs')
-rw-r--r--sys-fs/e2fsprogs/ChangeLog8
-rw-r--r--sys-fs/e2fsprogs/e2fsprogs-1.40.2.ebuild31
-rw-r--r--sys-fs/e2fsprogs/files/e2fsprogs-1.40-fbsd.patch21
-rw-r--r--sys-fs/e2fsprogs/files/fsck_ext2fs.896
-rw-r--r--sys-fs/e2fsprogs/files/fsck_ext2fs.c147
5 files changed, 295 insertions, 8 deletions
diff --git a/sys-fs/e2fsprogs/ChangeLog b/sys-fs/e2fsprogs/ChangeLog
index ba8bcab81515..da05700f0b44 100644
--- a/sys-fs/e2fsprogs/ChangeLog
+++ b/sys-fs/e2fsprogs/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-fs/e2fsprogs
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-fs/e2fsprogs/ChangeLog,v 1.110 2007/07/14 17:19:03 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/e2fsprogs/ChangeLog,v 1.111 2007/09/15 08:54:25 uberlord Exp $
+
+ 15 Sep 2007; Roy Marples <uberlord@gentoo.org> +files/fsck_ext2fs.8,
+ +files/e2fsprogs-1.40-fbsd.patch, +files/fsck_ext2fs.c,
+ e2fsprogs-1.40.2.ebuild:
+ Add the fsck_ext2fs helper and man page for FreeBSD and add a patch for
+ 1.40.2 to work on FreeBSD.
*e2fsprogs-1.40.2 (14 Jul 2007)
diff --git a/sys-fs/e2fsprogs/e2fsprogs-1.40.2.ebuild b/sys-fs/e2fsprogs/e2fsprogs-1.40.2.ebuild
index eaf2f9fdcb55..7fcbda07b4a8 100644
--- a/sys-fs/e2fsprogs/e2fsprogs-1.40.2.ebuild
+++ b/sys-fs/e2fsprogs/e2fsprogs-1.40.2.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-fs/e2fsprogs/e2fsprogs-1.40.2.ebuild,v 1.1 2007/07/14 17:19:03 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/e2fsprogs/e2fsprogs-1.40.2.ebuild,v 1.2 2007/09/15 08:54:25 uberlord Exp $
inherit eutils flag-o-matic toolchain-funcs
@@ -10,7 +10,7 @@ SRC_URI="mirror://sourceforge/e2fsprogs/${P}.tar.gz"
LICENSE="GPL-2 BSD"
SLOT="0"
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
IUSE="nls static"
RDEPEND="~sys-libs/com_err-${PV}
@@ -31,6 +31,9 @@ src_unpack() {
epatch "${FILESDIR}"/e2fsprogs-1.39-makefile.patch
epatch "${FILESDIR}"/${PN}-1.40-libintl.patch #122368
+ # Fix compile on FreeBSD
+ epatch "${FILESDIR}"/${PN}-1.40-fbsd.patch
+
# kernel headers use the same defines as e2fsprogs and can cause issues #48829
sed -i \
-e 's:CONFIG_JBD_DEBUG:__CONFIG_JBD_DEBUG__E2FS:g' \
@@ -58,9 +61,9 @@ src_unpack() {
src_compile() {
# Keep the package from doing silly things
- export LDCONFIG=/bin/true
+ export LDCONFIG=:
export CC=$(tc-getCC)
- export STRIP=/bin/true
+ export STRIP=:
econf \
--bindir=/bin \
@@ -80,6 +83,11 @@ src_compile() {
fi
# Parallel make sometimes fails
emake -j1 COMPILE_ET=compile_et || die
+
+ # Build the FreeBSD helper
+ if use elibc_FreeBSD ; then
+ ${CC} "${FILESDIR}"/fsck_ext2fs.c -o fsck_ext2fs || die
+ fi
}
src_install() {
@@ -104,8 +112,17 @@ src_install() {
dosbin "${D}"/sbin/mklost+found
rm -f "${D}"/sbin/mklost+found
- # these manpages are already provided by FreeBSD libc
- use elibc_FreeBSD && \
- rm -f "${D}"/usr/share/man/man3/{uuid,uuid_compare}.3 \
+ if use elibc_FreeBSD ; then
+ # Install helpers for us
+ dosbin "${S}"/fsck_ext2fs
+ doman "${FILESDIR}"/fsck_ext2fs.8
+
+ # these manpages are already provided by FreeBSD libc
+ # and filefrag is linux only
+ rm -f \
+ "${D}"/sbin/filefrag
+ "${D}"/usr/share/man/man8/filefrag.8
+ "${D}"/usr/share/man/man3/{uuid,uuid_compare}.3 \
"${D}"/usr/share/man/man1/uuidgen.1
+ fi
}
diff --git a/sys-fs/e2fsprogs/files/e2fsprogs-1.40-fbsd.patch b/sys-fs/e2fsprogs/files/e2fsprogs-1.40-fbsd.patch
new file mode 100644
index 000000000000..616a638ef32c
--- /dev/null
+++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.40-fbsd.patch
@@ -0,0 +1,21 @@
+--- a/lib/ext2fs/tdb.c.orig Thu Apr 5 02:43:05 2007
++++ b/lib/ext2fs/tdb.c Sat Jun 30 16:13:15 2007
+@@ -36,7 +36,6 @@
+ #define HAVE_UTIME_H
+ #define HAVE_UTIME
+ #endif
+-#define _XOPEN_SOURCE 500
+
+ #include <unistd.h>
+ #include <stdio.h>
+--- a/lib/ext2fs/ext2_fs.h.orig Sat Jun 30 16:36:37 2007
++++ b/lib/ext2fs/ext2_fs.h Sat Jun 30 16:36:43 2007
+@@ -414,7 +414,7 @@
+
+ #define i_size_high i_dir_acl
+
+-#if defined(__KERNEL__) || defined(__linux__)
++#if defined(__KERNEL__) || defined(__linux__) || defined(__FreeBSD__)
+ #define i_reserved1 osd1.linux1.l_i_reserved1
+ #define i_frag osd2.linux2.l_i_frag
+ #define i_fsize osd2.linux2.l_i_fsize
diff --git a/sys-fs/e2fsprogs/files/fsck_ext2fs.8 b/sys-fs/e2fsprogs/files/fsck_ext2fs.8
new file mode 100644
index 000000000000..ee40b26b58e0
--- /dev/null
+++ b/sys-fs/e2fsprogs/files/fsck_ext2fs.8
@@ -0,0 +1,96 @@
+.TH fsck_ext2fs 8 2006-07-02 "Matthias Andree" "FreeBSD Ports"
+.\"
+.\" fsck_ext2fs.8 - manual page for fsck_ext2fs wrapper
+.\"
+.\" (C) Copyright 2006 by Matthias Andree <matthias.andree@gmx.de>
+.\"
+.\" License: This file may be redistributed in accordance with the terms
+.\" of the GNU General Public License v2.
+.\"
+.\" Upstream $Id: fsck_ext2fs.8,v 1.1 2007/09/15 08:54:26 uberlord Exp $
+.\" $FreeBSD: ports/sysutils/e2fsprogs/files/fsck_ext2fs.8,v 1.1 2006/07/04 15:47:51 leeym Exp $
+.\"
+.SH NAME
+.B fsck_ext2fs
+\- compatibility wrapper for e2fsck
+.SH SYNOPSIS
+.P
+.B fsck_ext2fs
+[\fB\-Fpfnyv\fR] [\fB\-b\fR \fIblock\fR]
+.SH DESCRIPTION
+.P
+\fBfsck_ext2fs\fR maps the traditional FreeBSD \fBfsck_ffs\fR options to
+options with the same functionality for \fBe2fsck,\fR runs \fBe2fsck\fR
+and then maps its exit status to values that FreeBSD understands.
+\fBe2fsck\fR is a utility to check and repair ext2 and ext3 file
+systems.
+
+.SH OPTIONS
+.IP \fB\-F\fR
+(check foreground mode required) Immediately exits with status 1 to tell
+\fBfsck\fR that ext2fs cannot be checked in the background. \fBfsck\fR
+usually runs \fBfsck_*\fR programs twice, first with \fB\-F\fR to find
+out if they can do background checking, then either immediately without
+\fB\-F\fR for foreground checking or deferred in the background with
+\fB\-B\fR.
+.IP \fB\-p\fR
+(preen mode) This option suppresses adding the \fB\-f\fR option (unless
+\fB\-f\fR is also given) and adds the \fB\-p\fR option to the
+\fBe2fsck\fR command line. This causes \fBe2fsck\fR to automatically fix
+any filesystem problems that can safely be fixed without operator
+intervention. Without this option given, \fBe2fsck\fR will be run with
+the \fB\-f\fR option to force a check, since interactive scan and repair
+mode is the default on FreeBSD, but not on Linux where \fBe2fsck\fR
+comes from.
+.IP \fB\-f\fR
+(force check) This option forces the check of a clean file system while
+preening and is passed to \fBe2fsck\fR verbatim.
+.IP \fB\-n\fR
+("no" mode) This option causes the file system to be opened in read-only
+mode and assume "no" as answer to all questions. This is the only way to
+safely run \fBfsck\fR on a mounted ext2 or ext3 file system. This option
+is passed to \fBe2fsck\fR verbatim.
+.IP \fB\-y\fR
+("yes" mode) This option is passed verbatim to \fBe2fsck\fR and causes
+it to assume "yes" as answer to all questions. This allows the
+non-interactive use of e2fsck but is rather aggressive. Use with care.
+.IP \fB\-v\fR
+(verbose output) This option is passed verbatim to \fBe2fsck\fR and
+causes it to verbosely report its progress.
+.IP "\fB\-b\fR \fIblock\fR"
+(use alternate super block) This option is passed verbatim to
+\fBe2fsck\fR and selects an alternate super block, for use when the
+primary super block has been damaged. Please see the \fBe2fsck\fR(8)
+manual page for details.
+
+.SH EXIT STATUS
+If errors remain after \fBe2fsck\fR, an invalid option or too many
+options have been specified, \fBe2fsck\fR was killed with a signal or
+the \fIfork\fB system call failed, \fBfsck_ext2fs\fR exits with status
+EXIT_FAILURE (usually 1). If \fBe2fsck\fR cannot be started, exits with
+status 127. If the file system is clean after \fBe2fsck\fR operation,
+exits with status EXIT_SUCCESS (0).
+
+.SH NOTES
+.P
+This utility is merely meant as an adaptor so that \fBe2fsck\fR can be
+run during the boot process, it does not support all options that
+\fBe2fsck\fR offers. If you need one of its advanced options, please run
+\fBe2fsck\fR directly.
+
+.SH FILES
+.TP
+.I /sbin/e2fsck
+is the location of the \fBe2fsck\fR program to run.
+
+.SH AUTHOR
+.P
+Matthias Andree <matthias.andree@gmx.de> wrote the program and this
+manual page.
+.SH CONFORMING TO
+The FreeBSD 6.1 command line interface for \fBfsck_ufs\fR(8).
+.SH SEE ALSO
+.BR fsck (8),
+.BR e2fsck (8)
+and
+.BR fsck_ufs (8).
diff --git a/sys-fs/e2fsprogs/files/fsck_ext2fs.c b/sys-fs/e2fsprogs/files/fsck_ext2fs.c
new file mode 100644
index 000000000000..0b6a74ee0aab
--- /dev/null
+++ b/sys-fs/e2fsprogs/files/fsck_ext2fs.c
@@ -0,0 +1,147 @@
+/*
+ * fsck_ext2fs - wrapper for e2fsck on FreeBSD
+ * Copyright (C) 2004,2006 Matthias Andree <matthias.andree@gmx.de>
+ * redistributable in accordance with the
+ * GNU General Public License v2
+ *
+ * $FreeBSD: ports/sysutils/e2fsprogs/files/fsck_ext2fs.c,v 1.5 2006/07/04 15:47:51 leeym Exp $
+ *
+ * Upstream: $Id: fsck_ext2fs.c,v 1.1 2007/09/15 08:54:26 uberlord Exp $
+ *
+ * format: gindent -kr
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+__attribute__ ((noreturn))
+static int die(const char *tag)
+{
+ perror(tag);
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char **argv)
+{
+ int ch, i = 1, force = 0, status, verbose = 0, t;
+ long block = 0;
+ enum { normal, preen, yes, no } mode = normal;
+ char *cmd[256];
+ pid_t pid;
+
+ cmd[0] = "/sbin/e2fsck";
+ while ((ch = getopt(argc, argv, "BFpfnyb:v")) != -1) {
+ switch (ch) {
+ case 'p':
+ mode = preen;
+ break;
+ case 'f':
+ force = 1;
+ break;
+ case 'n':
+ mode = no;
+ break;
+ case 'y':
+ mode = yes;
+ break;
+ case 'b':
+ block = atol(optarg);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case 'F':
+ /* e2fsck does not support background checking,
+ * hence exit with nonzero status to force
+ * the foreground check. */
+ exit(1);
+ case 'B':
+ default:
+ fprintf(stderr, "%s: unknown option -%c\n",
+ argv[0], optopt);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (force)
+ cmd[i++] = "-f";
+
+ switch (mode) {
+ case normal:
+ /* FreeBSD needs -f to force a check only in context
+ * with -p -- so map normal to force to match
+ * expectations */
+ if (!force)
+ cmd[i++] = "-f";
+ break;
+ case yes:
+ cmd[i++] = "-y";
+ break;
+ case no:
+ cmd[i++] = "-n";
+ break;
+ case preen:
+ cmd[i++] = "-p";
+ break;
+ }
+
+ if (block) {
+ static char b[30];
+
+ sprintf(b, "-b %ld", block);
+ cmd[i++] = b;
+ }
+
+ /* silently limit verbose to 15 so we don't overflow the cmd array */
+ if (verbose > 15)
+ verbose = 15;
+
+ for (t = verbose; t > 1; t--)
+ cmd[i++] = "-v";
+
+ while (optind < argc) {
+ cmd[i++] = argv[optind++];
+ /* sanity check so we don't overflow the cmd buffer */
+ if (i+1 == sizeof(cmd)/sizeof(cmd[0])) {
+ errno = E2BIG;
+ die(argv[0]);
+ }
+ }
+
+ cmd[i++] = 0;
+
+ if (verbose) {
+ for (i=0; cmd[i]; i++)
+ fputs(cmd[i], stderr),
+ fputc(' ', stderr);
+ fputc('\n', stderr);
+ }
+
+ pid = fork();
+ switch (pid) {
+ case -1:
+ /* error */
+ die("fork");
+ break;
+ case 0:
+ /* child */
+ (void) execv(cmd[0], cmd);
+ perror("execve");
+ _exit(127);
+ default:
+ /* parent */
+ if (pid != waitpid(pid, &status, 0))
+ die("waitpid");
+ if (WIFSIGNALED(status)
+ || (WIFEXITED(status) && WEXITSTATUS(status) >= 4))
+ exit(EXIT_FAILURE);
+ }
+ exit(EXIT_SUCCESS);
+}