Date: Sun, 4 Feb 2007 18:51:21 +0100 (CET) From: Sten Spans <sten@blinkenlights.nl> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/108766: New port: sysutils/ffs2recov ufs2 recovery utility Message-ID: <20070204175121.119FA7301D@mx0.blinkenlights.nl> Resent-Message-ID: <200702041800.l14I0YVA042136@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 108766 >Category: ports >Synopsis: New port: sysutils/ffs2recov ufs2 recovery utility >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sun Feb 04 18:00:34 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Sten Spans >Release: FreeBSD 6.2-RELEASE i386 >Organization: >Environment: System: FreeBSD earth.blinkenlights.nl 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Sun Jan 28 15:02:12 CET 2007 root@earth.blinkenlights.nl:/usr/obj/usr/src/sys/1650 i386 >Description: Frank Mayhar (frank@exit.com) has added ufs2 support to an ufs recovery utility orignally developed by John-Mark Gurney. He requested addition to freebsd ports on the hackers mailinglist. >How-To-Repeat: >Fix: Add the port # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # ffs2recov # ffs2recov/files # ffs2recov/files/patch-cleanup # ffs2recov/Makefile # ffs2recov/distinfo # ffs2recov/pkg-descr # echo c - ffs2recov mkdir -p ffs2recov > /dev/null 2>&1 echo c - ffs2recov/files mkdir -p ffs2recov/files > /dev/null 2>&1 echo x - ffs2recov/files/patch-cleanup sed 's/^X//' >ffs2recov/files/patch-cleanup << 'END-of-ffs2recov/files/patch-cleanup' X--- Makefile.orig Mon Sep 19 05:47:56 2005 X+++ Makefile Sun Feb 4 04:55:45 2007 X@@ -1,39 +1,12 @@ X-PREFIX?= /usr/local X+# $FreeBSD$ X X-BINDIR = $(PREFIX)/bin X-BINOWN?= root X-BINGRP?= wheel X+PROG= ffs2recov X+SRCS= main.c block.c inode.c io.c super.c X+MAN= ffs2recov.8 X X-PROG = ffsrecov X+DPADD= ${LIBUFS} X+LDADD= -lufs X X-DEBUG = -g X+WARNS?= 2 X X-CFLAGS+= $(DEBUG) -Wall X- X-SRCS = main.c block.c inode.c io.c super.c X-OBJS = main.o block.o inode.o io.o super.o X- X-#XXX - install-man only handles one file in MAN8 X-MAN8 = ffsrecov.8 X-MANDIR = $(PREFIX)/man/man X-MANOWN? = man X-MANGRP? = man X- X-all: $(PROG) X- X-$(PROG): $(OBJS) X- $(CC) -g -o $@ $(OBJS) -lufs X- X-install: $(PROG) install-man X- cp $(PROG) $(BINDIR) X- strip $(BINDIR)/$(PROG) X- chmod 555 $(BINDIR)/$(PROG) X- -chown $(BINOWN):$(BINGRP) $(BINDIR)/$(PROG) X- X-install-man: X- cp $(MAN8) $(MANDIR)8 X- chmod 444 $(MANDIR)8/$(MAN8) X- -chown $(MANOWN):$(MANGRP) $(MANDIR)8/$(MAN8) X- X-clean: X- rm -f $(PROG) $(OBJS) cscope.out X+.include <bsd.prog.mk> X--- main.c.orig Sun Feb 4 03:00:36 2007 X+++ main.c Sun Feb 4 04:55:23 2007 X@@ -64,7 +64,7 @@ X int verbose; X int debug; X X-void X+static void X ufserr(const char *name) X { X if (ufs_disk != NULL && ufs_disk->d_error != NULL) X@@ -73,8 +73,8 @@ X warn("%s", name); X } X X-void X-usage() X+static void X+usage(void) X { X printf("usage: ffsrecover [-adps] [-b blk] [-c ino -n name | -f ino | -i ino ] [-o blk] [-r name] [-t blk] file\n"); X printf("\n"); X@@ -102,8 +102,6 @@ X int argc, X char *argv[]) X { X- extern char *optarg; X- extern int optind; X char *file; X int ch, findsb, printbsb, recoverfile, printalldirs; X ufs2_daddr_t blk; X@@ -371,7 +369,7 @@ X blk = ino_to_fsba(&disk->d_fs, i); X if (verbose) X fprintf(stderr, "Inode %d blk %llu\r", i, (unsigned long long)blk); X- if ((len = bread(disk, blk, inode, ilen)) < sizeof(struct ufs2_dinode)) { X+ if ((len = bread(disk, blk, inode, ilen)) < (ssize_t) sizeof(struct ufs2_dinode)) { X if (verbose > 1) X fprintf(stderr, X "\n%s: short read (%d) on inode %d blk %llu, skipping\n", X@@ -379,8 +377,6 @@ X continue; X } X if (i == 2 || (inode->di_mode & IFMT) == IFDIR) { X- int len; X- X len = (inode->di_size + disk->d_fs.fs_fsize - 1) & X disk->d_fs.fs_fmask; X if ((dir = malloc(len)) == NULL) { X@@ -473,7 +469,7 @@ X inode = malloc(ilen); X blk = ino_to_fsba(&disk->d_fs, num); X DPRINTF((stderr, "%s: ino %d blk %llu\n", __FUNCTION__, num, (unsigned long long)blk)); X- if (bread(disk, blk, inode, ilen) < sizeof(struct ufs2_dinode)) { X+ if (bread(disk, blk, inode, ilen) < (ssize_t) sizeof(struct ufs2_dinode)) { X fprintf(stderr, "short read on inode %d, skipping\n", num); X free(inode); X return; X@@ -498,7 +494,7 @@ X blk = ino_to_fsba(&disk->d_fs, i); X if (verbose) X fprintf(stderr, "Inode %d blk %llu\r", i, (unsigned long long)blk); X- if (bread(disk, blk, inode, ilen) < sizeof(struct ufs2_dinode)) { X+ if (bread(disk, blk, inode, ilen) < (ssize_t) sizeof(struct ufs2_dinode)) { X fprintf(stderr, "short read on inode %d, skipping\n", i); X continue; X } X@@ -537,7 +533,7 @@ X ilen = roundup2(sizeof(struct ufs2_dinode), disk->d_bsize); X inode = malloc(ilen); X blk = ino_to_fsba(&disk->d_fs, inum); X- if (bread(disk, blk, inode, ilen) < sizeof(struct ufs2_dinode)) { X+ if (bread(disk, blk, inode, ilen) < (ssize_t) sizeof(struct ufs2_dinode)) { X fprintf(stderr, "short read on inode %d, skipping\n", inum); X free(inode); X return; END-of-ffs2recov/files/patch-cleanup echo x - ffs2recov/Makefile sed 's/^X//' >ffs2recov/Makefile << 'END-of-ffs2recov/Makefile' X# New ports collection makefile for: ffs2recov X# Date created: 20070204 X# Whom: sten@blinkenlights.nl X# X# $FreeBSD$ X# X XPORTNAME= ffs2recov XPORTVERSION= 2007.02.04 XCATEGORIES= sysutils XMASTER_SITES= http://www.exit.com/Archives/FreeBSD/ XDISTNAME= ffs2recov X XMAINTAINER= sten@blinkenlights.nl XCOMMENT= A utility to recover UFS2 filesystems X XUSE_BZIP2= yes X XMAN8= ffs2recov.8 XPLIST_FILES= sbin/ffs2recov X Xdo-install: X ${INSTALL_PROGRAM} ${WRKSRC}/ffs2recov ${PREFIX}/sbin/. X ${INSTALL_MAN} ${WRKSRC}/ffs2recov.8 ${MAN8PREFIX}/man/man8/. X X.include <bsd.port.mk> END-of-ffs2recov/Makefile echo x - ffs2recov/distinfo sed 's/^X//' >ffs2recov/distinfo << 'END-of-ffs2recov/distinfo' XSHA256 (ffs2recov.tar.bz2) = 5abdb2691ef9e4d30f67918fb51ff39e54aeec3045cc8cb073a2ec620875c693 XMD5 (ffs2recov.tar.bz2) = 6034e3697c840a2599cde865f99b4c82 XSIZE (ffs2recov.tar.bz2) = 14864 END-of-ffs2recov/distinfo echo x - ffs2recov/pkg-descr sed 's/^X//' >ffs2recov/pkg-descr << 'END-of-ffs2recov/pkg-descr' XThis is the UFS2 version of ffsrecov, heavily (and I do mean _heavily_) based Xon John-Mark Gurney's program of the same name. It does basically the same Xthing, only it's a little more resistant to crashes caused by bad pointers, Xoffsets and the like, and it does a little more than his did. Don't contact Xhim for problems with this program, it's definitely _my_ fault if it breaks. X XThis program is not ready for prime time. It has some shortfalls, it has a Xbunch of new options that are mostly undocumented and the manpage could Xstand to be rewritten. One _good_ thing is that it now uses the libufs Xlibrary and is therefore not as dependent on carrying around low-level code. X XOn the other hand, it worked for me. Using this tool, I was able to recover Xalmost all of a several-hundred-gigabyte file system that had been stomped Xby a misconfigured RAID controller. (That's why I wrote the thing in the Xfirst place, in fact.) With the right knowledge and a lot of patience, Xit is possible to recover most or all of a trashed file system, at least if Xit's not _too_ trashed. X XI'm releasing it under the Berkeley two-clause license in the hope that Xsomeone with more time will pick it up, polish it and make something Xa little more useful out of it. X XFrank Mayhar Xfrank@exit.com END-of-ffs2recov/pkg-descr exit >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070204175121.119FA7301D>