Blob Blame History Raw
From 026736e9fed89ef00e6e6e84c7e422639ac2715c Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Mon, 23 Dec 2013 15:28:22 -0500
Subject: [PATCH 81/89] libparted: sync partitions > 16

The linux partition sync code was hard coded to only flush
the first 16 partitions.
---
 NEWS                   | 2 ++
 libparted/arch/linux.c | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 88dd1fe..9ef8bf4 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@ GNU parted NEWS                                    -*- outline -*-
 
 ** Bug Fixes
 
+  Fix linux partition sync code to flush partitions > 16
+
   Do not reject a FAT boot sector as invalid because it has no
   system ID string.
 
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4376d17..71f5034 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -289,6 +289,8 @@ struct blkdev_ioctl_param {
 
 static char* _device_get_part_path (PedDevice const *dev, int num);
 static int _partition_is_mounted_by_path (const char* path);
+static unsigned int _device_get_partition_range(PedDevice const* dev);
+
 
 static int
 _read_fd (int fd, char **buf)
@@ -1581,6 +1583,7 @@ _flush_cache (PedDevice* dev)
 {
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
         int             i;
+	int             lpn = _device_get_partition_range(dev);
 
         if (dev->read_only)
                 return;
@@ -1588,7 +1591,7 @@ _flush_cache (PedDevice* dev)
 
         ioctl (arch_specific->fd, BLKFLSBUF);
 
-        for (i = 1; i < 16; i++) {
+        for (i = 1; i < lpn; i++) {
                 char*           name;
                 int             fd;
 
-- 
1.8.5.3