[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#757986: kfreebsd: multiple "inappropriate ioctl for device" prompts



tags 757986 + patch
thanks

(p.s. KiBi - perhaps we could fix this in time for d-i Beta 2?  if linux
is waiting for up to 5 more days)

Hi,

I was able to review Jeff Epler's original patch for this issue, make
sure I properly understood it, clean it up and test it again in a full
d-i image.  I can now happily sign off on this as a correct fix.

I've attached it in the form of a commit for parted packaging Git.  It
updates the existing kfreebsd-gnu.patch with Jeff's new code, and
refreshes the others.

Thank you,
Regards,
-- 
Steven Chamberlain
steven@pyro.eu.org
diff --git a/debian/changelog b/debian/changelog
index 6b45fda..cf56fd1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,18 @@
+parted (3.2-5) UNRELEASED; urgency=low
+
+  [ Steven Chamberlain ]
+  * kfreebsd-gnu.patch: (Thanks, Jeff Epler!)
+    - Fix detection of /dev/ada as a SCSI disk type (Closes: #693510,
+      #757986)
+    - Implement detection of drive model, logical and physical sector
+      sizes for SCSI disks
+  * Refresh patches
+    - freebsd-zvol.patch
+    - freebsd-geli.patch
+    - kfreebsd_lvm.patch
+
+ -- Parted Maintainer Team <parted-maintainers@lists.alioth.debian.org>  Wed, 13 Aug 2014 20:24:11 +0100
+
 parted (3.2-4) unstable; urgency=high
 
   * Probe LVM logical volumes even when their physical volumes are on
diff --git a/debian/patches/freebsd-geli.patch b/debian/patches/freebsd-geli.patch
index b1003be..594632b 100644
--- a/debian/patches/freebsd-geli.patch
+++ b/debian/patches/freebsd-geli.patch
@@ -1,4 +1,4 @@
-From cc549a70b496cb4f9cdbd5de03a864922cd5c991 Mon Sep 17 00:00:00 2001
+From 4f1d7a475db350cc2b11d22ed54be6eff472e2f3 Mon Sep 17 00:00:00 2001
 From: Robert Millan <rmh@debian.org>
 Date: Fri, 28 Mar 2014 17:09:51 +0000
 Subject: Detection of GEOM encryption devices (GELI)
@@ -12,11 +12,9 @@ Patch-Name: freebsd-geli.patch
  libparted/arch/freebsd.c | 6 ++++++
  1 file changed, 6 insertions(+)
 
-diff --git a/libparted/arch/freebsd.c b/libparted/arch/freebsd.c
-index a53eadc..b3f23c3 100644
 --- a/libparted/arch/freebsd.c
 +++ b/libparted/arch/freebsd.c
-@@ -1058,6 +1058,8 @@ _probe_kern_disks ()
+@@ -1096,6 +1096,8 @@
  {
  	size_t listsize;
  	char *disklist, *pdisklist, *psave;
@@ -25,7 +23,7 @@ index a53eadc..b3f23c3 100644
  
  	if (sysctlbyname("kern.disks", NULL, &listsize, NULL, 0) != 0) {
  		ped_exception_throw (
-@@ -1091,6 +1093,10 @@ _probe_kern_disks ()
+@@ -1129,6 +1131,10 @@
  		strncat (dev_name, token, sizeof(dev_name) - strlen(_PATH_DEV) - 1);
  		dev_name[sizeof(dev_name) - 1] = '\0';
  		_ped_device_probe (dev_name);
diff --git a/debian/patches/freebsd-zvol.patch b/debian/patches/freebsd-zvol.patch
index 1da84bc..3906fa2 100644
--- a/debian/patches/freebsd-zvol.patch
+++ b/debian/patches/freebsd-zvol.patch
@@ -1,4 +1,4 @@
-From 78e2648ee6767ac54aa24d21646920b00de8e302 Mon Sep 17 00:00:00 2001
+From b62fecc10deaa9b84af44192ce52e84c1280a4a9 Mon Sep 17 00:00:00 2001
 From: Robert Millan <rmh@debian.org>
 Date: Fri, 28 Mar 2014 17:09:50 +0000
 Subject: Detection of ZFS volumes (ZVOL)
@@ -17,8 +17,6 @@ Patch-Name: freebsd-zvol.patch
  libparted/arch/freebsd.c | 40 ++++++++++++++++++++++++++++++++++++++++
  1 file changed, 40 insertions(+)
 
-diff --git a/libparted/arch/freebsd.c b/libparted/arch/freebsd.c
-index 52f5293..a53eadc 100644
 --- a/libparted/arch/freebsd.c
 +++ b/libparted/arch/freebsd.c
 @@ -23,6 +23,7 @@
@@ -29,7 +27,7 @@ index 52f5293..a53eadc 100644
  #include <errno.h>
  #include <fcntl.h>
  #include <stdint.h>
-@@ -1096,12 +1097,51 @@ _probe_kern_disks ()
+@@ -1134,12 +1135,51 @@
  	return 1;
  }
  
diff --git a/debian/patches/kfreebsd-gnu.patch b/debian/patches/kfreebsd-gnu.patch
index 957aa6b..4d07fac 100644
--- a/debian/patches/kfreebsd-gnu.patch
+++ b/debian/patches/kfreebsd-gnu.patch
@@ -21,11 +21,9 @@ Patch-Name: kfreebsd-gnu.patch
  7 files changed, 1272 insertions(+), 4 deletions(-)
  create mode 100644 libparted/arch/freebsd.c
 
-diff --git a/configure.ac b/configure.ac
-index 436d0e2..038ebdc 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -61,6 +61,7 @@ case "$host_os" in
+@@ -61,6 +61,7 @@
  	linux*) OS=linux ;;
  	gnu*)	OS=gnu ;;
  	beos*)	OS=beos ;;
@@ -33,7 +31,7 @@ index 436d0e2..038ebdc 100644
  	*)	AC_MSG_ERROR([Unknown or unsupported OS "$host_os".  Only "linux", "gnu" and "beos" are supported in this version of GNU Parted.]) ;;
  esac
  AC_SUBST([OS])
-@@ -273,6 +274,7 @@ AC_CHECK_SIZEOF([off_t], [64], [
+@@ -273,6 +274,7 @@
  	#include <sys/types.h>
  	#include <unistd.h>
  ])
@@ -41,7 +39,7 @@ index 436d0e2..038ebdc 100644
  
  AM_ENABLE_SHARED
  if test "$OS" = linux && test $ac_cv_sizeof_off_t -lt 8; then
-@@ -511,7 +513,7 @@ If you can't find one try:
+@@ -511,7 +513,7 @@
          http://web.mit.edu/tytso/www/linux/e2fsprogs.html])]
  )
  
@@ -50,7 +48,7 @@ index 436d0e2..038ebdc 100644
  AC_CHECK_HEADERS([linux/ext2_fs.h])
  
  dnl required for libparted/llseek.c  (TODO: make linux-x86 only)
-@@ -570,7 +572,9 @@ AC_C_CONST
+@@ -570,7 +572,9 @@
  AC_C_RESTRICT
  
  dnl Checks for library functions.
@@ -61,11 +59,9 @@ index 436d0e2..038ebdc 100644
  AC_CHECK_FUNCS([getuid])
  
  dnl NOTE: We need to remove the gl_cv_ignore_unused_libraries flag if we
-diff --git a/libparted/Makefile.am b/libparted/Makefile.am
-index edc5f2e..b410e64 100644
 --- a/libparted/Makefile.am
 +++ b/libparted/Makefile.am
-@@ -47,7 +47,8 @@ libparted_la_SOURCES  = debug.c			\
+@@ -47,7 +47,8 @@
  EXTRA_libparted_la_SOURCES    = arch/linux.c	\
  				arch/linux.h	\
  				arch/gnu.c	\
@@ -75,12 +71,9 @@ index edc5f2e..b410e64 100644
  
  libparted_la_LIBADD =	\
    fs/libfs.la		\
-diff --git a/libparted/arch/freebsd.c b/libparted/arch/freebsd.c
-new file mode 100644
-index 0000000..52f5293
 --- /dev/null
 +++ b/libparted/arch/freebsd.c
-@@ -0,0 +1,1254 @@
+@@ -0,0 +1,1292 @@
 +/*
 +    libparted - a library for manipulating disk partitions
 +    Copyright (C) 1999 - 2009 Free Software Foundation, Inc.
@@ -142,6 +135,7 @@ index 0000000..52f5293
 +
 +struct _FreeBSDSpecific {
 +	int	fd;
++	long long	phys_sector_size;
 +};
 +
 +static char* _device_get_part_path (PedDevice* dev, int num);
@@ -190,7 +184,9 @@ index 0000000..52f5293
 +	}
 +	np += 1; /* advance past '/' */
 +
-+	if(strncmp(np, "ad", 2) == 0) {
++	if (strncmp(np, "ada", 3) == 0) {
++		dev->type = PED_DEVICE_SCSI;
++	} else if (strncmp(np, "ad", 2) == 0) {
 +		dev->type = PED_DEVICE_IDE;
 +	} else if (strncmp(np, "da", 2) == 0) {
 +		dev->type = PED_DEVICE_SCSI;
@@ -228,6 +224,9 @@ index 0000000..52f5293
 +		dev->sector_size = (long long)sector_size;;
 +	}
 +
++	if (arch_specific->phys_sector_size)
++		dev->phys_sector_size = arch_specific->phys_sector_size;
++
 +	if (sector_size != PED_SECTOR_SIZE_DEFAULT) {
 +		ped_exception_throw (
 +			PED_EXCEPTION_WARNING,
@@ -370,7 +369,8 @@ index 0000000..52f5293
 +	int		fd;
 +	char		result[64];
 +
-+	if (sscanf (dev->path, "/dev/%2s%u", ccb.cgdl.periph_name, &ccb.cgdl.unit_number) != 2)
++	if (sscanf (dev->path, "/dev/%2s%u", ccb.cgdl.periph_name, &ccb.cgdl.unit_number) != 2 &&
++		sscanf (dev->path, "/dev/%3s%u", ccb.cgdl.periph_name, &ccb.cgdl.unit_number) != 2)
 +		goto error;
 +
 +	if ((fd = open("/dev/xpt0", O_RDWR)) < 0)
@@ -390,9 +390,32 @@ index 0000000..52f5293
 +	return NULL;
 +}
 +
++static uint32_t
++local_ata_logical_sector_size(struct ata_params *ident_data)
++{
++        if ((ident_data->pss & 0xc000) == 0x4000 &&
++            (ident_data->pss & ATA_PSS_LSSABOVE512)) {
++                return ((u_int32_t)ident_data->lss_1 |
++                    ((u_int32_t)ident_data->lss_2 << 16));
++        }
++        return (512);
++}
++
++static uint64_t
++local_ata_physical_sector_size(struct ata_params *ident_data)
++{
++        if ((ident_data->pss & 0xc000) == 0x4000 &&
++            (ident_data->pss & ATA_PSS_MULTLS)) {
++                return ((uint64_t)local_ata_logical_sector_size(ident_data) *
++                    (1 << (ident_data->pss & ATA_PSS_LSPPS)));
++        }
++        return (512);
++}
++
 +static int
 +init_scsi (PedDevice* dev)
 +{
++	FreeBSDSpecific*	arch_specific = FREEBSD_SPECIFIC (dev);
 +	PedExceptionOption 	ex_status;
 +	struct stat		dev_stat;
 +	char*			pass_dev;
@@ -473,10 +496,16 @@ index 0000000..52f5293
 +				break;
 +		}
 +	} else {
-+		dev->model = (char*) ped_malloc (8 + 16 + 2);
++		size_t model_length = (8 + 16 + 2);
++		dev->model = (char*) ped_malloc (model_length);
 +		if (!dev->model)
 +			goto error_close_fd_dev;
-+		sprintf (dev->model, "%.8s %.16s", ccb.cgd.inq_data.vendor, ccb.cgd.inq_data.product);
++		if (ccb.cgd.protocol == PROTO_ATA && *ccb.cgd.ident_data.model) {
++			snprintf (dev->model, model_length, "%s", ccb.cgd.ident_data.model);
++			arch_specific->phys_sector_size = local_ata_physical_sector_size(&ccb.cgd.ident_data);
++		} else {
++			snprintf (dev->model, model_length, "%.8s %.16s", ccb.cgd.inq_data.vendor, ccb.cgd.inq_data.product);
++		}
 +	}
 +
 +	if (!_device_probe_geometry (dev))
@@ -616,6 +645,8 @@ index 0000000..52f5293
 +	if (!dev->arch_specific)
 +		goto error_free_path;
 +
++	memset(dev->arch_specific, 0, sizeof(FreeBSDSpecific));
++
 +	dev->open_count = 0;
 +	dev->read_only = 0;
 +	dev->external_mode = 0;
@@ -1335,11 +1366,9 @@ index 0000000..52f5293
 +	dev_ops:	&freebsd_dev_ops,
 +	disk_ops:	&freebsd_disk_ops
 +};
-diff --git a/libparted/architecture.c b/libparted/architecture.c
-index df0f381..8c31fba 100644
 --- a/libparted/architecture.c
 +++ b/libparted/architecture.c
-@@ -34,6 +34,9 @@ ped_set_architecture ()
+@@ -34,6 +34,9 @@
  #elif defined(__BEOS__)
  	extern PedArchitecture ped_beos_arch;
  	const PedArchitecture* arch = &ped_beos_arch;
@@ -1349,8 +1378,6 @@ index df0f381..8c31fba 100644
  #else
  	extern PedArchitecture ped_gnu_arch;
  	const PedArchitecture* arch = &ped_gnu_arch;
-diff --git a/libparted/fs/xfs/platform_defs.h b/libparted/fs/xfs/platform_defs.h
-index 2b55752..01a06df 100644
 --- a/libparted/fs/xfs/platform_defs.h
 +++ b/libparted/fs/xfs/platform_defs.h
 @@ -37,7 +37,11 @@
@@ -1366,8 +1393,6 @@ index 2b55752..01a06df 100644
  #include <stddef.h>
  #include <stdlib.h>
  #include <string.h>
-diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
-index a8525a4..16dba31 100644
 --- a/libparted/labels/bsd.c
 +++ b/libparted/labels/bsd.c
 @@ -26,6 +26,7 @@
@@ -1378,8 +1403,6 @@ index a8525a4..16dba31 100644
  
  #if ENABLE_NLS
  #  include <libintl.h>
-diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c
-index b23ff86..0fc514c 100644
 --- a/libparted/labels/sun.c
 +++ b/libparted/labels/sun.c
 @@ -25,6 +25,7 @@
diff --git a/debian/patches/kfreebsd_lvm.patch b/debian/patches/kfreebsd_lvm.patch
index 87be4e8..d7f2780 100644
--- a/debian/patches/kfreebsd_lvm.patch
+++ b/debian/patches/kfreebsd_lvm.patch
@@ -8,11 +8,9 @@ Patch-Name: kfreebsd_lvm.patch
  libparted/arch/freebsd.c | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
 
-diff --git a/libparted/arch/freebsd.c b/libparted/arch/freebsd.c
-index b3f23c3..ff130af 100644
 --- a/libparted/arch/freebsd.c
 +++ b/libparted/arch/freebsd.c
-@@ -1140,6 +1140,31 @@ _probe_zfs_volumes ()
+@@ -1178,6 +1178,31 @@
  	return 1;
  }
  
@@ -44,7 +42,7 @@ index b3f23c3..ff130af 100644
  static void
  freebsd_probe_all ()
  {
-@@ -1148,6 +1173,8 @@ freebsd_probe_all ()
+@@ -1186,6 +1211,8 @@
  	_probe_kern_disks ();
  
  	_probe_zfs_volumes ();

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: