- Re-add sysutils/gpart, another useful port removed with no reason

A port of a tool which tries to guess the primary partition table of a PC-type
hard disk in case the primary partition table in sector 0 is damaged, incorrect
or deleted. The guessed table can be written to a file or device.

Supported (guessable) filesystem or partition types: DOS/Windows FAT, Linux
ext2 and swap, OS/2 HPFS, Windows NTFS, FreeBSD and Solaris/x86 disklabels,
Minix FS, Reiser FS

WWW: http://brzitwa.de/mb/gpart/index.html (outdated)
This commit is contained in:
Dmitry Marakasov 2013-09-14 10:54:57 +00:00
parent 5b409d8e89
commit 155f07275f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=327267
12 changed files with 215 additions and 1 deletions

1
MOVED
View File

@ -2607,7 +2607,6 @@ editors/openoffice.org-2|editors/openoffice.org-3|2011-09-20|Unsupported upstrea
devel/monodevelop-boo||2011-09-21|Removed
www/ruby-http-access||2011-09-22|Has expired: Deprecated upstream, please use www/rubygem-httpclient
sysutils/wots||2011-09-22|Has expired: No more public distfiles
sysutils/gpart||2011-09-22|Has expired: Upstream disappeared
sysutils/plod||2011-09-22|Has expired: No more public distfiles
sysutils/checkservice||2011-09-22|Has expired: BROKEN for more than 6 months
security/nsm-console||2011-09-22|Has expired: BROKEN for more than 6 months

View File

@ -342,6 +342,7 @@
SUBDIR += gnomebaker
SUBDIR += goaccess
SUBDIR += gosa
SUBDIR += gpart
SUBDIR += gpkgdep
SUBDIR += gpte
SUBDIR += graid5

31
sysutils/gpart/Makefile Normal file
View File

@ -0,0 +1,31 @@
# Created by: Andrew Stevenson <andrew@ugh.net.au>
# $FreeBSD$
PORTNAME= gpart
PORTVERSION= 0.1h
PORTREVISION= 2
CATEGORIES= sysutils
MASTER_SITES= SUNSITE/system/filesystems \
http://mirror.amdmi3.ru/distfiles/
MAINTAINER= amdmi3@FreeBSD.org
COMMENT= Tries to recover lost partition tables and file systems
LICENSE= GPLv2
USES= gmake
MAN8= gpart.8
PLIST_FILES= sbin/gpart
CFLAGS+= -std=c99
.if defined(WANT_STATIC)
MAKE_ARGS+= LDFLAGS=-static
.endif
.include <bsd.port.pre.mk>
.if ${ARCH} != "i386" && ${ARCH} != "alpha" && ${ARCH} != "amd64"
BROKEN= Only compiles on i386, amd64 and alpha.
.endif
.include <bsd.port.post.mk>

2
sysutils/gpart/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (gpart-0.1h.tar.gz) = b542bceb1a778c719304dadae5dbc2a8bd7f195c06774933e7255b98cfa46ee3
SIZE (gpart-0.1h.tar.gz) = 52357

View File

@ -0,0 +1,13 @@
--- ./inst.defs.orig 2000-12-13 23:45:49.000000000 +0100
+++ ./inst.defs 2011-03-17 01:15:54.000000000 +0100
@@ -1,8 +1,8 @@
#
# installation directories for gpart
#
-prefix=/usr/local
-bindir=$(prefix)/bin
+prefix=$(PREFIX)
+bindir=$(prefix)/sbin
libdir=$(prefix)/lib
mandir=$(prefix)/man
manext=8

View File

@ -0,0 +1,16 @@
--- ./make.defs.orig 2001-01-29 20:17:12.000000000 +0100
+++ ./make.defs 2011-03-17 01:15:54.000000000 +0100
@@ -1,10 +1,10 @@
#
#
#
-CC = gcc
-CFLAGS = -Wall -O2 -pedantic
+CC ?= gcc
+CFLAGS += -Wall -pedantic
LDFLAGS =
-MAKEDEP = gcc -M
+MAKEDEP = $(CC) -M
INSTALL = install
RM = rm -f
#

View File

@ -0,0 +1,11 @@
--- ./man/gpart.man.orig 2001-02-07 18:54:18.000000000 +0100
+++ ./man/gpart.man 2011-03-17 01:15:54.000000000 +0100
@@ -378,7 +378,7 @@
drive without starting the scan loop in FreeBSD type
.RS
-gpart -vvd /dev/wd2
+gpart -vvd /dev/ad2
.RE
.RE

View File

@ -0,0 +1,45 @@
--- ./src/disku.c.orig 2001-02-07 20:04:07.000000000 +0100
+++ ./src/disku.c 2011-03-17 01:15:54.000000000 +0100
@@ -28,7 +28,9 @@
#if defined(__FreeBSD__)
#include <errno.h>
+#include <sys/param.h>
#include <sys/disklabel.h>
+#include <sys/disk.h>
#endif
@@ -61,12 +63,26 @@
#endif
#if defined(__FreeBSD__)
- struct disklabel dl;
- if (ioctl(d->d_fd,DIOCGDINFO,&dl) == -1)
- pr(FATAL,EM_IOCTLFAILED,"DIOCGDINFO",strerror(errno));
- g.d_c = dl.d_ncylinders;
- g.d_h = dl.d_ntracks;
- g.d_s = dl.d_nsectors;
+ struct disklabel loclab;
+ u_int u;
+ off_t o; /* total disk size */
+
+ if (ioctl(d->d_fd, DIOCGFWSECTORS, &u) == 0)
+ g.d_s = u;
+ else
+ pr(FATAL, EM_IOCTLFAILED, "DIOCGFWSECTORS", strerror(errno));
+ // loclab.d_nsectors = 63;
+ if (ioctl(d->d_fd, DIOCGFWHEADS, &u) == 0)
+ g.d_h = u;
+ else
+ pr(FATAL, EM_IOCTLFAILED, "DIOCGFWHEADS", strerror(errno));
+ if (ioctl(d->d_fd, DIOCGSECTORSIZE, &u) == 0)
+ if (u != 512)
+ pr(FATAL, "sector size not a multiple of 512");
+ if (ioctl(d->d_fd, DIOCGMEDIASIZE, &o))
+ pr(FATAL, EM_IOCTLFAILED, "DIOCGMEDIASIZE", strerror(errno));
+
+ g.d_c = o / u / g.d_h / g.d_s;
#endif
return (&g);

View File

@ -0,0 +1,11 @@
--- ./src/gm_bsddl.h.orig 2000-12-13 23:54:31.000000000 +0100
+++ ./src/gm_bsddl.h 2011-03-17 01:15:54.000000000 +0100
@@ -28,7 +28,7 @@
#define BBSIZE 8192 /* size of boot area, with label */
-#ifdef __i386__
+#if defined(__i386__) || defined(__amd64__)
#define LABELSECTOR 1 /* sector containing label */
#define LABELOFFSET 0 /* offset of label in sector */
#endif

View File

@ -0,0 +1,34 @@
--- ./src/gm_ntfs.h.orig 2001-01-29 21:33:58.000000000 +0100
+++ ./src/gm_ntfs.h 2011-03-17 01:15:54.000000000 +0100
@@ -29,17 +29,16 @@
/* 'NTFS' in little endian */
#define NTFS_SUPER_MAGIC 0x5346544E
-#if defined(i386) || defined(__i386__) || defined(__alpha__)
+#include <stdint.h>
/* 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;
#endif /* NTFS_INTEGRAL_TYPES */
-#endif /* defined(i386) || defined(__i386__) || defined(__alpha__) */
/* Macros reading unsigned integers from a byte pointer */
@@ -53,8 +52,5 @@
/* 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) :
-
-
#endif /* _GM_NTFS_H */

View File

@ -0,0 +1,42 @@
--- ./src/gpart.h.orig 2001-01-31 00:07:29.000000000 +0100
+++ ./src/gpart.h 2011-03-17 01:15:54.000000000 +0100
@@ -22,8 +22,9 @@
#define PROGRAM "gpart"
+#include <stdint.h>
-typedef unsigned char byte_t;
+typedef uint8_t byte_t;
@@ -31,7 +32,7 @@
* endianness (incomplete, later)
*/
-#if defined(__i386__) || defined(__alpha__)
+#if defined(__i386__) || defined(__amd64__) || defined(__alpha__)
# define le16(x) (x) /* x as little endian */
# define be16(x) ((((x)&0xff00)>>8) | \
(((x)&0x00ff)<<8))
@@ -112,8 +113,8 @@
byte_t p_ehd; /* end head */
byte_t p_esect; /* end sector */
byte_t p_ecyl; /* end cylinder */
- unsigned long p_start; /* start sector (absolute) */
- unsigned long p_size; /* # of sectors */
+ uint32_t p_start; /* start sector (absolute) */
+ uint32_t p_size; /* # of sectors */
} dos_part_entry;
@@ -123,7 +124,7 @@
byte_t _align[2];
byte_t t_boot[DOSPARTOFF];
dos_part_entry t_parts[NDOSPARTS];
- unsigned short t_magic; /* DOSPTMAGIC */
+ uint16_t t_magic; /* DOSPTMAGIC */
} dos_part_table;

9
sysutils/gpart/pkg-descr Normal file
View File

@ -0,0 +1,9 @@
A port of a tool which tries to guess the primary partition table of a PC-type
hard disk in case the primary partition table in sector 0 is damaged, incorrect
or deleted. The guessed table can be written to a file or device.
Supported (guessable) filesystem or partition types: DOS/Windows FAT, Linux
ext2 and swap, OS/2 HPFS, Windows NTFS, FreeBSD and Solaris/x86 disklabels,
Minix FS, Reiser FS
WWW: http://brzitwa.de/mb/gpart/index.html (outdated)