[parted-devel] parted reporting old file system names

Mike Fleetwood mike.fleetwood at googlemail.com
Sat Dec 15 22:10:28 UTC 2012


On 14 December 2012 16:12, Phillip Susi <psusi at ubuntu.com> wrote:
>
> On 12/12/2012 6:58 PM, Mike Fleetwood wrote:
>> Hi,
>>
>> I've been doing some testing of wiping file systems, either using
>> the wipefs command or by writing zeros over the whole partition,
>> and find that in many distribution / parted version combinations it
>> prints the type of the file system that use to be there, even after
>> formatting with a new file system.  I'm doing this for a GParted
>> patch I am working on. Can anybody explain the behaviour and how to
>> fix it?
>
> Mike, can you try commenting out the if (!_have_kern26()) test before
> _flush_cache (dev), in libparted/arch/linux.c and see if that fixes it?

Thanks Phillip,

Yes applying your suggested changes makes parted report the current file
system within the partition correctly.

I also did some stracing of 'blkid' and 'parted /dev/sda print'.  The
key difference seems to be that blkid reads /proc/partitions and then
proceeds to read the contents of each partition, e.g. /dev/sda1,
/dev/sda2, ..., /dev/sda12, where as parted reads the whole disk device
/dev/sda and based on the partitioning continues to read from sda at the
relevant offsets to identify the file systems in each partition.
Totally understandable for each tool's purpose.

If I understand correctly Linux returns stale data from the buffer cache
when reading from /dev/sda after that data has been updated via
/dev/sda12 with different contents.  (In my case wiping, zeroing and
creating a different file system in the partition).  And that using
ioctl(fd, BLKFLSBUF) on /dev/sda prevents this.

Question: Is there a libparted API call I can make from GParted which
will call the BLKFLSBUF ioctl to flush the buffer cache, or do I need
to code GParted to do it when necessary?

Thanks,
Mike


This is the change I applied to parted 3.1.

diff -urp parted-3.1.orig/libparted/arch/linux.c
parted-3.1/libparted/arch/linux.c
--- parted-3.1.orig/libparted/arch/linux.c      2012-02-10
19:05:13.000000000 +0000
+++ parted-3.1/libparted/arch/linux.c   2012-12-15 18:55:26.992025781 +0000
@@ -1576,7 +1576,6 @@ retry:
         }

         /* With kernels < 2.6 flush cache for cache coherence issues */
-        if (!_have_kern26())
                 _flush_cache (dev);

         return 1;



More information about the parted-devel mailing list