From 56bd759df1d0c750a065b8c845e93d5dfa6b549d Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 8 Aug 2015 13:49:04 -0700 Subject: proj/gentoo: Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson X-Thanks: Alec Warner - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring - wrote much python to improve cvs2svn X-Thanks: Rich Freeman - validation scripts X-Thanks: Patrick Lauer - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed --- ...ix-error-message-so-the-mountpoint-is-pri.patch | 45 +++++++ sys-fs/e2fsprogs/files/e2fsck.conf | 6 + .../files/e2fsprogs-1.38-tests-locale.patch | 26 ++++ sys-fs/e2fsprogs/files/e2fsprogs-1.40-fbsd.patch | 11 ++ .../files/e2fsprogs-1.41.5-makefile.patch | 91 +++++++++++++ .../files/e2fsprogs-1.41.8-makefile.patch | 10 ++ ...gs-1.42.10-e2fsck-fix-makefile-dependency.patch | 28 ++++ .../files/e2fsprogs-1.42.10-fix-build-cflags.patch | 13 ++ .../files/e2fsprogs-1.42.13-fix-build-cflags.patch | 13 ++ sys-fs/e2fsprogs/files/fsck_ext2fs.8 | 96 ++++++++++++++ sys-fs/e2fsprogs/files/fsck_ext2fs.c | 147 +++++++++++++++++++++ 11 files changed, 486 insertions(+) create mode 100644 sys-fs/e2fsprogs/files/0001-resize2fs-Fix-error-message-so-the-mountpoint-is-pri.patch create mode 100644 sys-fs/e2fsprogs/files/e2fsck.conf create mode 100644 sys-fs/e2fsprogs/files/e2fsprogs-1.38-tests-locale.patch create mode 100644 sys-fs/e2fsprogs/files/e2fsprogs-1.40-fbsd.patch create mode 100644 sys-fs/e2fsprogs/files/e2fsprogs-1.41.5-makefile.patch create mode 100644 sys-fs/e2fsprogs/files/e2fsprogs-1.41.8-makefile.patch create mode 100644 sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-e2fsck-fix-makefile-dependency.patch create mode 100644 sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-fix-build-cflags.patch create mode 100644 sys-fs/e2fsprogs/files/e2fsprogs-1.42.13-fix-build-cflags.patch create mode 100644 sys-fs/e2fsprogs/files/fsck_ext2fs.8 create mode 100644 sys-fs/e2fsprogs/files/fsck_ext2fs.c (limited to 'sys-fs/e2fsprogs/files') diff --git a/sys-fs/e2fsprogs/files/0001-resize2fs-Fix-error-message-so-the-mountpoint-is-pri.patch b/sys-fs/e2fsprogs/files/0001-resize2fs-Fix-error-message-so-the-mountpoint-is-pri.patch new file mode 100644 index 000000000000..979bf74a0ea8 --- /dev/null +++ b/sys-fs/e2fsprogs/files/0001-resize2fs-Fix-error-message-so-the-mountpoint-is-pri.patch @@ -0,0 +1,45 @@ +https://bugs.gentoo.org/276352 + +From 3a4d9869d47c462c84688b0f8b15df5ab6f93381 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 2 Jul 2009 13:54:22 -0400 +Subject: [PATCH] resize2fs: Fix error message so the mountpoint is printed correctly + +The resize2fs program was freeing the mountpoint information too +early, so garbage was getting printed instead of the correct +information in an error message. + +Addresses-Debian-Bug: #535452 + +Signed-off-by: "Theodore Ts'o" +--- + resize/main.c | 5 ++--- + 1 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/resize/main.c b/resize/main.c +index 9b03ba9..2dae161 100644 +--- a/resize/main.c ++++ b/resize/main.c +@@ -250,10 +250,8 @@ int main (int argc, char ** argv) + device_name); + exit(1); + } +- if (!(mount_flags & EXT2_MF_MOUNTED) || (mtpt[len-1] == 0)) { +- free(mtpt); ++ if (!(mount_flags & EXT2_MF_MOUNTED) || (mtpt[len-1] == 0)) + break; +- } + free(mtpt); + len = 2 * len; + } +@@ -453,6 +451,7 @@ int main (int argc, char ** argv) + ((flags & RESIZE_PERCENT_COMPLETE) ? + resize_progress_func : 0)); + } ++ free(mtpt); + if (retval) { + com_err(program_name, retval, _("while trying to resize %s"), + device_name); +-- +1.6.3.3 + diff --git a/sys-fs/e2fsprogs/files/e2fsck.conf b/sys-fs/e2fsprogs/files/e2fsck.conf new file mode 100644 index 000000000000..401cec45eec1 --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsck.conf @@ -0,0 +1,6 @@ +# See the e2fsck.conf man page for more info + +[options] + +# allow fsck to run sanely at any point in time #142850 +buggy_init_scripts = yes diff --git a/sys-fs/e2fsprogs/files/e2fsprogs-1.38-tests-locale.patch b/sys-fs/e2fsprogs/files/e2fsprogs-1.38-tests-locale.patch new file mode 100644 index 000000000000..6c316ac2a38b --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.38-tests-locale.patch @@ -0,0 +1,26 @@ +Since the tests analyze the output messages, force the default locale. + +http://bugs.gentoo.org/99766 + +--- tests/test_script.in ++++ tests/test_script.in +@@ -3,6 +3,19 @@ + # Test script for e2fsck + # + ++# NLS nuisances. ++for as_var in \ ++ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ ++ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ ++ LC_TELEPHONE LC_TIME ++do ++ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then ++ eval $as_var=C; export $as_var ++ else ++ unset $as_var ++ fi ++done ++ + if test "$1"x = x ; then + TESTS=`ls -d $SRCDIR/[a-zA-Z]_* | $EGREP -v "\.failed|\.new"` + else 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..7d0919600d05 --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.40-fbsd.patch @@ -0,0 +1,11 @@ +--- a/lib/ext2fs/ext2_fs.h ++++ b/lib/ext2fs/ext2_fs.h +@@ -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/e2fsprogs-1.41.5-makefile.patch b/sys-fs/e2fsprogs/files/e2fsprogs-1.41.5-makefile.patch new file mode 100644 index 000000000000..010a09aafabe --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.41.5-makefile.patch @@ -0,0 +1,91 @@ +--- e2fsprogs-1.41.5/e2fsck/Makefile.in ++++ e2fsprogs-1.41.5/e2fsck/Makefile.in +@@ -195,12 +195,12 @@ + @echo " LINK $(root_sbindir)/fsck.ext2" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/e2fsck \ ++ @$(LN_S) -f e2fsck \ + $(DESTDIR)$(root_sbindir)/fsck.ext2 + @echo " LINK $(root_sbindir)/fsck.ext3" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/e2fsck \ ++ @$(LN_S) -f e2fsck \ + $(DESTDIR)$(root_sbindir)/fsck.ext3 + @echo " LINK $(root_sbindir)/fsck.ext4" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/e2fsck \ ++ @$(LN_S) -f e2fsck \ + $(DESTDIR)$(root_sbindir)/fsck.ext4 + @echo " LINK $(root_sbindir)/fsck.ext4dev" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/e2fsck \ ++ @$(LN_S) -f e2fsck \ + $(DESTDIR)$(root_sbindir)/fsck.ext4dev +@@ -221,12 +221,12 @@ + @echo " LINK $(man8dir)/fsck.ext2.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/e2fsck.8 \ ++ @$(LN_S) -f e2fsck.8 \ + $(DESTDIR)$(man8dir)/fsck.ext2.8 + @echo " LINK $(man8dir)/fsck.ext3.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/e2fsck.8 \ ++ @$(LN_S) -f e2fsck.8 \ + $(DESTDIR)$(man8dir)/fsck.ext3.8 + @echo " LINK $(man8dir)/fsck.ext4.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/e2fsck.8 \ ++ @$(LN_S) -f e2fsck.8 \ + $(DESTDIR)$(man8dir)/fsck.ext4.8 + @echo " LINK $(man8dir)/fsck.ext4.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/e2fsck.8 \ ++ @$(LN_S) -f e2fsck.8 \ + $(DESTDIR)$(man8dir)/fsck.ext4dev.8 +--- e2fsprogs-1.41.5/misc/Makefile.in ++++ e2fsprogs-1.41.5/misc/Makefile.in +@@ -394,19 +394,19 @@ + @echo " LINK $(root_sbindir)/mkfs.ext2" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/mke2fs \ ++ @$(LN_S) -f mke2fs \ + $(DESTDIR)$(root_sbindir)/mkfs.ext2 + @echo " LINK $(root_sbindir)/mkfs.ext3" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/mke2fs \ ++ @$(LN_S) -f mke2fs \ + $(DESTDIR)$(root_sbindir)/mkfs.ext3 + @echo " LINK $(root_sbindir)/mkfs.ext4" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/mke2fs \ ++ @$(LN_S) -f mke2fs \ + $(DESTDIR)$(root_sbindir)/mkfs.ext4 + @echo " LINK $(root_sbindir)/mkfs.ext4dev" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/mke2fs \ ++ @$(LN_S) -f mke2fs \ + $(DESTDIR)$(root_sbindir)/mkfs.ext4dev + @echo " LINK $(root_sbindir)/e2label" +- @$(LN) -f $(DESTDIR)$(root_sbindir)/tune2fs \ ++ @$(LN_S) -f tune2fs \ + $(DESTDIR)$(root_sbindir)/e2label + @if test -n "$(FINDFS_LINK)"; then \ + echo " LINK $(root_sbindir)/findfs"; \ +- $(LN) -f $(DESTDIR)$(root_sbindir)/tune2fs \ ++ $(LN_S) -f tune2fs \ + $(DESTDIR)$(root_sbindir)/$(FINDFS_LINK); \ +@@ -431,12 +431,12 @@ + @echo " LINK mkfs.ext2.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/mke2fs.8 \ ++ @$(LN_S) -f mke2fs.8 \ + $(DESTDIR)$(man8dir)/mkfs.ext2.8 + @echo " LINK mkfs.ext3.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/mke2fs.8 \ ++ @$(LN_S) -f mke2fs.8 \ + $(DESTDIR)$(man8dir)/mkfs.ext3.8 + @echo " LINK mkfs.ext4.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/mke2fs.8 \ ++ @$(LN_S) -f mke2fs.8 \ + $(DESTDIR)$(man8dir)/mkfs.ext4.8 + @echo " LINK mkfs.ext4dev.8" +- @$(LN) -f $(DESTDIR)$(man8dir)/mke2fs.8 \ ++ @$(LN_S) -f mke2fs.8 \ + $(DESTDIR)$(man8dir)/mkfs.ext4dev.8 +--- e2fsprogs-1.41.5/Makefile.in ++++ e2fsprogs-1.41.5/Makefile.in +@@ -281,6 +66,7 @@ + uninstall: uninstall-progs-recursive uninstall-shlibs-libs-recursive uninstall-doc-libs + + install-libs: install-libs-recursive ++install-libs-recursive: | install-shlibs-libs-recursive + + uninstall-libs: uninstall-libs-recursive + diff --git a/sys-fs/e2fsprogs/files/e2fsprogs-1.41.8-makefile.patch b/sys-fs/e2fsprogs/files/e2fsprogs-1.41.8-makefile.patch new file mode 100644 index 000000000000..b7d3d96856b5 --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.41.8-makefile.patch @@ -0,0 +1,10 @@ +--- e2fsprogs-1.41.5/Makefile.in ++++ e2fsprogs-1.41.5/Makefile.in +@@ -281,6 +66,7 @@ + uninstall: uninstall-progs-recursive uninstall-shlibs-libs-recursive uninstall-doc-libs + + install-libs: install-libs-recursive ++install-libs-recursive: | install-shlibs-libs-recursive + + uninstall-libs: uninstall-libs-recursive + diff --git a/sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-e2fsck-fix-makefile-dependency.patch b/sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-e2fsck-fix-makefile-dependency.patch new file mode 100644 index 000000000000..033084706f42 --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-e2fsck-fix-makefile-dependency.patch @@ -0,0 +1,28 @@ +From 5c15bf5f978bae01f1ca3cbe6414ab1d355a6adf Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 22 May 2014 18:52:27 -0400 +Subject: e2fsck: fix Makefile dependency for quota.o + +Signed-off-by: "Theodore Ts'o" + +diff --git a/e2fsck/Makefile.in b/e2fsck/Makefile.in +index 4b10f6f..f773fea 100644 +--- a/e2fsck/Makefile.in ++++ b/e2fsck/Makefile.in +@@ -552,3 +552,13 @@ logfile.o: $(srcdir)/logfile.c $(top_builddir)/lib/config.h \ + $(top_srcdir)/lib/quota/dqblk_v2.h $(top_srcdir)/lib/quota/quotaio_tree.h \ + $(top_srcdir)/lib/../e2fsck/dict.h + prof_err.o: prof_err.c ++quota.o: $(srcdir)/quota.c $(top_builddir)/lib/config.h \ ++ $(top_builddir)/lib/dirpaths.h $(srcdir)/e2fsck.h \ ++ $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \ ++ $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \ ++ $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \ ++ $(top_builddir)/lib/ext2fs/ext2_err.h \ ++ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \ ++ $(srcdir)/profile.h prof_err.h $(top_srcdir)/lib/quota/quotaio.h \ ++ $(top_srcdir)/lib/quota/dqblk_v2.h $(top_srcdir)/lib/quota/quotaio_tree.h \ ++ $(top_srcdir)/lib/../e2fsck/dict.h $(srcdir)/problem.h +-- +cgit v0.10.1 + diff --git a/sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-fix-build-cflags.patch b/sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-fix-build-cflags.patch new file mode 100644 index 000000000000..69e6f358d9e1 --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.42.10-fix-build-cflags.patch @@ -0,0 +1,13 @@ +https://bugs.gentoo.org/516854 + +--- a/e2fsprogs-libs-1.42.10/configure ++++ b/e2fsprogs-libs-1.42.10/configure +@@ -1328,7 +1328,7 @@ + BUILD_CFLAGS="$CFLAGS $CPPFLAGS $INCLUDES -DHAVE_CONFIG_H" + BUILD_LDFLAGS="$LDFLAGS" + else +- BUILD_CFLAGS= ++ BUILD_CFLAGS="$INCLUDES" + BUILD_LDFLAGS= + fi + diff --git a/sys-fs/e2fsprogs/files/e2fsprogs-1.42.13-fix-build-cflags.patch b/sys-fs/e2fsprogs/files/e2fsprogs-1.42.13-fix-build-cflags.patch new file mode 100644 index 000000000000..dcab9a34de09 --- /dev/null +++ b/sys-fs/e2fsprogs/files/e2fsprogs-1.42.13-fix-build-cflags.patch @@ -0,0 +1,13 @@ +https://bugs.gentoo.org/516854 + +--- e2fsprogs-1.42.13/configure ++++ e2fsprogs-1.42.13/configure +@@ -1315,6 +1315,8 @@ + if test $cross_compiling = no; then + BUILD_CFLAGS="$CFLAGS $CPPFLAGS $INCLUDES -DHAVE_CONFIG_H" + BUILD_LDFLAGS="$LDFLAGS" ++else ++ BUILD_CFLAGS="$INCLUDES" + fi + + diff --git a/sys-fs/e2fsprogs/files/fsck_ext2fs.8 b/sys-fs/e2fsprogs/files/fsck_ext2fs.8 new file mode 100644 index 000000000000..54d269b81b96 --- /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 +.\" +.\" License: This file may be redistributed in accordance with the terms +.\" of the GNU General Public License v2. +.\" +.\" Upstream $Id$ +.\" $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 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..c0a35de6792e --- /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 + * 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$ + * + * format: gindent -kr + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +__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); +} -- cgit v1.2.3-65-gdbad