Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Feb 2004 22:23:35 +0100 (CET)
From:      Matthias Andree <matthias.andree@gmx.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/63320: [MAINTAINER] sysutils/e2fsprogs: fix fsck_ext2fs bug, add SIGINFO handler
Message-ID:  <20040224212335.7B7355C5E@sigma.emma.line.org>
Resent-Message-ID: <200402242130.i1OLULmm028413@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         63320
>Category:       ports
>Synopsis:       [MAINTAINER] sysutils/e2fsprogs: fix fsck_ext2fs bug, add SIGINFO handler
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 24 13:30:21 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Matthias Andree
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD sigma.emma.line.org 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Tue Feb 24 16:34:50 CET 2004
>Description:
Bugfix: fsck_ext2fs would abort the boot when run as part of /etc/rc and
e2fsck had repaired a file system. fsck_ext2fs now maps exit codes 0 to 3
from e2fsck to 0. If e2fsck is aborted by a signal or an exit code of 4
or higher, maps to EXIT_FAILURE.

Feature: e2fsck now handles SIGINFO (Ctrl+T): print progress bar once.

COMMITTER: there is a new file "files/patch-SIGINFO-e2fck_unix.c",
please remember to cvs add it.

Generated with FreeBSD Port Tools 0.50
>How-To-Repeat:
>Fix:

--- e2fsprogs-1.35.w20040131_2.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/sysutils/e2fsprogs/Makefile /usr/home/emma/e2fsprogs/Makefile
--- /usr/ports/sysutils/e2fsprogs/Makefile	Tue Feb 24 16:26:22 2004
+++ /usr/home/emma/e2fsprogs/Makefile	Tue Feb 24 21:42:56 2004
@@ -7,7 +7,7 @@
 
 PORTNAME=	e2fsprogs
 PORTVERSION=	1.35.w20040131
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	sysutils
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	${PORTNAME}
diff -ruN --exclude=CVS /usr/ports/sysutils/e2fsprogs/files/fsck_ext2fs.c /usr/home/emma/e2fsprogs/files/fsck_ext2fs.c
--- /usr/ports/sysutils/e2fsprogs/files/fsck_ext2fs.c	Fri Feb 20 23:46:21 2004
+++ /usr/home/emma/e2fsprogs/files/fsck_ext2fs.c	Tue Feb 24 21:57:02 2004
@@ -6,21 +6,34 @@
  *
  * $FreeBSD: ports/sysutils/e2fsprogs/files/fsck_ext2fs.c,v 1.1 2004/02/20 22:46:21 glewis Exp $
  *
+ * Upstream: $Id: fsck_ext2fs.c,v 1.2 2004/02/24 20:57:02 emma 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>
 
-int
-main(int argc, char **argv)
+__attribute__ ((noreturn))
+static int die(const char *tag)
 {
-	int ch, i = 1, force = 0;
+	perror(tag);
+	exit(EXIT_FAILURE);
+}
+
+int main(int argc, char **argv)
+{
+	int ch, i = 1, force = 0, status;
 	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:")) != -1) {
@@ -43,6 +56,8 @@
 		case 'B':
 		case 'F':
 		default:
+			fprintf(stderr, "%s: unknown option -%c\n",
+				argv[0], optopt);
 			exit(EXIT_FAILURE);
 		}
 	}
@@ -76,6 +91,24 @@
 
 	cmd[i++] = 0;
 
-	(void)execv(cmd[0], cmd);
-	exit(EXIT_FAILURE);
+	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);
 }
diff -ruN --exclude=CVS /usr/ports/sysutils/e2fsprogs/files/patch-SIGINFO-e2fck_unix.c /usr/home/emma/e2fsprogs/files/patch-SIGINFO-e2fck_unix.c
--- /usr/ports/sysutils/e2fsprogs/files/patch-SIGINFO-e2fck_unix.c	Thu Jan  1 01:00:00 1970
+++ /usr/home/emma/e2fsprogs/files/patch-SIGINFO-e2fck_unix.c	Tue Feb 24 22:18:26 2004
@@ -0,0 +1,54 @@
+--- e2fsprogs-1.35/e2fsck/unix.c~	Sun Dec  7 18:11:38 2003
++++ e2fsprogs-1.35/e2fsck/unix.c	Tue Feb 24 22:13:52 2004
+@@ -416,6 +416,24 @@
+ 	return 0;
+ }
+ 
++static int e2fsck_progress_once(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max)
++{
++	char buf[80];
++	float percent;
++
++	if (pass == 0)
++		return 0;
++	
++	percent = calc_percent(&e2fsck_tbl, pass, cur, max);
++	e2fsck_simple_progress(ctx, ctx->device_name,
++			percent, 0);
++
++	printf("\n");
++	ctx->progress = 0;
++	return 0;
++}
++
++
+ #define PATH_SET "PATH=/sbin"
+ 
+ static void reserve_stdio_fds(void)
+@@ -448,6 +466,17 @@
+ 	ctx->progress_fd = 0;
+ }
+ 
++static void signal_progress_now(int sig EXT2FS_ATTR((unused)))
++{
++	e2fsck_t ctx = e2fsck_global_ctx;
++
++	if (!ctx)
++		return;
++
++	ctx->progress = e2fsck_progress_once;
++	ctx->progress_fd = 0;
++}
++
+ static void signal_progress_off(int sig EXT2FS_ATTR((unused)))
+ {
+ 	e2fsck_t ctx = e2fsck_global_ctx;
+@@ -740,6 +769,8 @@
+ 	sigaction(SIGUSR1, &sa, 0);
+ 	sa.sa_handler = signal_progress_off;
+ 	sigaction(SIGUSR2, &sa, 0);
++	sa.sa_handler = signal_progress_now;
++	sigaction(SIGINFO, &sa, 0);
+ #endif
+ 
+ 	/* Update our PATH to include /sbin if we need to run badblocks  */
--- e2fsprogs-1.35.w20040131_2.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040224212335.7B7355C5E>