GNU bug report logs - #22266
[libparted] jump instruction and boot code is corrupted with random bytes after fat is resized

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: parted; Reported by: Tom Yan <tom.ty89@HIDDEN>; dated Tue, 29 Dec 2015 18:00:02 UTC; Maintainer for parted is bug-parted@HIDDEN.

Message received at 22266 <at> debbugs.gnu.org:


Received: (at 22266) by debbugs.gnu.org; 15 Apr 2016 00:30:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 14 20:30:22 2016
Received: from localhost ([127.0.0.1]:35813 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aqreQ-0006QV-NH
	for submit <at> debbugs.gnu.org; Thu, 14 Apr 2016 20:30:22 -0400
Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.230]:62271
 helo=cdptpa-oedge-vip.email.rr.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psusi@HIDDEN>) id 1aqreP-0006QI-Nh
 for 22266 <at> debbugs.gnu.org; Thu, 14 Apr 2016 20:30:21 -0400
Received: from [72.239.162.168] ([72.239.162.168:37630] helo=[192.168.1.142])
 by cdptpa-oedge02 (envelope-from <psusi@HIDDEN>)
 (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP
 id 47/85-22503-71630175; Fri, 15 Apr 2016 00:30:16 +0000
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
To: Curtis Gedak <gedakc@HIDDEN>, Tom Yan <tom.ty89@HIDDEN>
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
 <20160104174524.GC12500@HIDDEN> <568AB233.7060808@HIDDEN>
 <CAGnHSEmf=O5KB27QpBtrwjVEx0eETuCispqs84Q10chMdaH==g@HIDDEN>
 <570AB0E1.7060501@HIDDEN>
From: Phillip Susi <psusi@HIDDEN>
Message-ID: <57103617.1010005@HIDDEN>
Date: Thu, 14 Apr 2016 20:30:15 -0400
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <570AB0E1.7060501@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-RR-Connecting-IP: 107.14.168.130:25
X-Cloudmark-Score: 0
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 22266
Cc: 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 04/10/2016 04:00 PM, Curtis Gedak wrote:
> Attached is a patch to fix the issue with jump instruction and boot
> code is corrupted with random bytes after fat is resized.
> 
> Thanks goes to Tom Yan, Dirk Eberhardt, and others who reported
> the problem and provided additional details.  This detailed
> information helped with my understanding of the issue.
> 
> The portion of this email after my signature delves further into
> the problem investigation and solution.

Thanks Curtis; patch pushed.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCgAGBQJXEDYXAAoJEBB5UWFcu6UWrdIH/1SNDXVZvz2QFgRvhqUAZhvB
AgFbgLp8TwVd7nqIIYxsBNMryF+3izBtUHl3rPE2S/2WjGvzQmgG1FZ5an0lIh0i
j6cIHof4MZ2QViAOHYzQP9npW7qurY9Jnp7MrXTNbT+kLdANJ7xm6StAFWKS0R+m
HBBSlNgKuj83C0pbYbnQkmNLlbPLLsytiaoQFE6sNBj5LwZCN7/gCiXeIO4i9KZ+
q7Kv3LWM1TbP+5zvbnr/Gs6fHKWM+LmfrgrpeyFCKlxImGTa2OH34aKRkUcIPv17
SlYKoiN96wIdePa6tztNdUhsuUmzYh30tXKBMf9eumBz1e5WxgFJUJI6hs8hvp0=
=5Noq
-----END PGP SIGNATURE-----




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at 22266 <at> debbugs.gnu.org:


Received: (at 22266) by debbugs.gnu.org; 10 Apr 2016 20:00:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 10 16:00:44 2016
Received: from localhost ([127.0.0.1]:57566 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1apLXH-0002KE-JW
	for submit <at> debbugs.gnu.org; Sun, 10 Apr 2016 16:00:43 -0400
Received: from mail-ig0-f171.google.com ([209.85.213.171]:38657)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gedakc@HIDDEN>) id 1apLXF-0002K1-JR
 for 22266 <at> debbugs.gnu.org; Sun, 10 Apr 2016 16:00:42 -0400
Received: by mail-ig0-f171.google.com with SMTP id ui10so56165733igc.1
 for <22266 <at> debbugs.gnu.org>; Sun, 10 Apr 2016 13:00:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=subject:to:references:cc:from:message-id:date:user-agent
 :mime-version:in-reply-to;
 bh=540nQito0xeeneX1xSfzbEUE8JKmCVKxJGZCOMle74k=;
 b=gG7E31p7zohDbndDgy71WdEsJLjcjFaYCMRy6K29WWQaDCupmrU09WZIIjWQTcQyuY
 gkKiL+dvfU85kFJW9srTFQlM5Wyyp/p/LzBDV3qgAP+lIo6JD4ZHICiGf4kRCIBjp4pY
 cKWZrQHviLjzUWRgTsCqps202hN5vCOLTh4DVbO9blEg2yq9f/1QVXX+GXbsKDicwRvO
 UdRV9YDAfL7BLiorpvaN5lxQlnWwFYacL4vM6OAPpN/a4d4oPkW7OlW0X4oCgJnsu+hd
 voAlDS7ZWdOCwXd3txv0iiNP1KHa9d7S6OHBAG6EtPN62e6Zq/aaeQS0M39WrlgqeZwC
 fENw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:subject:to:references:cc:from:message-id:date
 :user-agent:mime-version:in-reply-to;
 bh=540nQito0xeeneX1xSfzbEUE8JKmCVKxJGZCOMle74k=;
 b=Ho7rumaYXChZH4uR6D1oxLN6PWv/MzkhoITYFU9gyNvwUfbm6NO7JT7jWnqALur5wM
 DHxGyv0w0rmmxCr6EIAqdttBJu5Yf2wStikHZII1B/X4zrEqTCFRyrbHw0EUoBxFv3OW
 7o+r2yGTywop/EWh5oO0kzhFTFXpSNC4sxtXvBt5xby9a6S/rSSyZqV77ssffeUbis/T
 4k3AuZf0MR209pGe6kILTU21xZkMlsY0R4x2bBfzI9T/ZfwrFnlxXr2M7rR3e4tGVbVR
 c2YeEGLXSUyVZagWwGB2P44LfcmxpulgZ6RylLDX4Iig8GXe19YFL0wvO5TOx6IGXqIc
 cF5g==
X-Gm-Message-State: AD7BkJJL8SRBMiv9CssVpChto8v6/1SSeMza4sfPe2unYGQe0pgqbLfkQCvAMGCF3U/aFw==
X-Received: by 10.50.168.100 with SMTP id zv4mr14634717igb.4.1460318435576;
 Sun, 10 Apr 2016 13:00:35 -0700 (PDT)
Received: from [192.168.1.53] (d162-157-118-249.abhsia.telus.net.
 [162.157.118.249])
 by smtp.gmail.com with ESMTPSA id i187sm14729473ioi.33.2016.04.10.13.00.33
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 10 Apr 2016 13:00:34 -0700 (PDT)
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
To: Tom Yan <tom.ty89@HIDDEN>
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
 <20160104174524.GC12500@HIDDEN> <568AB233.7060808@HIDDEN>
 <CAGnHSEmf=O5KB27QpBtrwjVEx0eETuCispqs84Q10chMdaH==g@HIDDEN>
From: Curtis Gedak <gedakc@HIDDEN>
Message-ID: <570AB0E1.7060501@HIDDEN>
Date: Sun, 10 Apr 2016 14:00:33 -0600
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <CAGnHSEmf=O5KB27QpBtrwjVEx0eETuCispqs84Q10chMdaH==g@HIDDEN>
Content-Type: multipart/mixed; boundary="------------080907000304070407070401"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 22266
Cc: bcl@HIDDEN, d-eberhdt64@HIDDEN, bug-parted@HIDDEN,
 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

This is a multi-part message in MIME format.
--------------080907000304070407070401
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Attached is a patch to fix the issue with jump instruction and boot code
is corrupted with random bytes after fat is resized.

Thanks goes to Tom Yan, Dirk Eberhardt, and others who reported the
problem and provided additional details.  This detailed information
helped with my understanding of the issue.

The portion of this email after my signature delves further into the
problem investigation and solution.

Regards,
Curtis Gedak


PROBLEM
-------

Windows does not recognize FAT32 after resizing with utilities (for
example GParted) that use parted-3.2 libraries.


CONFIRMATION
------------

Steps to confirm are:

1) Create a single FAT32 partition (e.g. 500 MiB) on a device such as
   a USB drive.

   When I created FAT32 partition using GParted the boot sector
   started with:

   $ sudo hexdump -n 7k -C /dev/sda1
   00000000  eb 58 90 6d 6b 66 73                              |.X.mkfs|
   00000007
   $

2) Use GParted linked with parted-3.2 libraries to shrink the FAT32
   partition (e.g. 450 MiB).

   After FAT32 resizing using GParted the boot sector started with:

   $ sudo hexdump -n 7k -C /dev/sda1
   00000000  d0 02 30 4d 53 57 49                              |..0MSWI|
   00000007
   $

   The important distinction is that the first three hexadecimal
   values were randomly changed.  These values represent the "boot
   jump" code and Windows requires these values to be correctly set.

3) Try to use the FAT32 partition with Windows (e.g. insert USB drive
   in Windows computer).  The FAT32 file system is not recognized.

   Regarding boot_jump (and system_id) see:
   http://git.savannah.gnu.org/cgit/parted.git/tree/doc/FAT?id=v3.2#n176

If the libraries from parted 3.1, or versions 2.4 and earlier are
used, then the resized FAT32 partition is recognized by Windows.


INVESTIGATION
-------------

The problem with Windows FAT32 recognition was introduced with:

  Fix filesystem detection on non 512 byte sectors
  80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12

The cause of the problem is that when the parted library is resizing
FAT32, there is one too many boot_sector memory allocations.

The calling structure is as follows:

fat_resize (...)
{
  ...
  ctx = create_resize_context (...);  # Allocates new boot_sector
                                      #   memory and copies content
                                      #   from old boot sector
  ...
  fat_boot_sector_generate (...)      # Allocates new boot_sector
                                      #   memory AGAIN!
                                      #   Copied content lost!
  fat_boot_sector_write (...)
  ...
}


SOLUTION
--------

Remove new boot sector memory allocation from
fat_boot_sector_generate(...).

The function fat_boot_sector_generate(...) is also called from
fat_create(...).

  Note that access to fat_create(...) via ped_file_system_create(...)
  is no longer possible since parted-3.0 because all file system
  operations were removed.  See:
  http://git.savannah.gnu.org/cgit/parted.git/tree/NEWS?id=v3.0

  In parted-3.1, access to fat_create(...) via
  ped_file_system_create(...) was not re-introduced.  See:
  http://git.savannah.gnu.org/cgit/parted.git/tree/NEWS?id=v3.1

Although fat_create(...) in inaccessible, I thought it best to move
the new boot_sector memory allocation to where it is needed in
fat_boot_sector_set_boot_code(...).  That way the code should still
work if it is ever re-instated.


REFERENCES
----------

GNU bug report logs - #22266:
[libparted] jump instruction and boot code is corrupted with random
bytes after fat is resized
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22266

GNU bug report logs - #22710:
libparted 3.2 fat32 bootsector incompatible w. windows
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22710

GParted Bug Report:
Bug 759916 - fat(32) resizing generates boot sector(s) with invalid
             jump instruction and pseudo-random boot code
https://bugzilla.gnome.org/show_bug.cgi?id=759916

GParted Forum:
Vista/XP don't accept a shrinked Fat32 partition (USB-stick)
http://gparted-forum.surf4.info/viewtopic.php?id=17318

--------------080907000304070407070401
Content-Type: text/x-patch;
 name="gnubug22266-boot-code-corrupted-after-fat-resize.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="gnubug22266-boot-code-corrupted-after-fat-resize.patch"

From d9a424a6fd922f5275183ea96e911af9abb9b745 Mon Sep 17 00:00:00 2001
From: Curtis Gedak <gedakc@HIDDEN>
Date: Sun, 10 Apr 2016 11:38:41 -0600
Subject: [PATCH] lib-fs-resize: Fix recognition of FAT file system after
 resizing

When resizing a FAT partition, an extra boot_sector memory allocation
was causing the original boot_sector information to be lost.  The
resulting FAT file system was still recognized by GNU/Linux, but not
recognized by the proprietary Windows operating system.

The problem with Windows FAT32 recognition was introduced with:

  Fix filesystem detection on non 512 byte sectors
  80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12

Fix by removing the extra boot_sector memory allocation.

Note that since parted-3.0 another code path to the extra memory
allocation of fat_create(...) via ped_file_system_create(...) is
inaccessible.  In an effort to maintain the ability to re-instate the
code, add a new boot_sector memory allocation where it is needed in
the alternate code path.

GNU bug report logs - #22266
[libparted] jump instruction and boot code is corrupted with random
bytes after fat is resized
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22266
---
 libparted/fs/r/fat/bootsector.c | 9 +++++++--
 libparted/fs/r/fat/bootsector.h | 2 +-
 libparted/fs/r/fat/fat.c        | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libparted/fs/r/fat/bootsector.c b/libparted/fs/r/fat/bootsector.c
index 1d2b601..99d788d 100644
--- a/libparted/fs/r/fat/bootsector.c
+++ b/libparted/fs/r/fat/bootsector.c
@@ -281,8 +281,13 @@ fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs)
 
 #ifndef DISCOVER_ONLY
 int
-fat_boot_sector_set_boot_code (FatBootSector* bs)
+fat_boot_sector_set_boot_code (FatBootSector** bsp, const PedFileSystem* fs)
 {
+	FatSpecific*	fs_info = FAT_SPECIFIC (fs);
+
+	PED_ASSERT (bsp != NULL);
+	*bsp = ped_malloc (fs->geom->dev->sector_size);
+	FatBootSector *bs = *bsp;
 	PED_ASSERT (bs != NULL);
 
 	memset (bs, 0, 512);
@@ -297,8 +302,8 @@ fat_boot_sector_generate (FatBootSector** bsp, const PedFileSystem* fs)
 	FatSpecific*	fs_info = FAT_SPECIFIC (fs);
 
 	PED_ASSERT (bsp != NULL);
-	*bsp = ped_malloc (fs->geom->dev->sector_size);
 	FatBootSector *bs = *bsp;
+	PED_ASSERT (bs != NULL);
 
 	memcpy (bs->system_id, "MSWIN4.1", 8);
 	bs->sector_size = PED_CPU_TO_LE16 (fs_info->logical_sector_size * 512);
diff --git a/libparted/fs/r/fat/bootsector.h b/libparted/fs/r/fat/bootsector.h
index e92842c..3f84d7f 100644
--- a/libparted/fs/r/fat/bootsector.h
+++ b/libparted/fs/r/fat/bootsector.h
@@ -120,7 +120,7 @@ int fat_boot_sector_read (FatBootSector** bs, const PedGeometry* geom);
 FatType fat_boot_sector_probe_type (const FatBootSector* bs,
 				    const PedGeometry* geom);
 int fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs);
-int fat_boot_sector_set_boot_code (FatBootSector* bs);
+int fat_boot_sector_set_boot_code (FatBootSector** bs, const PedFileSystem* fs);
 int fat_boot_sector_generate (FatBootSector** bs, const PedFileSystem* fs);
 int fat_boot_sector_write (const FatBootSector* bs, PedFileSystem* fs);
 
diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
index 4ecf5c5..444668d 100644
--- a/libparted/fs/r/fat/fat.c
+++ b/libparted/fs/r/fat/fat.c
@@ -310,7 +310,7 @@ fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer)
 
 	fs_info->serial_number = generate_random_uint32 ();
 
-	if (!fat_boot_sector_set_boot_code (fs_info->boot_sector))
+	if (!fat_boot_sector_set_boot_code (&fs_info->boot_sector, fs))
 		goto error_free_buffers;
 	if (!fat_boot_sector_generate (&fs_info->boot_sector, fs))
 		goto error_free_buffers;
-- 
1.9.1


--------------080907000304070407070401--




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Apr 2016 20:00:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 10 16:00:50 2016
Received: from localhost ([127.0.0.1]:57569 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1apLXO-0002Ka-1D
	for submit <at> debbugs.gnu.org; Sun, 10 Apr 2016 16:00:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34608)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gedakc@HIDDEN>) id 1apLXM-0002KF-Lq
 for submit <at> debbugs.gnu.org; Sun, 10 Apr 2016 16:00:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1apLXF-0008QC-VQ
 for submit <at> debbugs.gnu.org; Sun, 10 Apr 2016 16:00:43 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:51464)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1apLXF-0008Q8-RX
 for submit <at> debbugs.gnu.org; Sun, 10 Apr 2016 16:00:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53810)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1apLXE-0006zv-8h
 for bug-parted@HIDDEN; Sun, 10 Apr 2016 16:00:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1apLXB-0008Pm-0S
 for bug-parted@HIDDEN; Sun, 10 Apr 2016 16:00:40 -0400
Received: from mail-ig0-x236.google.com ([2607:f8b0:4001:c05::236]:38588)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1apLXA-0008Ph-Oa
 for bug-parted@HIDDEN; Sun, 10 Apr 2016 16:00:36 -0400
Received: by mail-ig0-x236.google.com with SMTP id ui10so56165732igc.1
 for <bug-parted@HIDDEN>; Sun, 10 Apr 2016 13:00:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=subject:to:references:cc:from:message-id:date:user-agent
 :mime-version:in-reply-to;
 bh=540nQito0xeeneX1xSfzbEUE8JKmCVKxJGZCOMle74k=;
 b=gG7E31p7zohDbndDgy71WdEsJLjcjFaYCMRy6K29WWQaDCupmrU09WZIIjWQTcQyuY
 gkKiL+dvfU85kFJW9srTFQlM5Wyyp/p/LzBDV3qgAP+lIo6JD4ZHICiGf4kRCIBjp4pY
 cKWZrQHviLjzUWRgTsCqps202hN5vCOLTh4DVbO9blEg2yq9f/1QVXX+GXbsKDicwRvO
 UdRV9YDAfL7BLiorpvaN5lxQlnWwFYacL4vM6OAPpN/a4d4oPkW7OlW0X4oCgJnsu+hd
 voAlDS7ZWdOCwXd3txv0iiNP1KHa9d7S6OHBAG6EtPN62e6Zq/aaeQS0M39WrlgqeZwC
 fENw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:subject:to:references:cc:from:message-id:date
 :user-agent:mime-version:in-reply-to;
 bh=540nQito0xeeneX1xSfzbEUE8JKmCVKxJGZCOMle74k=;
 b=IvWHv+NLDUCNrReJGCQeeNIf3DrDLzY8DY+GlWF2nd80l3pWHQstcRywyMDWnCsiy/
 /WJ/CULsc6Uj1Jig0+J63mnIapddxJm5FsAQ6iT9UHicyy0FfxvgCi1wFn+DGoBkdeJ3
 sxOIHtg+mpi/NRRJ0+mZFLXOuxSLjDgaX6sELU1vgOYv85DPMFaCI485yaGWkSlcyzg2
 eN3Zp/q7Fp54im/c4zqWQyWRqxuiXz9RG4B77U5dL6ZLVDeYRsXI5seMGHWQWki0/ETz
 OIko/oX6o+FHAA6SCX2uCZVzZm/zVyZuBDVmxx93wkKOvDK1GJlhYu1qCCtGmX7AF9af
 rOBA==
X-Gm-Message-State: AD7BkJIeKyPtSPi7AUr0dK21O9qiDOohhprumEskEJ894WoQBPFDtcEedFDxQc925QN+lA==
X-Received: by 10.50.168.100 with SMTP id zv4mr14634717igb.4.1460318435576;
 Sun, 10 Apr 2016 13:00:35 -0700 (PDT)
Received: from [192.168.1.53] (d162-157-118-249.abhsia.telus.net.
 [162.157.118.249])
 by smtp.gmail.com with ESMTPSA id i187sm14729473ioi.33.2016.04.10.13.00.33
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 10 Apr 2016 13:00:34 -0700 (PDT)
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
To: Tom Yan <tom.ty89@HIDDEN>
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
 <20160104174524.GC12500@HIDDEN> <568AB233.7060808@HIDDEN>
 <CAGnHSEmf=O5KB27QpBtrwjVEx0eETuCispqs84Q10chMdaH==g@HIDDEN>
From: Curtis Gedak <gedakc@HIDDEN>
Message-ID: <570AB0E1.7060501@HIDDEN>
Date: Sun, 10 Apr 2016 14:00:33 -0600
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <CAGnHSEmf=O5KB27QpBtrwjVEx0eETuCispqs84Q10chMdaH==g@HIDDEN>
Content-Type: multipart/mixed; boundary="------------080907000304070407070401"
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
Cc: bcl@HIDDEN, d-eberhdt64@HIDDEN, bug-parted@HIDDEN,
 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

This is a multi-part message in MIME format.
--------------080907000304070407070401
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Attached is a patch to fix the issue with jump instruction and boot code
is corrupted with random bytes after fat is resized.

Thanks goes to Tom Yan, Dirk Eberhardt, and others who reported the
problem and provided additional details.  This detailed information
helped with my understanding of the issue.

The portion of this email after my signature delves further into the
problem investigation and solution.

Regards,
Curtis Gedak


PROBLEM
-------

Windows does not recognize FAT32 after resizing with utilities (for
example GParted) that use parted-3.2 libraries.


CONFIRMATION
------------

Steps to confirm are:

1) Create a single FAT32 partition (e.g. 500 MiB) on a device such as
   a USB drive.

   When I created FAT32 partition using GParted the boot sector
   started with:

   $ sudo hexdump -n 7k -C /dev/sda1
   00000000  eb 58 90 6d 6b 66 73                              |.X.mkfs|
   00000007
   $

2) Use GParted linked with parted-3.2 libraries to shrink the FAT32
   partition (e.g. 450 MiB).

   After FAT32 resizing using GParted the boot sector started with:

   $ sudo hexdump -n 7k -C /dev/sda1
   00000000  d0 02 30 4d 53 57 49                              |..0MSWI|
   00000007
   $

   The important distinction is that the first three hexadecimal
   values were randomly changed.  These values represent the "boot
   jump" code and Windows requires these values to be correctly set.

3) Try to use the FAT32 partition with Windows (e.g. insert USB drive
   in Windows computer).  The FAT32 file system is not recognized.

   Regarding boot_jump (and system_id) see:
   http://git.savannah.gnu.org/cgit/parted.git/tree/doc/FAT?id=v3.2#n176

If the libraries from parted 3.1, or versions 2.4 and earlier are
used, then the resized FAT32 partition is recognized by Windows.


INVESTIGATION
-------------

The problem with Windows FAT32 recognition was introduced with:

  Fix filesystem detection on non 512 byte sectors
  80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12

The cause of the problem is that when the parted library is resizing
FAT32, there is one too many boot_sector memory allocations.

The calling structure is as follows:

fat_resize (...)
{
  ...
  ctx = create_resize_context (...);  # Allocates new boot_sector
                                      #   memory and copies content
                                      #   from old boot sector
  ...
  fat_boot_sector_generate (...)      # Allocates new boot_sector
                                      #   memory AGAIN!
                                      #   Copied content lost!
  fat_boot_sector_write (...)
  ...
}


SOLUTION
--------

Remove new boot sector memory allocation from
fat_boot_sector_generate(...).

The function fat_boot_sector_generate(...) is also called from
fat_create(...).

  Note that access to fat_create(...) via ped_file_system_create(...)
  is no longer possible since parted-3.0 because all file system
  operations were removed.  See:
  http://git.savannah.gnu.org/cgit/parted.git/tree/NEWS?id=v3.0

  In parted-3.1, access to fat_create(...) via
  ped_file_system_create(...) was not re-introduced.  See:
  http://git.savannah.gnu.org/cgit/parted.git/tree/NEWS?id=v3.1

Although fat_create(...) in inaccessible, I thought it best to move
the new boot_sector memory allocation to where it is needed in
fat_boot_sector_set_boot_code(...).  That way the code should still
work if it is ever re-instated.


REFERENCES
----------

GNU bug report logs - #22266:
[libparted] jump instruction and boot code is corrupted with random
bytes after fat is resized
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22266

GNU bug report logs - #22710:
libparted 3.2 fat32 bootsector incompatible w. windows
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22710

GParted Bug Report:
Bug 759916 - fat(32) resizing generates boot sector(s) with invalid
             jump instruction and pseudo-random boot code
https://bugzilla.gnome.org/show_bug.cgi?id=759916

GParted Forum:
Vista/XP don't accept a shrinked Fat32 partition (USB-stick)
http://gparted-forum.surf4.info/viewtopic.php?id=17318

--------------080907000304070407070401
Content-Type: text/x-patch;
 name="gnubug22266-boot-code-corrupted-after-fat-resize.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="gnubug22266-boot-code-corrupted-after-fat-resize.patch"

From d9a424a6fd922f5275183ea96e911af9abb9b745 Mon Sep 17 00:00:00 2001
From: Curtis Gedak <gedakc@HIDDEN>
Date: Sun, 10 Apr 2016 11:38:41 -0600
Subject: [PATCH] lib-fs-resize: Fix recognition of FAT file system after
 resizing

When resizing a FAT partition, an extra boot_sector memory allocation
was causing the original boot_sector information to be lost.  The
resulting FAT file system was still recognized by GNU/Linux, but not
recognized by the proprietary Windows operating system.

The problem with Windows FAT32 recognition was introduced with:

  Fix filesystem detection on non 512 byte sectors
  80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12

Fix by removing the extra boot_sector memory allocation.

Note that since parted-3.0 another code path to the extra memory
allocation of fat_create(...) via ped_file_system_create(...) is
inaccessible.  In an effort to maintain the ability to re-instate the
code, add a new boot_sector memory allocation where it is needed in
the alternate code path.

GNU bug report logs - #22266
[libparted] jump instruction and boot code is corrupted with random
bytes after fat is resized
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22266
---
 libparted/fs/r/fat/bootsector.c | 9 +++++++--
 libparted/fs/r/fat/bootsector.h | 2 +-
 libparted/fs/r/fat/fat.c        | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libparted/fs/r/fat/bootsector.c b/libparted/fs/r/fat/bootsector.c
index 1d2b601..99d788d 100644
--- a/libparted/fs/r/fat/bootsector.c
+++ b/libparted/fs/r/fat/bootsector.c
@@ -281,8 +281,13 @@ fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs)
 
 #ifndef DISCOVER_ONLY
 int
-fat_boot_sector_set_boot_code (FatBootSector* bs)
+fat_boot_sector_set_boot_code (FatBootSector** bsp, const PedFileSystem* fs)
 {
+	FatSpecific*	fs_info = FAT_SPECIFIC (fs);
+
+	PED_ASSERT (bsp != NULL);
+	*bsp = ped_malloc (fs->geom->dev->sector_size);
+	FatBootSector *bs = *bsp;
 	PED_ASSERT (bs != NULL);
 
 	memset (bs, 0, 512);
@@ -297,8 +302,8 @@ fat_boot_sector_generate (FatBootSector** bsp, const PedFileSystem* fs)
 	FatSpecific*	fs_info = FAT_SPECIFIC (fs);
 
 	PED_ASSERT (bsp != NULL);
-	*bsp = ped_malloc (fs->geom->dev->sector_size);
 	FatBootSector *bs = *bsp;
+	PED_ASSERT (bs != NULL);
 
 	memcpy (bs->system_id, "MSWIN4.1", 8);
 	bs->sector_size = PED_CPU_TO_LE16 (fs_info->logical_sector_size * 512);
diff --git a/libparted/fs/r/fat/bootsector.h b/libparted/fs/r/fat/bootsector.h
index e92842c..3f84d7f 100644
--- a/libparted/fs/r/fat/bootsector.h
+++ b/libparted/fs/r/fat/bootsector.h
@@ -120,7 +120,7 @@ int fat_boot_sector_read (FatBootSector** bs, const PedGeometry* geom);
 FatType fat_boot_sector_probe_type (const FatBootSector* bs,
 				    const PedGeometry* geom);
 int fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs);
-int fat_boot_sector_set_boot_code (FatBootSector* bs);
+int fat_boot_sector_set_boot_code (FatBootSector** bs, const PedFileSystem* fs);
 int fat_boot_sector_generate (FatBootSector** bs, const PedFileSystem* fs);
 int fat_boot_sector_write (const FatBootSector* bs, PedFileSystem* fs);
 
diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
index 4ecf5c5..444668d 100644
--- a/libparted/fs/r/fat/fat.c
+++ b/libparted/fs/r/fat/fat.c
@@ -310,7 +310,7 @@ fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer)
 
 	fs_info->serial_number = generate_random_uint32 ();
 
-	if (!fat_boot_sector_set_boot_code (fs_info->boot_sector))
+	if (!fat_boot_sector_set_boot_code (&fs_info->boot_sector, fs))
 		goto error_free_buffers;
 	if (!fat_boot_sector_generate (&fs_info->boot_sector, fs))
 		goto error_free_buffers;
-- 
1.9.1


--------------080907000304070407070401--




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at 22266 <at> debbugs.gnu.org:


Received: (at 22266) by debbugs.gnu.org; 4 Jan 2016 18:36:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 04 13:36:55 2016
Received: from localhost ([127.0.0.1]:37838 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aG9zy-0001Ub-Pn
	for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 13:36:54 -0500
Received: from mail-yk0-f193.google.com ([209.85.160.193]:34768)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <tom.ty89@HIDDEN>) id 1aG9zx-0001UJ-L5
 for 22266 <at> debbugs.gnu.org; Mon, 04 Jan 2016 13:36:53 -0500
Received: by mail-yk0-f193.google.com with SMTP id v14so14855654ykd.1
 for <22266 <at> debbugs.gnu.org>; Mon, 04 Jan 2016 10:36:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:in-reply-to:references:date:message-id:subject:from:to
 :cc:content-type;
 bh=9DxWdx+nVNcRt38U8jXB+2EWR+H/9N4eFnMSybYshOo=;
 b=obDH6DvdRpne1GVZ70dYY0A7PpcE768kshwh4DR2ysC3hS7mXOYUu53Ww/4Kp/S8kv
 5LLYzc1K6q8uhjDZesS2vjs+iTz2dSgoiAh0C9+vzWUno+x0VfuoOq1TayLuiuuwWL37
 PKSTH2OnfVDztOquomBAAlbDhxGCLtn+DyzwlFXDUzQEjTPbOPY/ViFLVT7LkI2VKuRX
 tIaq5OkulTjlh8U3udqv+u/TcAP2ztp4XeuHik0UUdg4Afv54ECfHJg9pU4tsXBae+YE
 jYPN24TF4ejGOnfrdxP6KnSW5a163C9f9lheVbpVFwkTrtsQ04V3IP9aLjPXqAssui9m
 jZNg==
MIME-Version: 1.0
X-Received: by 10.129.38.3 with SMTP id m3mr66330524ywm.306.1451932608143;
 Mon, 04 Jan 2016 10:36:48 -0800 (PST)
Received: by 10.13.222.6 with HTTP; Mon, 4 Jan 2016 10:36:48 -0800 (PST)
In-Reply-To: <568AB233.7060808@HIDDEN>
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
 <20160104174524.GC12500@HIDDEN>
 <568AB233.7060808@HIDDEN>
Date: Tue, 5 Jan 2016 02:36:48 +0800
Message-ID: <CAGnHSEmf=O5KB27QpBtrwjVEx0eETuCispqs84Q10chMdaH==g@HIDDEN>
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
From: Tom Yan <tom.ty89@HIDDEN>
To: Curtis Gedak <gedakc@HIDDEN>
Content-Type: text/plain; charset=UTF-8
X-Spam-Score: -0.5 (/)
X-Debbugs-Envelope-To: 22266
Cc: bcl@HIDDEN, bug-parted@HIDDEN, 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

Well what I meant was commit 80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12
makes gparted simply quit with error when trying to resize FAT, and
commit 5adae27101565a5d6fed4aadf28ddb39872e41f5 fix that but
introduced the issue I am reporting now. (Well actually, I CANNOT know
exactly which of them introduced it.)

Well yeah dosfstools does not provide any resizing tool. Funny thing
is not even Windows support FAT resizing in its disk management util
(but it support that for NTFS).

On 5 January 2016 at 01:56, Curtis Gedak <gedakc@HIDDEN> wrote:
> Hi Brian,
>
> I agree that in an ideal world the code for resizing file systems would
> exist in the file system project.  Unfortunately this does not appear to
> be the case for FAT16/FAT32 file systems.
>
> When I last looked there were no other free software or open source
> options for resizing FAT16 and FAT32 file systems.  The same goes for
> the code in libparted that can shrink HFS and HFS+ file systems.
>
> Unless there is a change in this situation, I am in favour of keeping
> the resizing code/library in parted.
>
> Regards,
> Curtis Gedak
> (Maintainer of GParted)
>
> On 16-01-04 10:45 AM, Brian C. Lane wrote:
>> We should drop this resize code completely. I still think it was a
>> mistake to revive it as a library. Filesystems should be managed by the
>> upstream filesystem code, not parted.




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Jan 2016 18:36:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 04 13:36:58 2016
Received: from localhost ([127.0.0.1]:37841 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aGA02-0001Uq-0M
	for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 13:36:58 -0500
Received: from eggs.gnu.org ([208.118.235.92]:33209)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <tom.ty89@HIDDEN>) id 1aGA01-0001UQ-2t
 for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 13:36:57 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aG9zv-0005BX-63
 for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 13:36:51 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: *
X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50,
 FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,T_DKIM_INVALID autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:34826)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aG9zv-0005BT-2F
 for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 13:36:51 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52402)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aG9zu-00014a-10
 for bug-parted@HIDDEN; Mon, 04 Jan 2016 13:36:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aG9zt-0005B6-2e
 for bug-parted@HIDDEN; Mon, 04 Jan 2016 13:36:49 -0500
Received: from mail-yk0-x241.google.com ([2607:f8b0:4002:c07::241]:33554)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aG9zs-0005Ap-UT
 for bug-parted@HIDDEN; Mon, 04 Jan 2016 13:36:48 -0500
Received: by mail-yk0-x241.google.com with SMTP id y10so13628539ykf.0
 for <bug-parted@HIDDEN>; Mon, 04 Jan 2016 10:36:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:in-reply-to:references:date:message-id:subject:from:to
 :cc:content-type;
 bh=9DxWdx+nVNcRt38U8jXB+2EWR+H/9N4eFnMSybYshOo=;
 b=obDH6DvdRpne1GVZ70dYY0A7PpcE768kshwh4DR2ysC3hS7mXOYUu53Ww/4Kp/S8kv
 5LLYzc1K6q8uhjDZesS2vjs+iTz2dSgoiAh0C9+vzWUno+x0VfuoOq1TayLuiuuwWL37
 PKSTH2OnfVDztOquomBAAlbDhxGCLtn+DyzwlFXDUzQEjTPbOPY/ViFLVT7LkI2VKuRX
 tIaq5OkulTjlh8U3udqv+u/TcAP2ztp4XeuHik0UUdg4Afv54ECfHJg9pU4tsXBae+YE
 jYPN24TF4ejGOnfrdxP6KnSW5a163C9f9lheVbpVFwkTrtsQ04V3IP9aLjPXqAssui9m
 jZNg==
MIME-Version: 1.0
X-Received: by 10.129.38.3 with SMTP id m3mr66330524ywm.306.1451932608143;
 Mon, 04 Jan 2016 10:36:48 -0800 (PST)
Received: by 10.13.222.6 with HTTP; Mon, 4 Jan 2016 10:36:48 -0800 (PST)
In-Reply-To: <568AB233.7060808@HIDDEN>
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
 <20160104174524.GC12500@HIDDEN>
 <568AB233.7060808@HIDDEN>
Date: Tue, 5 Jan 2016 02:36:48 +0800
Message-ID: <CAGnHSEmf=O5KB27QpBtrwjVEx0eETuCispqs84Q10chMdaH==g@HIDDEN>
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
From: Tom Yan <tom.ty89@HIDDEN>
To: Curtis Gedak <gedakc@HIDDEN>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -3.8 (---)
X-Debbugs-Envelope-To: submit
Cc: bcl@HIDDEN, bug-parted@HIDDEN, 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.8 (---)

Well what I meant was commit 80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12
makes gparted simply quit with error when trying to resize FAT, and
commit 5adae27101565a5d6fed4aadf28ddb39872e41f5 fix that but
introduced the issue I am reporting now. (Well actually, I CANNOT know
exactly which of them introduced it.)

Well yeah dosfstools does not provide any resizing tool. Funny thing
is not even Windows support FAT resizing in its disk management util
(but it support that for NTFS).

On 5 January 2016 at 01:56, Curtis Gedak <gedakc@HIDDEN> wrote:
> Hi Brian,
>
> I agree that in an ideal world the code for resizing file systems would
> exist in the file system project.  Unfortunately this does not appear to
> be the case for FAT16/FAT32 file systems.
>
> When I last looked there were no other free software or open source
> options for resizing FAT16 and FAT32 file systems.  The same goes for
> the code in libparted that can shrink HFS and HFS+ file systems.
>
> Unless there is a change in this situation, I am in favour of keeping
> the resizing code/library in parted.
>
> Regards,
> Curtis Gedak
> (Maintainer of GParted)
>
> On 16-01-04 10:45 AM, Brian C. Lane wrote:
>> We should drop this resize code completely. I still think it was a
>> mistake to revive it as a library. Filesystems should be managed by the
>> upstream filesystem code, not parted.




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at 22266 <at> debbugs.gnu.org:


Received: (at 22266) by debbugs.gnu.org; 4 Jan 2016 17:56:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 04 12:56:12 2016
Received: from localhost ([127.0.0.1]:37812 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aG9Ma-0000VX-FF
	for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:56:12 -0500
Received: from mail-io0-f169.google.com ([209.85.223.169]:36688)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <gedakc@HIDDEN>) id 1aG9MZ-0000VL-N9
 for 22266 <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:56:12 -0500
Received: by mail-io0-f169.google.com with SMTP id o67so441881361iof.3
 for <22266 <at> debbugs.gnu.org>; Mon, 04 Jan 2016 09:56:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=subject:to:references:cc:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-type:content-transfer-encoding;
 bh=qo9W4rgbnex8jewRXisYz+W2kcqbHzPfP7kWznVZiew=;
 b=G1mRfYEieKP4REhBqXcR7huyQZhCJA9QKPgSmw7D1wuAjfmiy7IZq7C+2nBNhhf6is
 r3RtqLfAWZsRD+lBVZr6g/8n9v5ODKIEZ1cK7rZ3u3GY/qLPbv68qKrj16vyOaRj7EvW
 8IqYPoXD98C6vOi4JFKmWE6K/QwIjnbf4SmxP6Z40vn/Hx6GhC/xZZJuVTqGBJiSDKGt
 jrz4cE1sbFKA1UOJmEx/ZeOTp3f3x9S01Eo4apdUrLgZxvmWEjiAaZ9BrIBGjgkgsoui
 8XRVoUsTkIPWhbpvluHcOnzRrBukIo84QLFu7YIIo49OzwLxeUCAJdFUVECN02jGoltO
 z2Zg==
X-Received: by 10.107.185.214 with SMTP id j205mr54127927iof.175.1451930166143; 
 Mon, 04 Jan 2016 09:56:06 -0800 (PST)
Received: from [192.168.1.53] (d162-157-118-249.abhsia.telus.net.
 [162.157.118.249])
 by smtp.gmail.com with ESMTPSA id t69sm21653588ioi.9.2016.01.04.09.56.04
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 04 Jan 2016 09:56:05 -0800 (PST)
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
To: bcl@HIDDEN
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
 <20160104174524.GC12500@HIDDEN>
From: Curtis Gedak <gedakc@HIDDEN>
Message-ID: <568AB233.7060808@HIDDEN>
Date: Mon, 4 Jan 2016 10:56:03 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.4.0
MIME-Version: 1.0
In-Reply-To: <20160104174524.GC12500@HIDDEN>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 22266
Cc: tom.ty89@HIDDEN, bug-parted@HIDDEN, 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Hi Brian,

I agree that in an ideal world the code for resizing file systems would
exist in the file system project.  Unfortunately this does not appear to
be the case for FAT16/FAT32 file systems.

When I last looked there were no other free software or open source
options for resizing FAT16 and FAT32 file systems.  The same goes for
the code in libparted that can shrink HFS and HFS+ file systems.

Unless there is a change in this situation, I am in favour of keeping
the resizing code/library in parted.

Regards,
Curtis Gedak
(Maintainer of GParted)

On 16-01-04 10:45 AM, Brian C. Lane wrote:
> We should drop this resize code completely. I still think it was a
> mistake to revive it as a library. Filesystems should be managed by the
> upstream filesystem code, not parted.




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Jan 2016 17:56:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 04 12:56:18 2016
Received: from localhost ([127.0.0.1]:37815 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aG9Mg-0000Vs-MB
	for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:56:18 -0500
Received: from eggs.gnu.org ([208.118.235.92]:50529)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <gedakc@HIDDEN>) id 1aG9Mf-0000VW-6p
 for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:56:17 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1aG9MZ-0004bz-3J
 for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:56:11 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:45631)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1aG9MZ-0004bv-0b
 for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:56:11 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:41499)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1aG9MY-0008Ik-7X
 for bug-parted@HIDDEN; Mon, 04 Jan 2016 12:56:10 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1aG9MV-0004bg-2S
 for bug-parted@HIDDEN; Mon, 04 Jan 2016 12:56:10 -0500
Received: from mail-io0-x22e.google.com ([2607:f8b0:4001:c06::22e]:34795)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gedakc@HIDDEN>) id 1aG9MU-0004ba-Uh
 for bug-parted@HIDDEN; Mon, 04 Jan 2016 12:56:07 -0500
Received: by mail-io0-x22e.google.com with SMTP id 1so115920026ion.1
 for <bug-parted@HIDDEN>; Mon, 04 Jan 2016 09:56:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=subject:to:references:cc:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-type:content-transfer-encoding;
 bh=qo9W4rgbnex8jewRXisYz+W2kcqbHzPfP7kWznVZiew=;
 b=G1mRfYEieKP4REhBqXcR7huyQZhCJA9QKPgSmw7D1wuAjfmiy7IZq7C+2nBNhhf6is
 r3RtqLfAWZsRD+lBVZr6g/8n9v5ODKIEZ1cK7rZ3u3GY/qLPbv68qKrj16vyOaRj7EvW
 8IqYPoXD98C6vOi4JFKmWE6K/QwIjnbf4SmxP6Z40vn/Hx6GhC/xZZJuVTqGBJiSDKGt
 jrz4cE1sbFKA1UOJmEx/ZeOTp3f3x9S01Eo4apdUrLgZxvmWEjiAaZ9BrIBGjgkgsoui
 8XRVoUsTkIPWhbpvluHcOnzRrBukIo84QLFu7YIIo49OzwLxeUCAJdFUVECN02jGoltO
 z2Zg==
X-Received: by 10.107.185.214 with SMTP id j205mr54127927iof.175.1451930166143; 
 Mon, 04 Jan 2016 09:56:06 -0800 (PST)
Received: from [192.168.1.53] (d162-157-118-249.abhsia.telus.net.
 [162.157.118.249])
 by smtp.gmail.com with ESMTPSA id t69sm21653588ioi.9.2016.01.04.09.56.04
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 04 Jan 2016 09:56:05 -0800 (PST)
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
To: bcl@HIDDEN
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
 <20160104174524.GC12500@HIDDEN>
From: Curtis Gedak <gedakc@HIDDEN>
Message-ID: <568AB233.7060808@HIDDEN>
Date: Mon, 4 Jan 2016 10:56:03 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.4.0
MIME-Version: 1.0
In-Reply-To: <20160104174524.GC12500@HIDDEN>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
Cc: tom.ty89@HIDDEN, bug-parted@HIDDEN, 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

Hi Brian,

I agree that in an ideal world the code for resizing file systems would
exist in the file system project.  Unfortunately this does not appear to
be the case for FAT16/FAT32 file systems.

When I last looked there were no other free software or open source
options for resizing FAT16 and FAT32 file systems.  The same goes for
the code in libparted that can shrink HFS and HFS+ file systems.

Unless there is a change in this situation, I am in favour of keeping
the resizing code/library in parted.

Regards,
Curtis Gedak
(Maintainer of GParted)

On 16-01-04 10:45 AM, Brian C. Lane wrote:
> We should drop this resize code completely. I still think it was a
> mistake to revive it as a library. Filesystems should be managed by the
> upstream filesystem code, not parted.




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at 22266 <at> debbugs.gnu.org:


Received: (at 22266) by debbugs.gnu.org; 4 Jan 2016 17:45:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 04 12:45:32 2016
Received: from localhost ([127.0.0.1]:37804 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aG9CG-0000Fg-4Y
	for submit <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:45:32 -0500
Received: from mx1.redhat.com ([209.132.183.28]:33811)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <bcl@HIDDEN>) id 1aG9CD-0000FR-IJ
 for 22266 <at> debbugs.gnu.org; Mon, 04 Jan 2016 12:45:30 -0500
Received: from int-mx10.intmail.prod.int.phx2.redhat.com
 (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
 by mx1.redhat.com (Postfix) with ESMTPS id B9119C109085;
 Mon,  4 Jan 2016 17:45:26 +0000 (UTC)
Received: from lister.brianlane.com (ovpn-113-139.phx2.redhat.com
 [10.3.113.139])
 by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id
 u04HjOVW025433
 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO);
 Mon, 4 Jan 2016 12:45:26 -0500
Date: Mon, 4 Jan 2016 09:45:24 -0800
From: "Brian C. Lane" <bcl@HIDDEN>
To: Tom Yan <tom.ty89@HIDDEN>
Subject: Re: bug#22266: [libparted] jump instruction and boot code is
 corrupted with random bytes after fat is resized
Message-ID: <20160104174524.GC12500@HIDDEN>
References: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
User-Agent: Mutt/1.5.24 (2015-08-30)
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 22266
Cc: 22266 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

On Tue, Dec 29, 2015 at 06:08:31PM +0800, Tom Yan wrote:
> https://gist.github.com/tomty89/2a1ca8698bad5ae969ad/revisions?diff=split
> 
> The (last) diff compares a FAT32 resized with a working commit of
> libparted and a not working one. You can see that in the latter, the
> jump instruction and boot code in the boot sectors are not preserved
> but completely corrupted by random bytes. (FWIW, the first byte "eb"
> is crucial for Windows to recognize the filesystem)
> 
> The last working commit I can confirm is:
> http://git.savannah.gnu.org/cgit/parted.git/commit/?id=d0a4cc1b57750a92afb48b229e4791154afa322b
> 
> which is the commit right before:
> http://git.savannah.gnu.org/cgit/parted.git/commit/?id=80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12
> 
> where FAT resizing no longer works, until:
> http://git.savannah.gnu.org/cgit/parted.git/commit/?id=5adae27101565a5d6fed4aadf28ddb39872e41f5
> 
> which is the first commit I can confirm to have this issue.
> 
> I've also tested the latest commit:
> http://git.savannah.gnu.org/cgit/parted.git/commit/?id=388bab890a4e09b09d2428c0e773ed083295f91b
> 
> which does not work properly either.
> 
> See this bug report for more details:
> https://bugzilla.gnome.org/show_bug.cgi?id=759916

So you are saying that commit 5adae27101565a5d6fed4aadf28ddb39872e41f5
does *not* fix the problem?

We should drop this resize code completely. I still think it was a
mistake to revive it as a library. Filesystems should be managed by the
upstream filesystem code, not parted.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)




Information forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Dec 2015 17:59:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 29 12:59:27 2015
Received: from localhost ([127.0.0.1]:48881 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aDyYQ-0004D8-25
	for submit <at> debbugs.gnu.org; Tue, 29 Dec 2015 12:59:27 -0500
Received: from eggs.gnu.org ([208.118.235.92]:39485)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <tom.ty89@HIDDEN>) id 1aDrCq-0006QP-El
 for submit <at> debbugs.gnu.org; Tue, 29 Dec 2015 05:08:40 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aDrCk-0003SM-8B
 for submit <at> debbugs.gnu.org; Tue, 29 Dec 2015 05:08:35 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: *
X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50,
 FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,T_DKIM_INVALID autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:37577)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aDrCk-0003SH-58
 for submit <at> debbugs.gnu.org; Tue, 29 Dec 2015 05:08:34 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58681)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aDrCj-0005HC-3P
 for bug-parted@HIDDEN; Tue, 29 Dec 2015 05:08:34 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aDrCh-0003S0-T1
 for bug-parted@HIDDEN; Tue, 29 Dec 2015 05:08:33 -0500
Received: from mail-yk0-x231.google.com ([2607:f8b0:4002:c07::231]:33924)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <tom.ty89@HIDDEN>) id 1aDrCh-0003Rw-PI
 for bug-parted@HIDDEN; Tue, 29 Dec 2015 05:08:31 -0500
Received: by mail-yk0-x231.google.com with SMTP id a85so48314644ykb.1
 for <bug-parted@HIDDEN>; Tue, 29 Dec 2015 02:08:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:date:message-id:subject:from:to:content-type;
 bh=wyJ+rInAvA1sRyZOK832BWPGMTme9sU5h6BdV8woMw8=;
 b=cm6IF6iNjlgbCNnwZDziH+MnV3XjpVReCChMPxxr+OGT8GKP/d8Ob4tGk2WKlxr2Aq
 XZhcf6zv/X19RlnqM64iHYlO+LpO0bdGCt9XdDMGuArmVNc3XuZkchyTIoM49nHJRBEM
 Cl8tGjtTq52cvsPDKlzKLyFjhSgvYHdxk2br28t8isI6Bv0QORXJZ4ySlgjbyyeyHbaW
 VVOhsTiKSyGduxF0k0Ika1wJP9rdH/335zrpJRSFghrTbeSa7OZ7r5sSWu/+ciFZc+tI
 uiEFn/7GXoZ9T8mYiD2qGj2IKCw6QB8hKZ6KCRRnLoIM59lZSQjniBV/oU24k0+1iFhj
 FyKg==
MIME-Version: 1.0
X-Received: by 10.129.116.213 with SMTP id p204mr33281953ywc.322.1451383711253; 
 Tue, 29 Dec 2015 02:08:31 -0800 (PST)
Received: by 10.13.222.6 with HTTP; Tue, 29 Dec 2015 02:08:31 -0800 (PST)
Date: Tue, 29 Dec 2015 18:08:31 +0800
Message-ID: <CAGnHSEmX2jni33GL9aQOrzNZNnT1iuCYypKUYnK3vcvq8r3SBA@HIDDEN>
Subject: [libparted] jump instruction and boot code is corrupted with random
 bytes after fat is resized
From: Tom Yan <tom.ty89@HIDDEN>
To: bug-parted@HIDDEN
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -3.8 (---)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 29 Dec 2015 12:59:25 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.8 (---)

https://gist.github.com/tomty89/2a1ca8698bad5ae969ad/revisions?diff=split

The (last) diff compares a FAT32 resized with a working commit of
libparted and a not working one. You can see that in the latter, the
jump instruction and boot code in the boot sectors are not preserved
but completely corrupted by random bytes. (FWIW, the first byte "eb"
is crucial for Windows to recognize the filesystem)

The last working commit I can confirm is:
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=d0a4cc1b57750a92afb48b229e4791154afa322b

which is the commit right before:
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=80678bdd957cf49a9ccfc8b88ba3fb8b4c63fc12

where FAT resizing no longer works, until:
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=5adae27101565a5d6fed4aadf28ddb39872e41f5

which is the first commit I can confirm to have this issue.

I've also tested the latest commit:
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=388bab890a4e09b09d2428c0e773ed083295f91b

which does not work properly either.

See this bug report for more details:
https://bugzilla.gnome.org/show_bug.cgi?id=759916




Acknowledgement sent to Tom Yan <tom.ty89@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-parted@HIDDEN. Full text available.
Report forwarded to bug-parted@HIDDEN:
bug#22266; Package parted. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.