[Parted-maintainers] Bug#669936: parted: Fix hurd-i386 support
Samuel Thibault
sthibault at debian.org
Sun Apr 22 00:58:39 UTC 2012
Package: parted
Version: 2.3-9
Severity: important
Tags: patch
User: debian-hurd at lists.debian.org
Usertags: hurd
Hello,
The attached patch fixes parted support for hurd-i386: it adds partition
reloading support, both in-kernel, and for translators.
Samuel
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.0.4 (SMP w/8 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages parted depends on:
ii libblkid1 2.20.1-4
ii libc6 2.13-27
ii libdevmapper1.02.1 2:1.02.67-2
ii libparted0debian1 2.3-9
ii libreadline6 6.2-8
ii libtinfo5 5.9-4
ii libuuid1 2.20.1-4
parted recommends no packages.
Versions of packages parted suggests:
ii parted-doc 2.3-9
-- no debconf information
-------------- next part --------------
--- ./libparted/arch/gnu.c.original 2012-04-22 00:06:18.000000000 +0000
+++ ./libparted/arch/gnu.c 2012-04-22 02:34:58.000000000 +0000
@@ -185,7 +185,7 @@
if (!dev->arch_specific)
goto error_free_path;
- dev->type = PED_DEVICE_FILE; /* FIXME? */
+ dev->type = PED_DEVICE_UNKNOWN; /* It's deprecated anyway */
dev->open_count = 0;
dev->read_only = 0;
dev->external_mode = 0;
@@ -204,11 +204,83 @@
return NULL;
}
-static int
-_kernel_reread_part_table (PedDevice* dev)
-{
- /* XXX: We must wait for partfs to be finished. */
- return 1;
+/* Ask the kernel and translators to reload the partition table.
+ XXX: Will probably be replaced by some RPC to partfs when it's finished. In
+ the meantime, gnumach's glue layer will pass BLKRRPART to the Linux drivers.
+ */
+#define BLKRRPART 0x125F
+static int
+_reread_part_table (PedDevice* dev)
+{
+ struct store *store = GNU_SPECIFIC (dev)->store;
+ int retry_count = 9;
+ int len = strlen (dev->path);
+ char path[len + 3 + 1];
+ int i;
+ int done = 1;
+
+ sync ();
+
+ if(strcmp (store->class->name, "device") == 0) {
+ while (device_set_status (store->port, BLKRRPART, NULL, 0)) {
+ retry_count--;
+ sync ();
+ if (retry_count == 3)
+ sleep (1); /* Pause to allow system to settle */
+
+ if (!retry_count) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("WARNING: the kernel failed to re-read the "
+ "partition table on %s (%s). As a result, "
+ "it may not reflect all of your changes "
+ "until after reboot."),
+ dev->path, strerror (errno));
+ return 0;
+ }
+ }
+ }
+
+ i = 1;
+ while (1) {
+ file_t node;
+ error_t err;
+
+ /* Throw away all active parted-based translators */
+ snprintf (path, sizeof (path), "%ss%u", dev->path, i);
+ node = file_name_lookup (path, O_NOTRANS, 0666);
+ if (node == MACH_PORT_NULL) {
+ if (errno == ENOENT)
+ /* Finished looping over them */
+ break;
+
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("Warning: unable to open %s (%s). As a "
+ "result, it may not reflect all of your "
+ "changes until after reboot."),
+ path, strerror (errno));
+ done = 0;
+ }
+
+ err = file_set_translator (node, 0, FS_TRANS_SET,
+ 0, 0, 0, MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
+ if (err) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("Warning: failed to make translator go away "
+ "on %s (%s). As a result, it may not reflect "
+ "all of your changes until after reboot."),
+ dev->path, strerror (errno));
+ done = 0;
+ }
+ i++;
+ }
+
+ return done;
}
/* Free the memory associated with a PedDevice structure. */
@@ -355,7 +427,7 @@
_flush_cache (dev);
if (dev->dirty && dev->type != PED_DEVICE_FILE) {
- if (_kernel_reread_part_table (dev))
+ if (_reread_part_table (dev))
dev->dirty = 0;
}
@@ -858,7 +930,7 @@
static int
gnu_disk_commit (PedDisk* disk)
{
- return 1;
+ return _reread_part_table (disk->dev);
}
static PedDeviceArchOps gnu_dev_ops = {
More information about the Parted-maintainers
mailing list