Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jun 2003 10:05:58 +0300 (EEST)
From:      Valentin Nechayev <netch@netch.kiev.ua>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/53666: Update port: sysutils/linuxfdisk
Message-ID:  <200306240705.h5O75wjp003776@iv.nn.kiev.ua>
Resent-Message-ID: <200306240710.h5O7AIpu005261@freefall.freebsd.org>

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

>Number:         53666
>Category:       ports
>Synopsis:       Update port: sysutils/linuxfdisk
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 24 00:10:17 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Valentin Nechayev
>Release:        FreeBSD 5.1-RELEASE i386
>Organization:
Home sweet home
>Environment:
FreeBSD 5.1-RELEASE i386
FreeBSD 4.8-RELEASE i386
>Description:

Added two another fdisking;) utilities from this package: sfdisk (command-line
batch tool) and cfdisk (curses-based interactive tool).

Renamed binaries. Among many variants as lfdisk, linfdisk, linuxfdisk, etc.,
I decided that fdisk-linux, cfdisk-linux, sfdisk-linux will be almost
optimal (not better, but the least bad). The criteria was visual parseability
and easiness of completion in bash/zsh ;)

Removed unneeded building cludges (symlink for WRKSRC, copying of manpages).

Fixed some system-dependent issues: synchronizing on GEOM'ed 5.* which
is unfixably implicit and not forceable; get slice size on 4.x using
trick based on DIOCGSLICEINFO.

PORTREVISION wasn't bumped in attached contents.

>How-To-Repeat:
>Fix:

Full port contents are attached.

>Release-Note:
>Audit-Trail:
>Unformatted:
# 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:
#
#	./files/linuxfdisk-Makefile
#	./files/linuxfdisk-sys_bsd.c
#	./files/patch-aa
#	./Makefile
#	./distinfo
#	./pkg-descr
#	./pkg-plist
#
echo x - ./files/linuxfdisk-Makefile
sed 's/^X//' >./files/linuxfdisk-Makefile << 'END-of-./files/linuxfdisk-Makefile'
Xall: fdisk cfdisk sfdisk
X
XFDISK_OBJS = fdisk.o i386_sys_types.o partname.o \
X	fdiskbsdlabel.o fdisksunlabel.o fdiskaixlabel.o fdisksgilabel.o \
X	sys_bsd.o
X
XSFDISK_OBJS = sfdisk.o sys_bsd.o i386_sys_types.o partname.o getopt.o getopt1.o
X
XCFDISK_OBJS = cfdisk.o sys_bsd.o i386_sys_types.o
X
XCFLAGS += -DUTIL_LINUX_VERSION=\"2.11z\" -I../getopt/gnu
X
XINSTALL?=	install -c
X## Debug
X#CFLAGS+=	-O0 -g -Wall
X
Xfdisk: $(FDISK_OBJS)
X	$(CC) -o fdisk $(FDISK_OBJS)
X
Xsfdisk: $(SFDISK_OBJS)
X	$(CC) -o sfdisk $(SFDISK_OBJS)
X
Xcfdisk: $(CFDISK_OBJS)
X	$(CC) -o cfdisk $(CFDISK_OBJS) -lncurses
X
Xgetopt.o: ../getopt/gnu/getopt.c
Xgetopt1.o: ../getopt/gnu/getopt1.c
X
Xinstall:
X	$(INSTALL) -c -m 0555 -s fdisk ${DESTDIR}${PREFIX}/sbin/fdisk-linux
X	$(INSTALL) -c -m 0555 -s cfdisk ${DESTDIR}${PREFIX}/sbin/cfdisk-linux
X	$(INSTALL) -c -m 0555 -s sfdisk ${DESTDIR}${PREFIX}/sbin/sfdisk-linux
X	$(INSTALL) -c -m 0644 fdisk.8 ${DESTDIR}${PREFIX}/man/man8/fdisk-linux.8
X	$(INSTALL) -c -m 0644 cfdisk.8 ${DESTDIR}${PREFIX}/man/man8/cfdisk-linux.8
X	$(INSTALL) -c -m 0644 sfdisk.8 ${DESTDIR}${PREFIX}/man/man8/sfdisk-linux.8
END-of-./files/linuxfdisk-Makefile
echo x - ./files/linuxfdisk-sys_bsd.c
sed 's/^X//' >./files/linuxfdisk-sys_bsd.c << 'END-of-./files/linuxfdisk-sys_bsd.c'
X#include <sys/param.h>
X#include <sys/disklabel.h>
X#if __FreeBSD_version < 500000
X#include <sys/diskslice.h>
X#include <sys/stat.h>
X#else
X#include <sys/disk.h>
X#include <errno.h>
X#endif
X#include <stddef.h>
X#include "common.h"
X
Xunsigned int
Xsys_bsd_sectorsize(int fd)
X{
X#ifdef DIOCGSECTORSIZE
X	;{
X		unsigned int d;
X		if (ioctl(fd, DIOCGSECTORSIZE, &d) == 0)
X			return d;
X	}
X#endif
X	;{
X		struct disklabel dl;
X		if (ioctl(fd, DIOCGDINFO, &dl) == 0)
X			return dl.d_secsize;
X	}
X#ifdef DIOCGSLICEINFO
X	;{
X		struct diskslices dss;
X		if (ioctl(fd, DIOCGSLICEINFO, &dss) == 0)
X			return dss.dss_secsize;
X	}
X#endif
X	return 0;
X}
X
Xint
Xsys_bsd_getsectors(int fd, unsigned long *s)
X{
X	/* XXX */
X	struct disklabel dl;
X#if defined(DIOCGMEDIASIZE) && defined(DIOCGSECTORSIZE)
X	;{
X		off_t fullsize;
X		unsigned sectsize;
X		if (ioctl(fd, DIOCGMEDIASIZE, &fullsize) == 0 &&
X		    ioctl(fd, DIOCGSECTORSIZE, &sectsize) == 0)
X		{
X			*s = fullsize / sectsize;
X			return 0;
X		}
X	}
X#endif
X#ifdef DIOCGSLICEINFO
X	/* XXX it is somehow ugly, but seems to work on 4.x. */
X	;{
X		struct diskslices dss;
X		struct stat st;
X		if (ioctl(fd, DIOCGSLICEINFO, &dss) == 0 &&
X		    fstat(fd, &st) == 0)
X		{
X			int slice = 31 & (st.st_rdev >> 16);
X			/* If it have disklabel, fall to disklabel case,
X			 * because it shows more exact info.
X			 */
X			if (slice != WHOLE_DISK_SLICE &&
X			    dss.dss_slices[slice].ds_label != NULL &&
X			    ioctl(fd, DIOCGDINFO, &dl) == 0) {
X				*s = (unsigned long) dl.d_secperunit;
X				return 0;
X			}
X			*s = dss.dss_slices[slice].ds_size;
X			return 0;
X		}
X	}
X#endif
X	/* Fallback method. */
X	if (ioctl(fd, DIOCGDINFO, &dl) == 0) {
X		*s = (unsigned long) dl.d_secperunit;
X		return 0;
X	}
X	return -1;
X}
X
Xint
Xsys_bsd_ptsync(int fd)
X{
X#ifdef DIOCSYNCSLICEINFO
X	return ioctl(fd, DIOCSYNCSLICEINFO, NULL);
X#else
X	/* XXX I suppose here GEOM systems which:
X	 * 1) Don't allow writing to raw disk if it is mounted anywhere,
X	 * 2) Automatically update GEOM structures after writing to disk.
X	 * Hence, no explicit syncing is required.
X	 */
X	return 0;
X#endif
X}
X
Xint
Xsys_bsd_getgeometry(int fd, struct hd_geometry *g)
X{
X	/* XXX */
X	struct disklabel dl;
X	if (ioctl(fd, DIOCGDINFO, &dl) < 0)
X		return -1;
X	g->cylinders = dl.d_ncylinders;
X	g->heads = dl.d_ntracks;
X	g->sectors = dl.d_nsectors;
X	return 0;
X}
END-of-./files/linuxfdisk-sys_bsd.c
echo x - ./files/patch-aa
sed 's/^X//' >./files/patch-aa << 'END-of-./files/patch-aa'
Xdiff -rNu cfdisk.c cfdisk.c
X--- cfdisk.c	Tue Nov 26 18:44:33 2002
X+++ cfdisk.c	Fri Jun 20 19:47:15 2003
X@@ -76,25 +76,14 @@
X #include <string.h>
X #include <sys/stat.h>
X #include <sys/ioctl.h>
X-#include <linux/types.h>
X 
X #include "nls.h"
X-#include "xstrncpy.h"
X #include "common.h"
X 
X-#if defined(__GNUC__) || defined(HAS_LONG_LONG)
X-typedef long long ext2_loff_t;
X-#else
X-typedef long      ext2_loff_t;
X-#endif
X-
X-extern ext2_loff_t ext2_llseek(unsigned int fd, ext2_loff_t offset,
X-			       unsigned int origin);
X-
X #define VERSION UTIL_LINUX_VERSION
X 
X-#define DEFAULT_DEVICE "/dev/hda"
X-#define ALTERNATE_DEVICE "/dev/sda"
X+#define DEFAULT_DEVICE "/dev/ad0"
X+#define ALTERNATE_DEVICE "/dev/da0"
X 
X /* With K=1024 we have `binary' megabytes, gigabytes, etc.
X    Some misguided hackers like that.
X@@ -324,7 +313,8 @@
X int logical = 0;
X int logical_sectors[MAXIMUM_PARTS];
X 
X-__sighandler_t old_SIGINT, old_SIGTERM;
X+void (*old_SIGINT)(int);
X+void (*old_SIGTERM)(int);
X 
X int arrow_cursor = FALSE;
X int display_units = MEGABYTES;
X@@ -571,7 +561,7 @@
X 
X static void
X read_sector(char *buffer, int sect_num) {
X-    if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
X+    if (lseek(fd, ((off_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
X 	fatal(_("Cannot seek on disk drive"), 2);
X     if (read(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE)
X 	fatal(_("Cannot read disk drive"), 2);
X@@ -579,7 +569,7 @@
X 
X static void
X write_sector(char *buffer, int sect_num) {
X-    if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
X+    if (lseek(fd, ((off_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
X 	fatal(_("Cannot seek on disk drive"), 2);
X     if (write(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE)
X 	fatal(_("Cannot write disk drive"), 2);
X@@ -603,11 +593,11 @@
X #define DOS_OSTYPE_SZ 8
X #define DOS_LABEL_SZ 11
X #define DOS_FSTYPE_SZ 8
X-	ext2_loff_t offset;
X+	off_t offset;
X 
X-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
X+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
X 		* SECTOR_SIZE;
X-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
X+	if (lseek(fd, offset, SEEK_SET) == offset
X 	    && read(fd, &sector, sizeof(sector)) == sizeof(sector)) {
X 		dos_copy_to_info(p_info[i].ostype, OSTYPESZ,
X 				 sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ);
X@@ -664,12 +654,12 @@
X 	} xfsb;
X 
X 	char *label;
X-	ext2_loff_t offset;
X+	off_t offset;
X 	int j;
X 
X-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
X+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
X 		* SECTOR_SIZE + 1024;
X-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
X+	if (lseek(fd, offset, SEEK_SET) == offset
X 	    && read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb)
X 	    && e2fsb.s_magic[0] + (e2fsb.s_magic[1]<<8) == EXT2_SUPER_MAGIC) {
X 		label = e2fsb.s_volume_name;
X@@ -684,9 +674,9 @@
X 		return;
X 	}
X 
X-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
X+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
X 		* SECTOR_SIZE + 0;
X-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
X+	if (lseek(fd, offset, SEEK_SET) == offset
X 	    && read(fd, &xfsb, sizeof(xfsb)) == sizeof(xfsb)
X 	    && !strcmp(xfsb.s_magic, XFS_SUPER_MAGIC)) {
X 		label = xfsb.s_fname;
X@@ -698,9 +688,9 @@
X 	}
X 
X 	/* reiserfs? */
X-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
X+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
X 		* SECTOR_SIZE + REISERFS_DISK_OFFSET_IN_BYTES;
X-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
X+	if (lseek(fd, offset, SEEK_SET) == offset
X 	    && read(fd, &reiserfsb, 1024) == 1024
X 	    && is_reiserfs_magic_string(&reiserfsb)) {
X 		strncpy(p_info[i].fstype, "reiserfs", FSTYPESZ);
X@@ -1140,7 +1130,7 @@
X             print_warning(_("Menu item too long. Menu may look odd."));
X #endif
X 	if (lenName >= sizeof(buff)) {	/* truncate ridiculously long string */
X-	    xstrncpy(buff, mi, sizeof(buff));
X+	    strlcpy(buff, mi, sizeof(buff));
X 	} else {
X             snprintf(buff, sizeof(buff),
X 		     (menuType & MENU_BUTTON) ? "[%*s%-*s]" : "%*s%-*s",
X@@ -1605,17 +1595,7 @@
X 	 opentype = O_RDWR;
X     opened = TRUE;
X 
X-    /* Blocks are visible in more than one way:
X-       e.g. as block on /dev/hda and as block on /dev/hda3
X-       By a bug in the Linux buffer cache, we will see the old
X-       contents of /dev/hda when the change was made to /dev/hda3.
X-       In order to avoid this, discard all blocks on /dev/hda.
X-       Note that partition table blocks do not live in /dev/hdaN,
X-       so this only plays a role if we want to show volume labels. */
X-    ioctl(fd, BLKFLSBUF);	/* ignore errors */
X-				/* e.g. Permission Denied */
X-
X-    if (ioctl(fd, BLKGETSIZE, &actual_size))
X+    if (sys_bsd_getsectors(fd, &actual_size))
X 	fatal(_("Cannot get disk size"), 3);
X 
X     read_sector(buffer.c.b, 0);
X@@ -1824,7 +1804,7 @@
X     if (is_bdev) {
X 	 sync();
X 	 sleep(2);
X-	 if (!ioctl(fd,BLKRRPART))
X+	 if (!sys_bsd_ptsync(fd))
X 	      changed = TRUE;
X 	 sync();
X 	 sleep(4);
X@@ -2850,9 +2830,11 @@
X     int c;
X     int i, len;
X 
X+#if 0
X     setlocale(LC_ALL, "");
X     bindtextdomain(PACKAGE, LOCALEDIR);
X     textdomain(PACKAGE);
X+#endif
X 
X     while ((c = getopt(argc, argv, "ac:gh:s:vzP:")) != -1)
X 	switch (c) {
Xdiff -rNu common.h common.h
X--- common.h	Thu May  9 02:50:35 2002
X+++ common.h	Fri Jun 20 19:25:55 2003
X@@ -1,11 +1,10 @@
X /* common stuff for fdisk, cfdisk, sfdisk */
X 
X-/* including <linux/fs.h> fails */
X-#include <sys/ioctl.h>
X-#define BLKRRPART  _IO(0x12,95)    /* re-read partition table */
X-#define BLKGETSIZE _IO(0x12,96)    /* return device size */
X-#define BLKFLSBUF  _IO(0x12,97)    /* flush buffer cache */
X-#define BLKSSZGET  _IO(0x12,104)   /* get block device sector size */
X+#include <sys/types.h>
X+typedef u_int16_t __u16;
X+typedef u_int32_t __u32;
X+typedef int16_t __s16;
X+typedef u_int8_t __u8;
X 
X /* including <linux/hdreg.h> also fails */
X struct hd_geometry {
X@@ -15,9 +14,6 @@
X       unsigned long start;
X };
X 
X-#define HDIO_GETGEO		0x0301	/* get device geometry */
X-
X-
X struct systypes {
X 	unsigned char type;
X 	char *name;
X@@ -26,3 +22,8 @@
X extern struct systypes i386_sys_types[];
X 
X extern char *partname(char *dev, int pno, int lth);
X+
X+unsigned int sys_bsd_sectorsize(int fd);
X+int sys_bsd_getsectors(int fd, unsigned long* s);
X+int sys_bsd_ptsync(int fd);
X+int sys_bsd_getgeometry(int, struct hd_geometry*);
Xdiff -rNu fdisk.c fdisk.c
X--- fdisk.c	Sat Nov 23 18:05:24 2002
X+++ fdisk.c	Fri Jun 20 19:25:55 2003
X@@ -37,11 +37,6 @@
X #include "fdisksgilabel.h"
X #include "fdiskaixlabel.h"
X 
X-#include "../defines.h"
X-#ifdef HAVE_blkpg_h
X-#include <linux/blkpg.h>
X-#endif
X-
X static void delete_partition(int i);
X 
X #define hex_val(c)	({ \
X@@ -198,8 +193,8 @@
X "       fdisk -l [-b SSZ] [-u] DISK  List partition table(s)\n"
X "       fdisk -s PARTITION           Give partition size(s) in blocks\n"
X "       fdisk -v                     Give fdisk version\n"
X-"Here DISK is something like /dev/hdb or /dev/sda\n"
X-"and PARTITION is something like /dev/hda7\n"
X+"Here DISK is something like /dev/ad1 or /dev/da0\n"
X+"and PARTITION is something like /dev/ad0s7\n"
X "-u: give Start and End in sector (instead of cylinder) units\n"
X "-b 2048: (for certain MO disks) use 2048-byte sectors\n");
X 			break;
X@@ -207,10 +202,8 @@
X 		  /* msg in cases where fdisk used to probe */
X 			message = _(
X "Usage: fdisk [-l] [-b SSZ] [-u] device\n"
X-"E.g.: fdisk /dev/hda  (for the first IDE disk)\n"
X-"  or: fdisk /dev/sdc  (for the third SCSI disk)\n"
X-"  or: fdisk /dev/eda  (for the first PS/2 ESDI drive)\n"
X-"  or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)\n"
X+"E.g.: fdisk /dev/ad0  (for the first IDE disk)\n"
X+"  or: fdisk /dev/da0  (for the third SCSI disk)\n"
X "  ...\n");
X 			break;
X 		case unable_to_open:
X@@ -231,7 +224,7 @@
X 			break;
X 		case ioctl_error:
X 			snprintf(error, sizeof(error),
X-				 _("BLKGETSIZE ioctl failed on %s\n"),
X+				 _("DIOCGDINFO ioctl failed on %s\n"),
X 				disk_device);
X 			break;
X 		case out_of_memory:
X@@ -248,8 +241,8 @@
X 
X static void
X seek_sector(int fd, uint secno) {
X-	ext2_loff_t offset = (ext2_loff_t) secno * sector_size;
X-	if (ext2_llseek(fd, offset, SEEK_SET) == (ext2_loff_t) -1)
X+	off_t offset = (off_t) secno * sector_size;
X+	if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
X 		fatal(unable_to_seek);
X }
X 
X@@ -725,53 +718,23 @@
X 	get_boot(create_empty_dos);
X }
X 
X-#include <sys/utsname.h>
X-#define MAKE_VERSION(p,q,r)     (65536*(p) + 256*(q) + (r))
X-
X-static int
X-linux_version_code(void) {
X-	static int kernel_version = 0;
X-        struct utsname my_utsname;
X-        int p, q, r;
X-
X-        if (!kernel_version && uname(&my_utsname) == 0) {
X-                p = atoi(strtok(my_utsname.release, "."));
X-                q = atoi(strtok(NULL, "."));
X-                r = atoi(strtok(NULL, "."));
X-                kernel_version = MAKE_VERSION(p,q,r);
X-        }
X-        return kernel_version;
X-}
X-
X static void
X get_sectorsize(int fd) {
X-#if defined(BLKSSZGET)
X-	if (!user_set_sector_size &&
X-	    linux_version_code() >= MAKE_VERSION(2,3,3)) {
X-		int arg;
X-		if (ioctl(fd, BLKSSZGET, &arg) == 0)
X-			sector_size = arg;
X-		if (sector_size != DEFAULT_SECTOR_SIZE)
X-			printf(_("Note: sector size is %d (not %d)\n"),
X-			       sector_size, DEFAULT_SECTOR_SIZE);
X-	}
X-#else
X-	/* maybe the user specified it; and otherwise we still
X-	   have the DEFAULT_SECTOR_SIZE default */
X-#endif
X+	unsigned int r = sys_bsd_sectorsize(fd);
X+	if (r)
X+		sector_size = r;
X+	if (sector_size != DEFAULT_SECTOR_SIZE)
X+		printf(_("Note: sector size is %d (not %d)\n"),
X+		       sector_size, DEFAULT_SECTOR_SIZE);
X }
X 
X static void
X get_kernel_geometry(int fd) {
X-#ifdef HDIO_GETGEO
X-	struct hd_geometry geometry;
X-
X-	if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
X-		kern_heads = geometry.heads;
X-		kern_sectors = geometry.sectors;
X-		/* never use geometry.cylinders - it is truncated */
X+	struct hd_geometry h;
X+	if (!sys_bsd_getgeometry(fd, &h)) {
X+		kern_heads = h.heads;
X+		kern_sectors = h.sectors;
X 	}
X-#endif
X }
X 
X static void
X@@ -813,7 +776,7 @@
X 
X 	get_sectorsize(fd);
X 	sec_fac = sector_size / 512;
X-	guess_device_type(fd);
X+	//guess_device_type(fd);
X 	heads = cylinders = sectors = 0;
X 	kern_heads = kern_sectors = 0;
X 	pt_heads = pt_sectors = 0;
X@@ -828,8 +791,11 @@
X 		pt_sectors ? pt_sectors :
X 		kern_sectors ? kern_sectors : 63;
X 
X-	if (ioctl(fd, BLKGETSIZE, &longsectors))
X-		longsectors = 0;
X+	;{
X+		unsigned long r;
X+		if (sys_bsd_getsectors(fd, &r) == 0)
X+			longsectors = r;
X+	}
X 
X 	sector_offset = 1;
X 	if (dos_compatible_flag)
X@@ -1404,7 +1370,7 @@
X  * Jan.  1990 (version 1.2.1 by Gordon W. Ross Aug. 1990; Modified by S.
X  * Lubkin Oct.  1991). */
X 
X-static void long2chs(ulong ls, uint *c, uint *h, uint *s) {
X+static void long2chs(unsigned long ls, uint *c, uint *h, uint *s) {
X 	int	spc = heads * sectors;
X 
X 	*c = ls / spc;
X@@ -2102,16 +2068,8 @@
X 	printf(_("Calling ioctl() to re-read partition table.\n"));
X 	sync();
X 	sleep(2);
X-	if ((i = ioctl(fd, BLKRRPART)) != 0) {
X+	if ((i = sys_bsd_ptsync(fd)) != 0) {
X                 error = errno;
X-        } else {
X-                /* some kernel versions (1.2.x) seem to have trouble
X-                   rereading the partition table, but if asked to do it
X-		   twice, the second time works. - biro@yggdrasil.com */
X-                sync();
X-                sleep(2);
X-                if ((i = ioctl(fd, BLKRRPART)) != 0)
X-                        error = errno;
X         }
X 
X 	if (i) {
X@@ -2403,9 +2361,11 @@
X 	int j, c;
X 	int optl = 0, opts = 0;
X 
X+#if 0
X 	setlocale(LC_ALL, "");
X 	bindtextdomain(PACKAGE, LOCALEDIR);
X 	textdomain(PACKAGE);
X+#endif
X 
X 	/*
X 	 * Calls:
X@@ -2455,7 +2415,7 @@
X 			break;
X 		case 'V':
X 		case 'v':
X-			printf("fdisk v" UTIL_LINUX_VERSION "\n");
X+			printf("fdisk v" "2.11z" "-freebsd-portbld" "\n");
X 			exit(0);
X 		default:
X 			fatal(usage);
X@@ -2504,7 +2464,7 @@
X 			disk_device = argv[j];
X 			if ((fd = open(disk_device, type_open)) < 0)
X 				fatal(unable_to_open);
X-			if (ioctl(fd, BLKGETSIZE, &size))
X+			if (sys_bsd_getsectors(fd, &size))
X 				fatal(ioctl_error);
X 			close(fd);
X 			if (opts == 1)
Xdiff -rNu fdiskaixlabel.c fdiskaixlabel.c
X--- fdiskaixlabel.c	Tue Apr 18 15:21:28 2000
X+++ fdiskaixlabel.c	Fri Jun 20 19:25:55 2003
X@@ -8,7 +8,7 @@
X #include <string.h>             /* strstr */
X #include <unistd.h>             /* write */
X 
X-#include <endian.h>
X+#include <sys/endian.h>
X 
X #include "common.h"
X #include "fdisk.h"
Xdiff -rNu fdiskaixlabel.h fdiskaixlabel.h
X--- fdiskaixlabel.h	Sun Feb 20 18:50:51 2000
X+++ fdiskaixlabel.h	Fri Jun 20 19:25:55 2003
X@@ -1,4 +1,3 @@
X-#include <linux/types.h>   /* for __u32 etc */
X /*
X  * Copyright (C) Andreas Neuper, Sep 1998.
X  *	This file may be redistributed under
Xdiff -rNu fdiskbsdlabel.c fdiskbsdlabel.c
X--- fdiskbsdlabel.c	Thu Oct 31 15:43:42 2002
X+++ fdiskbsdlabel.c	Fri Jun 20 19:25:55 2003
X@@ -566,7 +566,7 @@
X   sector = get_start_sect(xbsd_part);
X #endif
X 
X-  if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
X+  if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
X     fatal (unable_to_seek);
X   if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
X     fatal (unable_to_write);
X@@ -735,7 +735,7 @@
X 	sector = 0;
X #endif
X 
X-	if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
X+	if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
X 		fatal (unable_to_seek);
X 	if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
X 		fatal (unable_to_read);
X@@ -781,12 +781,12 @@
X 
X #if defined (__alpha__) && BSD_LABELSECTOR == 0
X   alpha_bootblock_checksum (disklabelbuffer);
X-  if (ext2_llseek (fd, (ext2_loff_t) 0, SEEK_SET) == -1)
X+  if (lseek (fd, (off_t) 0, SEEK_SET) == -1)
X     fatal (unable_to_seek);
X   if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
X     fatal (unable_to_write);
X #else
X-  if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
X+  if (lseek (fd, (off_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
X 		   SEEK_SET) == -1)
X     fatal (unable_to_seek);
X   if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel)))
Xdiff -rNu fdiskbsdlabel.h fdiskbsdlabel.h
X--- fdiskbsdlabel.h	Thu Oct 31 15:45:34 2002
X+++ fdiskbsdlabel.h	Fri Jun 20 19:25:55 2003
X@@ -31,8 +31,6 @@
X  * SUCH DAMAGE.
X  */
X 
X-#include <linux/types.h>	/* for __u32, __u16, __u8, __s16 */
X-
X #ifndef BSD_DISKMAGIC
X #define BSD_DISKMAGIC     ((__u32) 0x82564557)
X #endif
Xdiff -rNu fdisksgilabel.c fdisksgilabel.c
X--- fdisksgilabel.c	Thu May  9 02:51:31 2002
X+++ fdisksgilabel.c	Fri Jun 20 19:25:55 2003
X@@ -17,9 +17,8 @@
X #include <sys/stat.h>           /* stat */
X #include <assert.h>             /* assert */
X 
X-#include <endian.h>
X+#include <sys/endian.h>
X #include "nls.h"
X-#include <linux/major.h>        /* FLOPPY_MAJOR */
X 
X #include "common.h"
X #include "fdisk.h"
X@@ -382,7 +381,7 @@
X 	 */
X 	sgiinfo*info = fill_sgiinfo();	/* fills the block appropriately */
X 	int infostartblock = SSWAP32( sgilabel->directory[0].vol_file_start );
X-	if( ext2_llseek(fd, (ext2_loff_t)infostartblock*
X+	if( lseek(fd, (off_t)infostartblock*
X 	    SECTOR_SIZE, SEEK_SET) < 0 )
X 	    fatal(unable_to_seek);
X 	if( write(fd, info, SECTOR_SIZE) != SECTOR_SIZE )
X@@ -735,11 +734,7 @@
X 
X     other_endian = (BYTE_ORDER == LITTLE_ENDIAN);
X 
X-#ifdef HDIO_REQ
X-    if (!ioctl(fd, HDIO_REQ, &geometry))
X-#else
X-    if (!ioctl(fd, HDIO_GETGEO, &geometry))
X-#endif
X+    if (!sys_bsd_getgeometry(fd, &geometry))
X     {
X 	heads = geometry.heads;
X 	sectors = geometry.sectors;
Xdiff -rNu fdisksgilabel.h fdisksgilabel.h
X--- fdisksgilabel.h	Tue Feb 20 12:26:53 2001
X+++ fdisksgilabel.h	Fri Jun 20 19:25:55 2003
X@@ -1,4 +1,3 @@
X-#include <linux/types.h>   /* for __u32 etc */
X /*
X  * Copyright (C) Andreas Neuper, Sep 1998.
X  *	This file may be modified and redistributed under
Xdiff -rNu fdisksunlabel.c fdisksunlabel.c
X--- fdisksunlabel.c	Fri Nov  1 03:55:25 2002
X+++ fdisksunlabel.c	Fri Jun 20 19:25:55 2003
X@@ -16,18 +16,18 @@
X #include <unistd.h>		/* write */
X #include <sys/ioctl.h>		/* ioctl */
X #include <sys/stat.h>		/* stat */
X-#include <sys/sysmacros.h>	/* major */
X+//#include <sys/sysmacros.h>	/* major */
X 
X #include "nls.h"
X 
X-#include <endian.h>
X-#include "../defines.h"		/* for HAVE_scsi_h */
X+#include <sys/endian.h>
X+//#include "../defines.h"		/* for HAVE_scsi_h */
X #ifdef HAVE_scsi_h
X #define u_char	unsigned char
X #include <scsi/scsi.h>		/* SCSI_IOCTL_GET_IDLUN */
X #undef u_char
X #endif
X-#include <linux/major.h>	/* FLOPPY_MAJOR */
X+//#include <linux/major.h>	/* FLOPPY_MAJOR */
X 
X #include "common.h"
X #include "fdisk.h"
X@@ -71,6 +71,7 @@
X 	return SSWAP32(p.num_sectors);
X }
X 
X+#if 0
X #ifndef IDE0_MAJOR
X #define IDE0_MAJOR 3
X #endif
X@@ -97,6 +98,7 @@
X                 floppy = 0;
X 	}
X }
X+#endif
X 
X static void
X set_sun_partition(int i, uint start, uint stop, int sysid) {
X@@ -296,11 +298,7 @@
X 	    }
X 	}
X 	if (!p || floppy) {
X-#ifdef HDIO_REQ
X-	    if (!ioctl(fd, HDIO_REQ, &geometry)) {
X-#else
X-	    if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
X-#endif
X+	    if (!sys_bsd_getgeometry(fd, &geometry)) {
X 	        heads = geometry.heads;
X 	        sectors = geometry.sectors;
X 	        cylinders = geometry.cylinders;
Xdiff -rNu fdisksunlabel.h fdisksunlabel.h
X--- fdisksunlabel.h	Tue Oct  3 00:42:10 2000
X+++ fdisksunlabel.h	Fri Jun 20 19:25:55 2003
X@@ -1,4 +1,3 @@
X-#include <linux/types.h>   /* for __u16, __u32 */
X 
X typedef struct {
X 	unsigned char info[128];   /* Informative text string */
Xdiff -rNu nls.h nls.h
X--- nls.h	Thu Jan  1 03:00:00 1970
X+++ nls.h	Fri Jun 20 19:25:55 2003
X@@ -0,0 +1,2 @@
X+#define _(x) (x)
X+#define N_(x) (x)
Xdiff -rNu partname.c partname.c
X--- partname.c	Sun Jul  7 15:16:43 2002
X+++ partname.c	Fri Jun 20 19:25:55 2003
X@@ -21,14 +21,16 @@
X 	p = "";
X 
X 	if (isdigit(dev[w-1]))
X-		p = "p";
X+		p = "s";
X 
X+#if 0
X 	/* devfs kludge - note: fdisk partition names are not supposed
X 	   to equal kernel names, so there is no reason to do this */
X 	if (strcmp (dev + w - 4, "disc") == 0) {
X 		w -= 4;
X 		p = "part";
X 	}
X+#endif
X 
X 	wp = strlen(p);
X 		
Xdiff -rNu sfdisk.8 sfdisk.8
X--- sfdisk.8	Fri Jun 20 20:37:34 2003
X+++ sfdisk.8	Fri Jun 20 20:43:24 2003
X@@ -9,9 +9,9 @@
X .SH NAME
X sfdisk \- Partition table manipulator for Linux
X .SH SYNOPSIS
X-.BR sfdisk " [options] device"
X+.BR sfdisk-linux " [options] device"
X .br
X-.BR "sfdisk \-s " [partition]
X+.BR "sfdisk-linux \-s " [partition]
X .SH DESCRIPTION
X .B sfdisk
X has four (main) uses: list the size of a partition, list the partitions
X@@ -19,7 +19,7 @@
X repartition a device.
X 
X .SS "List Sizes"
X-.BI "sfdisk \-s " partition
X+.BI "sfdisk-linux \-s " partition
X gives the size of
X .I partition
X in blocks. This may be useful in connection with programs like
X@@ -27,16 +27,16 @@
X or so. Here
X .I partition
X is usually something like
X-.I /dev/hda1
X+.I /dev/ad0s1
X or
X-.IR /dev/sdb12 ,
X+.IR /dev/da2s12 ,
X but may also be an entire disk, like
X-.IR /dev/xda .
X+.IR /dev/amrd0 .
X .br
X .RS
X .nf
X .if t .ft CW
X-% sfdisk \-s /dev/hda9
X+% sfdisk-linux \-s /dev/ad0s9
X 81599
X %
X .if t .ft R
X@@ -49,12 +49,12 @@
X .RS
X .nf
X .if t .ft CW
X-% sfdisk \-s
X-/dev/hda: 208896
X-/dev/hdb: 1025136
X-/dev/hdc: 1031063
X-/dev/sda: 8877895
X-/dev/sdb: 1758927
X+% sfdisk-linux \-s
X+/dev/ad0: 208896
X+/dev/ad1: 1025136
X+/dev/ad2: 1031063
X+/dev/da0: 8877895
X+/dev/da1: 1758927
X total: 12901917 blocks
X %
X .if t .ft R
X@@ -70,16 +70,16 @@
X .br
X .nf
X .if t .ft CW
X-% sfdisk \-l /dev/hdc
X+% sfdisk-linux \-l /dev/ad2
X 
X-Disk /dev/hdc: 16 heads, 63 sectors, 2045 cylinders
X+Disk /dev/ad2: 16 heads, 63 sectors, 2045 cylinders
X Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0
X 
X    Device Boot Start     End   #cyls   #blocks   Id  System
X-/dev/hdc1          0+    406     407\-   205096+  83  Linux native
X-/dev/hdc2        407     813     407    205128   83  Linux native
X-/dev/hdc3        814    2044    1231    620424   83  Linux native
X-/dev/hdc4          0       \-       0         0    0  Empty
X+/dev/ad2s1          0+    406     407\-   205096+  83  Linux native
X+/dev/ad2s2        407     813     407    205128   83  Linux native
X+/dev/ad2s3        814    2044    1231    620424   83  Linux native
X+/dev/ad2s4          0       \-       0         0    0  Empty
X %
X .if t .ft R
X .fi
X@@ -89,17 +89,17 @@
X 
X .SS "Check partitions"
X The third type of invocation:
X-.BI "sfdisk \-V " device
X+.BI "sfdisk-linux \-V " device
X will apply various consistency checks to the partition tables on
X .IR device .
X It prints `OK' or complains. The \-V option can be used together
X with \-l. In a shell script one might use
X-.BI "sfdisk \-V \-q " device
X+.BI "sfdisk-linux \-V \-q " device
X which only returns a status.
X 
X .SS "Create partitions"
X The fourth type of invocation:
X-.BI "sfdisk " device
X+.BI "sfdisk-linux " device
X will cause
X .B sfdisk
X to read the specification for the desired partitioning of
X@@ -119,7 +119,7 @@
X .RS
X .nf
X .if t .ft CW
X-% sfdisk /dev/hdd \-O hdd-partition-sectors.save
X+% sfdisk-linux /dev/ad3 \-O ad3-partition-sectors.save
X \&...
X %
X .if t .ft R
X@@ -132,7 +132,7 @@
X .RS
X .nf
X .if t .ft CW
X-% sfdisk /dev/hdd \-I hdd-partition-sectors.save
X+% sfdisk-linux /dev/ad3 \-I ad3-partition-sectors.save
X %
X .if t .ft R
X .fi
X@@ -176,8 +176,8 @@
X .br
X .nf
X .if t .ft CW
X-    % sfdisk -d /dev/hda > hda.out
X-    % sfdisk /dev/hda < hda.out
X+    % sfdisk-linux -d /dev/ad0 > ad0.out
X+    % sfdisk-linux /dev/ad0 < ad0.out
X .if t .ft R
X .fi
X will correct the bad last extended partition that the OS/2
X@@ -194,14 +194,14 @@
X .br
X .nf
X .if t .ft CW
X-    % sfdisk /dev/hdb \-N5
X+    % sfdisk-linux /dev/ad1 \-N5
X     ,,,*
X     %
X .if t .ft R
X .fi
X-will make the fifth partition on /dev/hdb bootable (`active')
X+will make the fifth partition on /dev/ad1 bootable (`active')
X and change nothing else. (Probably this fifth partition
X-is called /dev/hdb5, but you are free to call it something else,
X+is called /dev/ad1s5, but you are free to call it something else,
X like `/my_equipment/disks/2/5' or so).
X .TP
X .BI \-A "number"
X@@ -216,13 +216,13 @@
X .br
X .nf
X .if t .ft CW
X-    % sfdisk --print-id /dev/hdb 5
X+    % sfdisk-linux --print-id /dev/ad1 5
X     6
X-    % sfdisk --change-id /dev/hdb 5 83
X+    % sfdisk-linux --change-id /dev/ad1 5 83
X     OK
X .if t .ft R
X .fi
X-first reports that /dev/hdb5 has Id 6, and then changes that into 83.
X+first reports that /dev/ad1s5 has Id 6, and then changes that into 83.
X .TP
X .BR \-uS " or " \-uB " or " \-uC " or " \-uM
X Accept or report in units of sectors (blocks, cylinders, megabytes,
X@@ -420,7 +420,7 @@
X .RS
X .nf
X .if t .ft CW
X-sfdisk /dev/hdc << EOF
X+sfdisk-linux /dev/ad2 << EOF
X 0,407
X ,407
X ;
X@@ -429,7 +429,7 @@
X .if t .ft R
X .fi
X .RE
X-will partition /dev/hdc just as indicated above.
X+will partition /dev/ad2 just as indicated above.
X 
X With the \-x option, the number of input lines must be a multiple of 4:
X you have to list the two empty partitions that you never want
X@@ -456,9 +456,9 @@
X .B dd
X to zero the first 512 bytes of that partition before using DOS FORMAT to
X format the partition.  For example, if you were using sfdisk to make a DOS
X-partition table entry for /dev/hda1, then (after exiting sfdisk and
X+partition table entry for /dev/ad0s1, then (after exiting sfdisk and
X rebooting Linux so that the partition table information is valid) you
X-would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
X+would use the command "dd if=/dev/zero of=/dev/ad0s1 bs=512 count=1" to zero
X the first 512 bytes of the partition.
X .B BE EXTREMELY CAREFUL
X if you use the
X@@ -508,7 +508,7 @@
X 
X .SH BUGS
X A corresponding interactive
X-.B cfdisk
X+.B cfdisk-linux
X (with curses interface) is still lacking.
X .LP
X There are too many options.
X@@ -519,7 +519,7 @@
X A. E. Brouwer (aeb@cwi.nl)
X 
X .SH "SEE ALSO"
X-.BR cfdisk (8),
X+.BR cfdisk-linux (8),
X+.BR fdisk-linux (8),
X .BR fdisk (8),
X-.BR mkfs (8),
X-.BR parted (8)
X+.BR newfs (8)
Xdiff -rNu cfdisk.8 cfdisk.8
X--- cfdisk.8	Sun Jul  7 15:28:27 2002
X+++ cfdisk.8	Fri Jun 20 20:57:52 2003
X@@ -15,7 +15,7 @@
X .SH NAME
X cfdisk \- Curses based disk partition table manipulator for Linux
X .SH SYNOPSIS
X-.BI "cfdisk [ \-agvz ] [ \-c " cylinders " ] [ \-h " heads " ]"
X+.BI "cfdisk-linux [ \-agvz ] [ \-c " cylinders " ] [ \-h " heads " ]"
X .BI "[ \-s " sectors-per-track " ] [ -P " opt " ] [ " device " ]"
X .SH DESCRIPTION
X .B cfdisk
X@@ -26,12 +26,10 @@
X .sp
X .nf
X .RS
X-/dev/hda [default]
X-/dev/hdb
X-/dev/sda
X-/dev/sdb
X-/dev/sdc
X-/dev/sdd
X+/dev/ad0 [default]
X+/dev/ad1
X+/dev/da0
X+/dev/da1
X .RE
X .fi
X 
X@@ -132,9 +130,9 @@
X .B dd
X to zero the first 512 bytes of that partition before using DOS FORMAT to
X format the partition.  For example, if you were using cfdisk to make a DOS
X-partition table entry for /dev/hda1, then (after exiting fdisk or cfdisk
X+partition table entry for /dev/ad0s1, then (after exiting fdisk or cfdisk
X and rebooting Linux so that the partition table information is valid) you
X-would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
X+would use the command "dd if=/dev/zero of=/dev/ad0s1 bs=512 count=1" to zero
X the first 512 bytes of the partition. Note:
X 
X .B BE EXTREMELY CAREFUL
X@@ -418,10 +416,10 @@
X 0: No errors; 1: Invocation error; 2: I/O error;
X 3: cannot get geometry; 4: bad partition table on disk.
X .SH "SEE ALSO"
X+.BR fdisk-linux (8),
X+.BR newfs (8),
X .BR fdisk (8),
X-.BR mkfs (8),
X-.BR parted (8),
X-.BR sfdisk (8)
X+.BR sfdisk-linux (8)
X .SH BUGS
X The current version does not support multiple disks.
X .SH AUTHOR
Xdiff -rNu fdisk.8 fdisk.8
X--- fdisk.8	Tue Aug  6 17:33:33 2002
X+++ fdisk.8	Fri Jun 20 21:01:24 2003
X@@ -5,14 +5,14 @@
X .SH NAME
X fdisk \- Partition table manipulator for Linux
X .SH SYNOPSIS
X-.BI "fdisk [\-u] [\-b " sectorsize ]
X+.BI "fdisk-linux [\-u] [\-b " sectorsize ]
X .BI "[\-C " cyls "] [\-H " heads "] [\-S " sects "] " device
X .sp
X-.BI "fdisk \-l [\-u] [" "device ..." ]
X+.BI "fdisk-linux \-l [\-u] [" "device ..." ]
X .sp
X-.BI "fdisk \-s " "partition ..."
X+.BI "fdisk-linux \-s " "partition ..."
X .sp
X-.BI "fdisk \-v
X+.BI "fdisk-linux \-v
X .SH DESCRIPTION
X Hard disks can be divided into one or more logical disks called
X .IR partitions .
X@@ -48,26 +48,22 @@
X .br
X .nf
X .RS
X-/dev/hda
X-/dev/hdb
X-/dev/sda
X-/dev/sdb
X+/dev/ad0
X+/dev/ad1
X+/dev/da0
X+/dev/da1
X .RE
X .fi
X-(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks,
X-/dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks).
X+(/dev/adN for IDE disks, /dev/daN for SCSI disks, N=0,1,2...)
X A device name refers to the entire disk.
X 
X The
X .I partition
X is a
X .I device
X-name followed by a partition number.  For example,
X-.B /dev/hda1
X+name followed by 's' and a partition number.  For example,
X+.B /dev/ad0s1
X is the first partition on the first IDE hard disk in the system.
X-IDE disks can have up to 63 partitions, SCSI disks up to 15.
X-See also
X-.IR /usr/src/linux/Documentation/devices.txt .
X 
X A BSD/SUN type disklabel can describe 8 partitions,
X the third of which should be a `whole disk' partition.
X@@ -132,7 +128,7 @@
X Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
X this is unlikely to cause difficulty unless you have OS/2 on your machine.
X 
X-A sync() and a BLKRRPART ioctl() (reread partition table from disk)
X+A sync() and a sys_bsd_ptsync() (reread partition table from disk)
X are performed before exiting when the partition table has been updated.
X Long ago it used to be necessary to reboot after the use of fdisk.
X I do not think this is the case anymore - indeed, rebooting too quickly
X@@ -242,7 +238,7 @@
X .\" Andreas Neuper (ANeuper@GUUG.de)
X .\" and many others.
X .SH "SEE ALSO"
X-.BR cfdisk (8),
X-.BR mkfs (8),
X-.BR parted (8),
X-.BR sfdisk (8)
X+.BR cfdisk_linux (8),
X+.BR newfs (8),
X+.BR fdisk (8),
X+.BR sfdisk_linux (8)
Xdiff -rNu sfdisk.c sfdisk.c
X--- sfdisk.c	Tue Jan 28 20:18:03 2003
X+++ sfdisk.c	Tue Jun 24 01:10:28 2003
X@@ -42,11 +42,9 @@
X #include <errno.h>		/* ERANGE */
X #include <string.h>		/* index() */
X #include <ctype.h>
X-#include <getopt.h>
X+#include "getopt.h"
X #include <sys/ioctl.h>
X #include <sys/stat.h>
X-#include <sys/utsname.h>
X-#include <linux/unistd.h>	/* _syscall */
X #include "nls.h"
X #include "common.h"
X 
X@@ -130,23 +128,14 @@
X  *
X  * Note: we use 512-byte sectors here, irrespective of the hardware ss.
X  */
X-#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) && !defined (__s390x__)
X-static
X-_syscall5(int,  _llseek,  uint,  fd, ulong, hi, ulong, lo,
X-       loff_t *, res, uint, wh);
X-#endif
X 
X static int
X sseek(char *dev, unsigned int fd, unsigned long s) {
X-    loff_t in, out;
X-    in = ((loff_t) s << 9);
X+    off_t in, out;
X+    in = ((off_t) s << 9);
X     out = 1;
X 
X-#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) && !defined (__s390x__)
X-    if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0) {
X-#else
X     if ((out = lseek(fd, in, SEEK_SET)) != in) {
X-#endif
X 	perror("llseek");
X 	error(_("seek error on %s - cannot seek to %lu\n"), dev, s);
X 	return 0;
X@@ -399,12 +388,13 @@
X     long size;
X     struct geometry R;
X 
X-    if (ioctl(fd, BLKGETSIZE, &size)) {
X+    if (sys_bsd_getsectors(fd, (unsigned long*) &size)) {
X 	size = 0;
X 	if (!silent)
X 	    printf(_("Disk %s: cannot get size\n"), dev);
X     }
X-    if (ioctl(fd, HDIO_GETGEO, &g)) {
X+    g.start = 0; /* XXX ?????????? */
X+    if (sys_bsd_getgeometry(fd, &g)) {
X 	g.heads = g.sectors = g.cylinders = g.start = 0;
X 	if (!silent)
X 	    printf(_("Disk %s: cannot get geometry\n"), dev);
X@@ -721,8 +711,8 @@
X /* tell the kernel to reread the partition tables */
X static int
X reread_ioctl(int fd) {
X-    if(ioctl(fd, BLKRRPART)) {
X-	perror("BLKRRPART");
X+    if(sys_bsd_ptsync(fd)) {
X+	perror("sys_bsd_ptsync");
X 	return -1;
X     }
X     return 0;
X@@ -1428,22 +1418,6 @@
X 	z->partno = pno;
X }
X 
X-#define MAKE_VERSION(p,q,r)     (65536*(p) + 256*(q) + (r))
X-
X-static int
X-linux_version_code(void) {
X-        struct utsname my_utsname;
X-        int p, q, r;
X-
X-        if (uname(&my_utsname) == 0) {
X-                p = atoi(strtok(my_utsname.release, "."));
X-                q = atoi(strtok(NULL, "."));
X-                r = atoi(strtok(NULL, "."));
X-                return MAKE_VERSION(p,q,r);
X-        }
X-        return 0;
X-}
X-
X static int
X msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
X     int i;
X@@ -1452,7 +1426,10 @@
X     struct sector *s;
X     struct part_desc *partitions = &(z->partitions[0]);
X     int pno = z->partno;
X-    int bsd_later = (linux_version_code() >= MAKE_VERSION(2,3,40));
X+    /* Under FreeBSD, "bsd later" is always true because BSD partitions
X+     * in MBR or MBREXT partitions doesn't be listed immediately.
X+     */
X+    int bsd_later = 1;
X 
X     if (!(s = get_sector(dev, fd, start)))
X 	return 0;
X@@ -1501,6 +1478,8 @@
X 	    }
X 	    extended_partition(dev, fd, &partitions[i], z);
X 	}
X+#if 0
X+/* FreeBSD port: don't count partitions as they won't be list as slices */
X 	if (!bsd_later && is_bsd(partitions[i].p.sys_type)) {
X 	    if (!partitions[i].size) {
X 		printf(_("strange..., a BSD partition of size 0?\n"));
X@@ -1508,8 +1487,11 @@
X 	    }
X 	    bsd_partition(dev, fd, &partitions[i], z);
X 	}
X+#endif
X     }
X 
X+#if 0
X+/* FreeBSD port: don't count partitions as they won't be list as slices */
X     if (bsd_later) {
X 	for (i=0; i<4; i++) {
X 	    if (is_bsd(partitions[i].p.sys_type)) {
X@@ -1521,6 +1503,7 @@
X 	    }
X 	}
X     }
X+#endif
X 	    
X     return 1;
X }
X@@ -2413,9 +2396,11 @@
X     char *activatearg = 0;
X     char *unhidearg = 0;
X 
X+#if 0
X     setlocale(LC_ALL, "");
X     bindtextdomain(PACKAGE, LOCALEDIR);
X     textdomain(PACKAGE);
X+#endif
X 
X     if (argc < 1)
X       fatal(_("no command?\n"));
X@@ -2668,10 +2653,10 @@
X     if (fd < 0)
X 	return;
X 
X-    if(ioctl(fd, BLKGETSIZE, &size)) {
X+    if(sys_bsd_getsectors(fd, (unsigned long*) &size)) {
X 	if(!silent) {
X 	    perror(dev);
X-	    fatal(_("BLKGETSIZE ioctl failed for %s\n"), dev);
X+	    fatal(_("sys_bsd_getsectors() failed for %s\n"), dev);
X 	}
X 	return;
X     }
END-of-./files/patch-aa
echo x - ./Makefile
sed 's/^X//' >./Makefile << 'END-of-./Makefile'
X# New ports collection makefile for:	linuxfdisk
X# Date created:		Mon Jun 16 14:52:38 UTC 2003
X# Whom:			netch@netch.kiev.ua
X#
X# $FreeBSD: ports/sysutils/linuxfdisk/Makefile,v 1.1 2003/06/18 06:24:45 daichi Exp $
X#
X
XPORTNAME=	linuxfdisk
XPORTVERSION=	2.11z
XCATEGORIES=	sysutils
XMASTER_SITES=	ftp://ftp.kernel.org/pub/linux/utils/util-linux/
XDISTNAME=	util-linux-${PORTVERSION}
XEXTRACT_SUFX=	.tar.bz2
X
XMAINTAINER=	netch@netch.kiev.ua
XCOMMENT=	Fdisk, a partition tables manipulator, from util-linux
X
XWRKSRC=		${WRKDIR}/util-linux-${PORTVERSION}/fdisk
XUSE_BZIP2=	yes
XMAN8=		fdisk-linux.8 cfdisk-linux.8 sfdisk-linux.8
X
Xpre-patch:
X	@rm -f ${WRKSRC}/Makefile
X	@cp ${FILESDIR}/linuxfdisk-Makefile ${WRKSRC}/Makefile
X	@cp ${FILESDIR}/linuxfdisk-sys_bsd.c ${WRKSRC}/sys_bsd.c
X
X.include <bsd.port.mk>
END-of-./Makefile
echo x - ./distinfo
sed 's/^X//' >./distinfo << 'END-of-./distinfo'
XMD5 (util-linux-2.11z.tar.bz2) = abaab0a441233d6b7763b89ea5ab4078
END-of-./distinfo
echo x - ./pkg-descr
sed 's/^X//' >./pkg-descr << 'END-of-./pkg-descr'
XThis is fdisk from util-linux package, common on Linux systems.
XIt allows interactive manipulation of partitions including logical ones
Xfrom MS-DOS partitioning scheme.
END-of-./pkg-descr
echo x - ./pkg-plist
sed 's/^X//' >./pkg-plist << 'END-of-./pkg-plist'
Xsbin/fdisk-linux
Xsbin/cfdisk-linux
Xsbin/sfdisk-linux
END-of-./pkg-plist
exit



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