[Forensics-changes] [SCM] Guess PC disk partition table, find lost partitions branch, debian, updated. upstream/0.1h-1-g4a1524b
Daniel Baumann
daniel at debian.org
Fri Sep 19 06:16:56 UTC 2008
The following commit has been merged in the debian branch:
commit 4a1524b0e446ff5ff4e805b262db10e68ee0839a
Author: Daniel Baumann <daniel at debian.org>
Date: Fri Sep 19 08:15:12 2008 +0200
Adding debian version 0.1h-4.1.
diff --git a/Makefile b/Makefile
index 99d6764..49cf511 100644
--- a/Makefile
+++ b/Makefile
@@ -10,8 +10,12 @@ gpart:
$(MAKE) -C src
$(MAKE) -C man
-install:
+install: install-object install-man
+
+install-object:
$(MAKE) -C src install
+
+install-man:
$(MAKE) -C man install
uninstall:
@@ -21,3 +25,5 @@ uninstall:
clean:
$(MAKE) -C src clean
$(MAKE) -C man clean
+
+.PHONY: all gpart install install-object install-man uninstall clean
diff --git a/README b/README
index dc5ed68..c933842 100644
--- a/README
+++ b/README
@@ -24,25 +24,25 @@
- Currently recognized partitions/filesystems types ---------------------
- Modname Typ Description
- fat 0x01 "Primary DOS with 12 bit FAT"
- 0x04 "Primary DOS with 16 bit FAT (<= 32MB)"
- 0x06 "Primary 'big' DOS (> 32MB)"
- 0x0B "DOS or Windows 95 with 32 bit FAT"
- 0x0C "DOS or Windows 95 with 32 bit FAT, LBA"
- ntfs 0x07 "OS/2 HPFS, NTFS, QNX or Advanced UNIX"
- hpfs 0x07 "OS/2 HPFS, NTFS, QNX or Advanced UNIX"
- ext2 0x83 "Linux ext2 filesystem"
- lswap 0x82 "Linux swap"
- bsddl 0xA5 "FreeBSD/NetBSD/386BSD"
- s86dl 0x82 "Solaris/x86 disklabel"
- minix 0x80 "Minix V1"
- 0x81 "Minix V2"
- rfs 0x83 "Reiser filesystem"
- hmlvm 0xFE "Linux LVM physical volumes"
- qnx4 0x4F "QNX 4.x"
- beos 0xEB "BeOS fs"
- xfs 0x83 "SGI XFS filesystem"
+ Modname Typ Description
+ fat 0x01 "Primary DOS with 12 bit FAT"
+ 0x04 "Primary DOS with 16 bit FAT (<= 32MB)"
+ 0x06 "Primary 'big' DOS (> 32MB)"
+ 0x0B "DOS or Windows 95 with 32 bit FAT"
+ 0x0C "DOS or Windows 95 with 32 bit FAT, LBA"
+ ntfs 0x07 "OS/2 HPFS, NTFS, QNX or Advanced UNIX"
+ hpfs 0x07 "OS/2 HPFS, NTFS, QNX or Advanced UNIX"
+ ext2 0x83 "Linux ext2 filesystem"
+ lswap 0x82 "Linux swap"
+ bsddl 0xA5 "FreeBSD/NetBSD/386BSD"
+ s86dl 0x82 "Solaris/x86 disklabel"
+ minix 0x80 "Minix V1"
+ 0x81 "Minix V2"
+ reiserfs 0x83 "ReiserFS filesystem"
+ hmlvm 0xFE "Linux LVM physical volumes"
+ qnx4 0x4F "QNX 4.x"
+ beos 0xEB "BeOS fs"
+ xfs 0x83 "SGI XFS filesystem"
diff --git a/debian/README.debian b/debian/README.debian
new file mode 100644
index 0000000..263e61e
--- /dev/null
+++ b/debian/README.debian
@@ -0,0 +1,13 @@
+gpart for DEBIAN
+----------------
+
+Changes made to upstream version for the Debian package:
+
+ -- Install into /sbin and /usr/share/man rather than /usr/local/bin and usr/local/man
+
+ (I have it install to /sbin, rather than (e.g.) /usr/sbin, because it
+ will be necessary to have it there if you lose or inadvertently
+ delete your /usr partition from the partition table, and want to use
+ gpart to find it again.)
+
+David L. Coe <david.coe at someotherplace.org>, Fri, 28 May 1999 22:49:11 +0000
diff --git a/debian/TODO.Debian b/debian/TODO.Debian
new file mode 100644
index 0000000..71798d3
--- /dev/null
+++ b/debian/TODO.Debian
@@ -0,0 +1,8 @@
+TODO.Debian for gpart
+---------------------
+
+create html and info documentation from the man page contents?
+
+help upstream author write a how-to document?
+
+amend the Linux partition recovery mini-HOWTO
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..5b5ac1a
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,122 @@
+gpart (0.1h-4.1) unstable; urgency=medium
+
+ * NMU from the Cambridge BSP
+ * Rather than attempt to use the syscall(!) interface for 64-bit lseek,
+ simply compile to use the 64-bit VFS interface and use the normal
+ lseek calls. Let libc deal with the issues...
+ Closes: #225578, #294836, #393039.
+ * Applied the reiserfs 3.6 recognition patch from
+ ftp://ftp.namesys.com/pub/misc-patches/gpart-0.1h-reiserfs-3.6.patch.gz
+ Closes: #246989, #322256
+ * Recogniise ext3 filesystems as well as ext2. Thanks to Xisco Calafat
+ for the patch. Closes: #212989
+
+ -- Steve McIntyre <93sam at debian.org> Sat, 28 Oct 2006 22:50:42 +0100
+
+gpart (0.1h-4) unstable; urgency=low
+
+ * recompile to resolve errno problem; no changes required
+ Closes: #225018: gpart binary is incorrectly built
+ * debian standards 3.5.10:
+ - support DEB_BUILD_OPTIONS "noopt"
+
+ -- David Coe <davidc at debian.org> Thu, 25 Dec 2003 01:31:30 -0500
+
+gpart (0.1h-3) unstable; urgency=low
+
+ * corrected punctuation in package description
+ Closes: #124692: Spelling error in description
+
+ -- David Coe <davidc at debian.org> Mon, 17 Dec 2001 21:06:11 -0500
+
+gpart (0.1h-2) unstable; urgency=low
+
+ * moved Build-Depends to the right place
+ Closes: #119348: malformed debian/control
+ * patched to build on ia64 (and others), thanks to Doug Porter
+ <dsp at debian.org>, and changed to Architecture: any.
+ Closes: #119347: fix to build on ia64
+ * standards version now 3.5.6; no changes needed.
+
+ -- David Coe <davidc at debian.org> Sun, 25 Nov 2001 23:08:43 -0500
+
+gpart (0.1h-1) unstable; urgency=low
+
+ * new upstream version:
+ v0.1h
+ - New support for BeOS, QNX 4.x & SGI XFS filesystems.
+ - Updated Reiser filesystem support.
+ - Updated LVM support.
+ - Several small fixes from contributors.
+ v0.1g
+ - For access via raw devices: made writing of guessed table also
+ aligned (reading has been aligned since 0.1f).
+ - Fixed stupid copy&paste bug in the partition table check routine.
+ Closes: #66894 "crashes immediately on Alpha [includes patch]
+ (the suggested patch was applied upstream)
+ Closes: #85151 "New upstream version available"
+ * patched gm_fat.h as suggested by Falk Hueffner <falk at debian.org>
+ Closes: #66893 "FAT detection broken on Alpha"
+ * debian standards 3.5.2 (support for DEB_BUILD_OPTIONS)
+
+ -- David Coe <david.coe at someotherplace.org> Sat, 24 Feb 2001 21:01:33 -0500
+
+gpart (0.1f-1) frozen unstable; urgency=medium
+
+ * new upstream version:
+ - Default scan increment is 'h' [head] again.
+ - Fixed wrong head-boundary condition. closes: #59147
+ - Introduced possibility to edit guessed partitions.
+ - Scan now starts on (sectors/head) unless -k <start> was given.
+ - Length of guessed NTFS partitions now includes NTFS backup boot
+ sector created by NT4.
+
+ -- David Coe <david.coe at someotherplace.org> Sun, 27 Feb 2000 22:02:45 -0500
+
+gpart (0.1e-2) frozen unstable; urgency=low
+
+ * added ARM architecture, thanks to Philip Blundell; closes: #58395
+
+ -- David Coe <david.coe at someotherplace.org> Fri, 18 Feb 2000 13:24:35 -0500
+
+gpart (0.1e-1) unstable; urgency=low
+
+ * new upstream version:
+ - Default scan increment now 's', extended partition table boundary
+ condition now depends on scan increment (head if 's', else cylinder
+ boundary).
+ - Added LVM physical volume module (LVM by Heinz Mauelshagen).
+ * Debian change to "Architecture: alpha i386", until upstream resolves
+ endianness and other architecture differences (closes: #46101);
+ forwarded various architecture/endianness suggestions upstream.
+ * Also improved upstream:
+ - A more detailed README.
+ * revised the man page (improved wording, format), at upstream
+ author's request; sent changes upstream.
+ * added TODO.Debian
+ * finished FHS transition; docs are now in /usr/share/doc/ with
+ appropriate compatibility symlink, thanks to debhelper.
+
+ -- David Coe <david.coe at someotherplace.org> Sun, 7 Nov 1999 04:18:14 +0000
+
+gpart (0.1d-1) unstable; urgency=low
+
+ * new upstream version
+ * changed for debian standards 3.0.1 and FHS (except for /usr/doc)
+
+ -- David L. Coe <david.coe at someotherplace.org> Fri, 20 Aug 1999 04:26:15 +0000
+
+gpart (0.1c-2) unstable; urgency=low
+
+ * install into /sbin rather than /usr/sbin (as explained in README.Debian)
+ * improved description
+
+ -- David L. Coe <david.coe at someotherplace.org> Tue, 1 Jun 1999 02:49:55 +0000
+
+gpart (0.1c-1) unstable; urgency=low
+
+ * initial debianization
+
+ -- David L. Coe <david.coe at someotherplace.org> Fri, 28 May 1999 22:49:11 +0000
+
+
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..ff87db4
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,43 @@
+Source: gpart
+Section: admin
+Priority: optional
+Maintainer: David Coe <davidc at debian.org>
+Standards-Version: 3.5.10
+Build-Depends: debhelper
+
+Package: gpart
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Guess PC disk partition table, find lost partitions
+ Gpart is a tool which tries to guess the primary partition table of a
+ PC-type disk in case the primary partition table in sector 0 is
+ damaged, incorrect or deleted.
+ .
+ It is also good at finding and listing the types, locations, and
+ sizes of inadvertently-deleted partitions, both primary and logical.
+ It gives you the information you need to manually re-create them
+ (using fdisk, cfdisk, sfdisk, etc.).
+ .
+ The guessed table can also be written to a file or (if you firmly
+ believe the guessed table is entirely correct) directly to a disk
+ device.
+ .
+ Supported (guessable) filesystem or partition types:
+ .
+ * BeOS filesystem type.
+ * FreeBSD/NetBSD/386BSD disklabel sub-partitioning
+ scheme used on Intel platforms.
+ * Linux second extended filesystem.
+ * MS-DOS FAT12/16/32 "filesystems".
+ * IBM OS/2 High Performance filesystem.
+ * Linux LVM physical volumes (LVM by Heinz Mauelshagen).
+ * Linux swap partitions (versions 0 and 1).
+ * The Minix operating system filesystem type.
+ * MS Windows NT/2000 filesystem.
+ * QNX 4.x filesystem.
+ * The Reiser filesystem (version 3.5.X, X > 11).
+ * Sun Solaris on Intel platforms uses a sub-partitioning
+ scheme on PC hard disks similar to the BSD disklabels.
+ * Silicon Graphics' journalling filesystem for Linux.
+ .
+ Other types may be added relatively easily, as separately compiled modules.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..d7489ed
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,10 @@
+This package was debianized by David L. Coe david.coe at someotherplace.org on
+Fri, 28 May 1999 22:49:11 +0000.
+
+It was downloaded from http://home.pages.de/~michab/gpart/
+
+Upstream Author: mb at ichabod.han.de (Michail Brzitwa)
+a.k.a. michail at brzitwa.de
+
+Copyright: GNU GENERAL PUBLIC LICENSE Version 2, June 1991
+Refer to /usr/share/common-licenses/GPL
diff --git a/debian/dirs b/debian/dirs
new file mode 100644
index 0000000..e1ae85e
--- /dev/null
+++ b/debian/dirs
@@ -0,0 +1 @@
+sbin
diff --git a/debian/docs b/debian/docs
new file mode 100644
index 0000000..493e865
--- /dev/null
+++ b/debian/docs
@@ -0,0 +1,3 @@
+README
+LSM
+debian/TODO.Debian
diff --git a/debian/ia64_and_others.patch b/debian/ia64_and_others.patch
new file mode 100644
index 0000000..0ab0cea
--- /dev/null
+++ b/debian/ia64_and_others.patch
@@ -0,0 +1,132 @@
+NOTE: this patch has already been applied, I'm just
+keeping it here for future reference.
+D. Coe 25 Nov 2001.
+
+X-From-Line: debbugs at master.debian.org Mon Nov 12 15:11:01 2001
+Return-Path: <debbugs at master.debian.org>
+Delivered-To: david at someotherplace.org
+Received: from master.debian.org (master.debian.org [216.234.231.5])
+ by zona.someotherplace.org (Postfix) with ESMTP id 74B7E7D006
+ for <david.coe at someotherplace.org>; Mon, 12 Nov 2001 15:11:00 -0500 (EST)
+Received: from debbugs by master.debian.org with local (Exim 3.12 1 (Debian))
+ id 163NIO-0001Oj-00; Mon, 12 Nov 2001 14:03:04 -0600
+Subject: Bug#119347: gpart: fix to build on ia64
+Reply-To: Doug Porter <dsp at debian.org>, 119347 at bugs.debian.org
+Resent-From: Doug Porter <dsp at debian.org>
+Original-Sender: dsp at waterspout.com
+Resent-To: debian-bugs-dist at lists.debian.org
+Resent-Cc: David Coe <davidc at debian.org>
+Resent-Date: Mon, 12 Nov 2001 20:03:03 GMT
+Resent-Message-ID: <handler.119347.B.10055952404995 at bugs.debian.org>
+X-Debian-PR-Message: report 119347
+X-Debian-PR-Package: gpart
+X-Debian-PR-Keywords: patch
+X-Loop: owner at bugs.debian.org
+Received: via spool by submit at bugs.debian.org id=B.10055952404995
+ (code B ref -1); Mon, 12 Nov 2001 20:03:03 GMT
+From: Doug Porter <dsp at debian.org>
+To: submit at bugs.debian.org
+Date: Mon, 12 Nov 2001 15:00:23 -0500
+Sender: dsp at waterspout.com
+X-Gnus-Mail-Source: file:/var/mail/david
+Message-Id: <20011112195918.2263D9B08 at squall.waterspout.com>
+Delivered-To: submit at bugs.debian.org
+Resent-Sender: Debian BTS <debbugs at master.debian.org>
+Lines: 106
+Xref: zona bugs.debian.org.owner:104
+
+Package: gpart
+Version: 0.1h-1
+Severity: important
+Tags: patch
+
+Currently the src/gm_ntfs.h that ships with gpart prevents gpart
+from building on a number of Debian's supported architectures. I
+have adapted some stuff that I pulled from recent 2.4 kernel
+source that should allow gpart to build on most Debian platforms
+without any trouble.
+
+
+diff -Naur gpart-0.1h.orig/src/gm_ntfs.h gpart-0.1h/src/gm_ntfs.h
+--- gpart-0.1h.orig/src/gm_ntfs.h Mon Nov 12 19:56:57 2001
++++ gpart-0.1h/src/gm_ntfs.h Mon Nov 12 19:57:28 2001
+@@ -14,6 +14,9 @@
+ *
+ */
+
++#include <stdint.h>
++#include <asm/byteorder.h>
++
+ #ifndef _GM_NTFS_H
+ #define _GM_NTFS_H
+
+@@ -29,32 +32,38 @@
+ /* 'NTFS' in little endian */
+ #define NTFS_SUPER_MAGIC 0x5346544E
+
+-#if defined(i386) || defined(__i386__) || defined(__alpha__) || defined(__arm__)
+-
+ /* unsigned integral types */
+ #ifndef NTFS_INTEGRAL_TYPES
+ #define NTFS_INTEGRAL_TYPES
+-typedef unsigned char ntfs_u8;
+-typedef unsigned short ntfs_u16;
+-typedef unsigned int ntfs_u32;
+-typedef s64_t ntfs_u64;
++typedef uint8_t ntfs_u8;
++typedef uint16_t ntfs_u16;
++typedef uint32_t ntfs_u32;
++typedef uint64_t ntfs_u64;
++typedef int8_t ntfs_s8;
++typedef int16_t ntfs_s16;
+ #endif /* NTFS_INTEGRAL_TYPES */
+-#endif /* defined(i386) || defined(__i386__) || defined(__alpha__) */
+-
+-
+-/* Macros reading unsigned integers from a byte pointer */
+-/* these should work for all little endian machines */
+-#define NTFS_GETU8(p) (*(ntfs_u8*)(p))
+-#define NTFS_GETU16(p) (*(ntfs_u16*)(p))
+-#define NTFS_GETU24(p) (NTFS_GETU32(p) & 0xFFFFFF)
+-#define NTFS_GETU32(p) (*(ntfs_u32*)(p))
+-#define NTFS_GETU64(p) (*(ntfs_u64*)(p))
+-
+-/* Macros reading signed integers, returning int */
+-#define NTFS_GETS8(p) ((int)(*(char*)(p)))
+-#define NTFS_GETS16(p) ((int)(*(short*)(p)))
+-#define NTFS_GETS24(p) (NTFS_GETU24(p) < 0x800000 ? (int)NTFS_GETU24(p) :
+-
+
++#define CPU_TO_LE16(a) __cpu_to_le16(a)
++#define CPU_TO_LE32(a) __cpu_to_le32(a)
++#define CPU_TO_LE64(a) __cpu_to_le64(a)
++
++#define LE16_TO_CPU(a) __cpu_to_le16(a)
++#define LE32_TO_CPU(a) __cpu_to_le32(a)
++#define LE64_TO_CPU(a) __cpu_to_le64(a)
++
++/* Macros reading unsigned integers */
++#define NTFS_GETU8(p) (*(ntfs_u8*)(p))
++#define NTFS_GETU16(p) ((ntfs_u16)LE16_TO_CPU(*(ntfs_u16*)(p)))
++#define NTFS_GETU24(p) ((ntfs_u32)NTFS_GETU16(p) | \
++ ((ntfs_u32)NTFS_GETU8(((char*)(p)) + 2) << 16))
++#define NTFS_GETU32(p) ((ntfs_u32)LE32_TO_CPU(*(ntfs_u32*)(p)))
++#define NTFS_GETU64(p) ((ntfs_u64)LE64_TO_CPU(*(ntfs_u64*)(p)))
++
++/* Macros reading signed integers */
++#define NTFS_GETS8(p) ((*(ntfs_s8*)(p)))
++#define NTFS_GETS16(p) ((ntfs_s16)LE16_TO_CPU(*(short*)(p)))
++#define NTFS_GETS24(p) (NTFS_GETU24(p) < 0x800000 ? \
++ (int)NTFS_GETU24(p) : \
++ (int)(NTFS_GETU24(p) - 0x1000000))
+
+ #endif /* _GM_NTFS_H */
+
+
+I hope this helps.
+
+--
+Doug Porter <dsp at waterspout.com>
+
+
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..601bafe
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,80 @@
+#!/usr/bin/make -f
+# MAde with the aid of dh_make, by Craig Small
+# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
+# Some lines taken from debmake, by Cristoph Lameter.
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+export OPTIMIZATION_FLAGS:=-O0
+endif
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+
+# # Add here commands to compile the package.
+
+ $(MAKE) DEBUG=1
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp install-stamp
+
+# # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+
+ dh_clean
+
+install: install-stamp
+install-stamp: build-stamp
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+# # Add here commands to install the package into debian/tmp.
+ $(MAKE) install-object DESTDIR=`pwd`/debian/tmp
+
+ touch install-stamp
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+# dh_testversion
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+# dh_installexamples
+# dh_installmenu
+# dh_installemacsen
+# dh_installinit
+# dh_installcron
+ dh_installmanpages
+# dh_undocumented
+ dh_installchangelogs Changes
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ dh_strip
+endif
+ dh_compress
+ dh_fixperms
+# dh_suidregister
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+# dh_makeshlibs
+ dh_md5sums
+ dh_builddeb
+
+source diff:
+ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
diff --git a/inst.defs b/inst.defs
index 575a27f..3f0760e 100644
--- a/inst.defs
+++ b/inst.defs
@@ -1,9 +1,23 @@
#
# installation directories for gpart
#
-prefix=/usr/local
-bindir=$(prefix)/bin
-libdir=$(prefix)/lib
-mandir=$(prefix)/man
+
+# Added by D. Coe for Debian GNU/Linux:
+DESTDIR =
+
+# Changed by D. Coe for Debian GNU/Linux:
+#prefix=/usr/local
+prefix=$(DESTDIR)
+
+# Changed by D. Coe for Debian GNU/Linux:
+# Install into sbin rather than bin
+bindir=$(prefix)/sbin
+
+# Not used -D. Coe:
+#libdir=$(prefix)/lib
+
+mandir=$(prefix)/usr/share/man
manext=8
-sharedir=$(prefix)/share
+
+# Not used -D. Coe:
+#sharedir=$(prefix)/share
diff --git a/man/gpart.man b/man/gpart.man
index 7ebbaf4..c97b4b5 100644
--- a/man/gpart.man
+++ b/man/gpart.man
@@ -63,8 +63,8 @@ MS Windows NT/2000 filesystem.
.I qnx4
QNX 4.x filesystem.
.TP
-.I rfs
-The Reiser filesystem (version 3.5.X, X > 11).
+.I reiserfs
+The Reiser filesystem (version 3.5.X, X > 11, 3.6.X).
.TP
.I s86dl
Sun Solaris on Intel platforms uses a sub-partitioning
diff --git a/src/Makefile b/src/Makefile
index fb3dd4b..50c1cdc 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -7,6 +7,8 @@ include ../make.defs
CFLAGS+=-DVERSION=\"$(version)\"
ifeq ($(shell uname),Linux)
LIBS=-ldl
+CFLAGS += -D__USE_FILE_OFFSET64 -D__USE_LARGEFILE64
+CFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
endif
ifdef DEBUG
@@ -19,7 +21,7 @@ CFLAGS+=-DGPART_LANG=\'$(GPART_LANG)\'
endif
-mod=ext2 lswap fat bsddl ntfs hpfs s86dl minix rfs hmlvm qnx4 beos xfs
+mod=ext2 lswap fat bsddl ntfs hpfs s86dl minix reiserfs hmlvm qnx4 beos xfs
modobj=$(foreach m,$(mod),gm_$(m).o)
obj=gpart.o gmodules.o disku.o l64seek.o $(modobj)
src=$(obj:.o=.c)
diff --git a/src/disku.c b/src/disku.c
index d340e66..a0df3a6 100644
--- a/src/disku.c
+++ b/src/disku.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
+#include <errno.h>
#include "gpart.h"
#if defined(__linux__)
diff --git a/src/gm_ext2.c b/src/gm_ext2.c
index bff7f10..81c2762 100644
--- a/src/gm_ext2.c
+++ b/src/gm_ext2.c
@@ -121,9 +121,10 @@ int ext2_gfun(disk_desc *d,g_module *m)
/*
* current mount count shouldn't be greater than max+20
+ * but ext3 usually has s_max_mnt_count==-1
*/
- if (sb->s_mnt_count > sb->s_max_mnt_count + 20)
+ if ((sb->s_max_mnt_count!=-1)&&(sb->s_mnt_count > sb->s_max_mnt_count + 20))
return (1);
/*
diff --git a/src/gm_fat.h b/src/gm_fat.h
index 506023a..5e0adf7 100644
--- a/src/gm_fat.h
+++ b/src/gm_fat.h
@@ -60,6 +60,10 @@ struct fat_boot_sector {
__u16 info_sector; /* filesystem info sector */
__u16 backup_boot; /* backup boot sector */
__u16 reserved2[6]; /* Unused */
-};
-
+} __attribute__ ((packed));
+/* "__attribute__ ((packed))"
+ added by davidc at debian.org,
+ as suggested by falk at zxmjz18.extern.uni-tuebingen.de
+ Fri Jul 07 18:04:15 2000
+ in debian bug report #66893 "FAT detection broken on Alpha" */
#endif /* _GM_FAT_H */
diff --git a/src/gm_ntfs.h b/src/gm_ntfs.h
index 89c953d..6752116 100644
--- a/src/gm_ntfs.h
+++ b/src/gm_ntfs.h
@@ -14,6 +14,9 @@
*
*/
+#include <stdint.h>
+#include <asm/byteorder.h>
+
#ifndef _GM_NTFS_H
#define _GM_NTFS_H
@@ -29,32 +32,38 @@
/* 'NTFS' in little endian */
#define NTFS_SUPER_MAGIC 0x5346544E
-#if defined(i386) || defined(__i386__) || defined(__alpha__)
-
/* unsigned integral types */
#ifndef NTFS_INTEGRAL_TYPES
#define NTFS_INTEGRAL_TYPES
-typedef unsigned char ntfs_u8;
-typedef unsigned short ntfs_u16;
-typedef unsigned int ntfs_u32;
-typedef s64_t ntfs_u64;
+typedef uint8_t ntfs_u8;
+typedef uint16_t ntfs_u16;
+typedef uint32_t ntfs_u32;
+typedef uint64_t ntfs_u64;
+typedef int8_t ntfs_s8;
+typedef int16_t ntfs_s16;
#endif /* NTFS_INTEGRAL_TYPES */
-#endif /* defined(i386) || defined(__i386__) || defined(__alpha__) */
-
-/* Macros reading unsigned integers from a byte pointer */
-/* these should work for all little endian machines */
-#define NTFS_GETU8(p) (*(ntfs_u8*)(p))
-#define NTFS_GETU16(p) (*(ntfs_u16*)(p))
-#define NTFS_GETU24(p) (NTFS_GETU32(p) & 0xFFFFFF)
-#define NTFS_GETU32(p) (*(ntfs_u32*)(p))
-#define NTFS_GETU64(p) (*(ntfs_u64*)(p))
+#define CPU_TO_LE16(a) __cpu_to_le16(a)
+#define CPU_TO_LE32(a) __cpu_to_le32(a)
+#define CPU_TO_LE64(a) __cpu_to_le64(a)
-/* Macros reading signed integers, returning int */
-#define NTFS_GETS8(p) ((int)(*(char*)(p)))
-#define NTFS_GETS16(p) ((int)(*(short*)(p)))
-#define NTFS_GETS24(p) (NTFS_GETU24(p) < 0x800000 ? (int)NTFS_GETU24(p) :
+#define LE16_TO_CPU(a) __cpu_to_le16(a)
+#define LE32_TO_CPU(a) __cpu_to_le32(a)
+#define LE64_TO_CPU(a) __cpu_to_le64(a)
+/* Macros reading unsigned integers */
+#define NTFS_GETU8(p) (*(ntfs_u8*)(p))
+#define NTFS_GETU16(p) ((ntfs_u16)LE16_TO_CPU(*(ntfs_u16*)(p)))
+#define NTFS_GETU24(p) ((ntfs_u32)NTFS_GETU16(p) | \
+ ((ntfs_u32)NTFS_GETU8(((char*)(p)) + 2) << 16))
+#define NTFS_GETU32(p) ((ntfs_u32)LE32_TO_CPU(*(ntfs_u32*)(p)))
+#define NTFS_GETU64(p) ((ntfs_u64)LE64_TO_CPU(*(ntfs_u64*)(p)))
+/* Macros reading signed integers */
+#define NTFS_GETS8(p) ((*(ntfs_s8*)(p)))
+#define NTFS_GETS16(p) ((ntfs_s16)LE16_TO_CPU(*(short*)(p)))
+#define NTFS_GETS24(p) (NTFS_GETU24(p) < 0x800000 ? \
+ (int)NTFS_GETU24(p) : \
+ (int)(NTFS_GETU24(p) - 0x1000000))
#endif /* _GM_NTFS_H */
diff --git a/src/gm_rfs.c b/src/gm_reiserfs.c
similarity index 66%
copy from src/gm_rfs.c
copy to src/gm_reiserfs.c
index 8c78b5a..79f0ca0 100644
--- a/src/gm_rfs.c
+++ b/src/gm_reiserfs.c
@@ -1,5 +1,5 @@
/*
- * gm_rfs.c -- gpart ReiserFS guessing module
+ * gm_reiserfs.c -- gpart ReiserFS guessing module
*
* gpart (c) 1999-2001 Michail Brzitwa <mb at ichabod.han.de>
* Guess PC-type hard disk partitions.
@@ -12,44 +12,47 @@
* Created: 21.01.1999 <mb at ichabod.han.de>
* Modified: 26.12.2000 Francis Devereux <francis at devereux.tc>
* Added reiserfs 3.5.28 support.
+ * Modified: 10.01.2003 Yury Umanets <umka at namesys.com>
+ * Added reiserfs 3.6.x support.
*
*/
#include <string.h>
#include <errno.h>
#include "gpart.h"
-#include "gm_rfs.h"
+#include "gm_reiserfs.h"
-static const char rcsid[] = "$Id: gm_rfs.c,v 1.5 2001/02/07 18:08:08 mb Exp mb $";
+static const char rcsid[] = "$Id: gm_reiserfs.c,v 1.5 2003/01/10 16:38:08 mb Exp mb $";
-int rfs_init(disk_desc *d,g_module *m)
+int reiserfs_init(disk_desc *d,g_module *m)
{
if ((d == 0) || (m == 0))
return (0);
- m->m_desc = "Reiser filesystem";
- return (REISERFS_FIRST_BLOCK * 1024 + SB_SIZE);
+ m->m_desc = "ReiserFS filesystem";
+ return (REISERFS_FIRST_BLOCK * 1024 + SB_V35_SIZE);
}
-int rfs_term(disk_desc *d)
+int reiserfs_term(disk_desc *d)
{
return (1);
}
-int rfs_gfun(disk_desc *d,g_module *m)
+int reiserfs_gfun(disk_desc *d,g_module *m)
{
- struct reiserfs_super_block *sb;
+ struct reiserfs_super_block_v35 *sb;
dos_part_entry *pt = &m->m_part;
s64_t size;
m->m_guess = GM_NO;
- sb = (struct reiserfs_super_block *)(d->d_sbuf + REISERFS_FIRST_BLOCK * 1024);
- if (strncmp(sb->s_magic,REISERFS_SUPER_MAGIC,12) == 0)
+ sb = (struct reiserfs_super_blockv35 *)(d->d_sbuf + REISERFS_FIRST_BLOCK * 1024);
+ if (strncmp(sb->s_magic,REISERFS_SUPER_V35_MAGIC,12) == 0 ||
+ strncmp(sb->s_magic,REISERFS_SUPER_V36_MAGIC,12) == 0)
{
/*
* sanity checks.
diff --git a/src/gm_rfs.h b/src/gm_reiserfs.h
similarity index 75%
copy from src/gm_rfs.h
copy to src/gm_reiserfs.h
index da86cc5..c653d16 100644
--- a/src/gm_rfs.h
+++ b/src/gm_reiserfs.h
@@ -1,5 +1,5 @@
/*
- * gm_rfs.h -- gpart ReiserFS guessing module header
+ * gm_reiserfs.h -- gpart ReiserFS guessing module header
*
* gpart (c) 1999-2001 Michail Brzitwa <mb at ichabod.han.de>
* Guess PC-type hard disk partitions.
@@ -12,11 +12,13 @@
* Created: 21.01.1999 <mb at ichabod.han.de>
* Modified: 26.12.2000 Francis Devereux <francis at devereux.tc>
* Update support reiserfs version 3.5.28
+ * Modified: 10.01.2003 Yury Umanets <umka at namesys.com>
+ * Added reiserfs 3.6.x support.
*
*/
-#ifndef _GM_RFS_H
-#define _GM_RFS_H
+#ifndef _GM_reiserfs_H
+#define _GM_reiserfs_H
/* imported from asm/types.h */
typedef __signed__ char __s8;
@@ -29,16 +31,18 @@ typedef __signed__ int __s32;
typedef unsigned int __u32;
/*
- * taken from ReiserFS v3.5.28. Reiserfs Copyright 1996-2000 Hans Reiser
+ * taken from ReiserFS v3.5.28, v3.6.x. Reiserfs Copyright 1996-2000 Hans Reiser
*/
-#define REISERFS_SUPER_MAGIC "ReIsErFs"
+#define REISERFS_SUPER_V35_MAGIC "ReIsErFs"
+#define REISERFS_SUPER_V36_MAGIC "ReIsEr2Fs"
+
#define REISERFS_FIRST_BLOCK 64
#define REISERFS_VALID_FS 1
#define REISERFS_ERROR_FS 2
#define REISERFS_MIN_BLOCK_AMOUNT 100
-struct reiserfs_super_block
+struct reiserfs_super_block_v35
{
__u32 s_block_count; /* blocks count */
__u32 s_free_blocks; /* free blocks count */
@@ -62,7 +66,17 @@ struct reiserfs_super_block
__u16 s_reserved;
};
-#define SB_SIZE (sizeof(struct reiserfs_super_block))
+#define SB_V35_SIZE (sizeof(struct reiserfs_super_block_v35))
+
+struct reiserfs_super_block_v36 {
+ struct reiserfs_super_block_v35 s_v35;
+ __u32 s_inode_generation;
+ __u32 s_flags;
+ char s_uuid[16];
+ char s_label[16];
+ char s_unused[88];
+};
+#define SB_V36_SIZE (sizeof(struct reiserfs_super_block_v36))
-#endif /* _GM_RFS_H */
+#endif /* _GM_REISERFS_H */
diff --git a/src/gmodules.c b/src/gmodules.c
index f56aae0..504ff9d 100644
--- a/src/gmodules.c
+++ b/src/gmodules.c
@@ -154,7 +154,7 @@ void g_mod_addinternals()
GMODINS(bsddl);
GMODINS(lswap);
GMODINS(qnx4);
- GMODINS(rfs);
+ GMODINS(reiserfs);
GMODINS(ntfs);
GMODINS(hpfs);
GMODINS(minix);
diff --git a/src/gmodules.h b/src/gmodules.h
index c28e3ad..1b6ffbb 100644
--- a/src/gmodules.h
+++ b/src/gmodules.h
@@ -63,7 +63,7 @@ g_module *g_mod_setweight(char *,float);
GMODDECL(bsddl); GMODDECL(ext2); GMODDECL(fat);
GMODDECL(hpfs); GMODDECL(lswap); GMODDECL(ntfs);
-GMODDECL(s86dl); GMODDECL(minix); GMODDECL(rfs);
+GMODDECL(s86dl); GMODDECL(minix); GMODDECL(reiserfs);
GMODDECL(hmlvm); GMODDECL(qnx4); GMODDECL(beos);
GMODDECL(xfs);
diff --git a/src/l64seek.c b/src/l64seek.c
index 55b3a87..f3c09d8 100644
--- a/src/l64seek.c
+++ b/src/l64seek.c
@@ -25,30 +25,11 @@ static struct
} ostck[OSTACKLEN];
static int osptr = -1;
-#if defined(__linux__) && defined(__i386__)
-_syscall5(int,_llseek,uint,fd,ulong,hi,ulong,lo,loff_t *,res,uint,wh)
-#endif
-
-
-
off64_t l64seek(int fd,off64_t offset,int whence)
{
off64_t ret = (off64_t)-1;
-#if defined(__linux__) && defined(__i386__)
- int iret;
- unsigned long ohi, olo;
-
- ohi = (unsigned long)((offset >> 32) & 0xFFFFFFFF);
- olo = (unsigned long)(offset & 0xFFFFFFFF);
- iret = _llseek(fd,ohi,olo,&ret,whence);
- if (iret == -1)
- ret = (off64_t)-1;
-#endif
-
-#if defined(__FreeBSD__) || (defined(__linux__) && defined(__alpha__))
ret = lseek(fd,offset,whence);
-#endif
return (ret);
}
diff --git a/src/l64seek.h b/src/l64seek.h
index 946a7cf..669b655 100644
--- a/src/l64seek.h
+++ b/src/l64seek.h
@@ -17,6 +17,8 @@
#ifndef _L64SEEK_H
#define _L64SEEK_H
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
/*
@@ -25,19 +27,7 @@
* offsets.
*/
-
-#if defined(__linux__)
-# include <linux/unistd.h>
-# include <sys/types.h>
- typedef int64_t off64_t;
-#endif
-
-
-#if defined(__FreeBSD__)
- typedef off_t off64_t;
-#endif
-
-
+typedef loff_t off64_t;
typedef off64_t s64_t;
off64_t l64seek(int fd, off64_t offset, int whence);
@@ -45,5 +35,4 @@ off64_t l64seek(int fd, off64_t offset, int whence);
int l64opush(int);
s64_t l64opop(int);
-
#endif
--
Guess PC disk partition table, find lost partitions
More information about the forensics-changes
mailing list