GNU bug report logs - #16338
[PATCH 2/2] Fix filesystem detection on non 512 byte sectors

Previous Next

Package: parted;

Reported by: Phillip Susi <psusi <at> ubuntu.com>

Date: Sat, 4 Jan 2014 05:28:01 UTC

Severity: normal

Tags: patch

Done: Phillip Susi <psusi <at> ubuntu.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Phillip Susi <psusi <at> ubuntu.com>
To: "Brian C. Lane" <bcl <at> redhat.com>, 16338 <at> debbugs.gnu.org
Subject: bug#16338: [PATCH 2/2] Fix filesystem detection on non 512 byte sectors
Date: Mon, 03 Mar 2014 19:36:43 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 03/03/2014 02:45 PM, Brian C. Lane wrote:
> Do our tests already cover all of these filesystems?

I think so but now that I look at this again, it looks like I forgot
to fix the tests.  Currently they skip on !512 byte sector size.  I'll
fix that.

> 
>> diff --git a/libparted/fs/ext2/interface.c
>> b/libparted/fs/ext2/interface.c index 97220b7..ecafb62 100644 ---
>> a/libparted/fs/ext2/interface.c +++
>> b/libparted/fs/ext2/interface.c @@ -33,10 +33,12 @@ struct
>> ext2_dev_handle*
>> ext2_make_dev_handle_from_parted_geometry(PedGeometry* g static
>> PedGeometry* _ext2_generic_probe (PedGeometry* geom, int
>> expect_ext_ver) { -	void *sb_v; -	if
>> (!ped_geometry_read_alloc(geom, &sb_v, 2, 2)) +	const int sectors
>> = (4096 + geom->dev->sector_size - 1) / +
>> geom->dev->sector_size; +	char *sb_v = alloca (sectors *
>> geom->dev->sector_size); +	if (!ped_geometry_read(geom, sb_v, 0,
>> sectors)) return NULL; -	struct ext2_super_block *sb = sb_v; +
>> struct ext2_super_block *sb = (struct ext2_super_block *)(sb_v +
>> 1024);
> 
> It would probably be more readable to just read_alloc the first 4
> blocks and then point *sb at +1024 inside that.
> 
> Also, I just realized that you are using alloca for these -- I'm
> not sure we want to switch to using something that has undefined
> behavior on failure.

Practically speaking it isn't undefined; if you really blow your stack
then you get a stack fault.  Also it seems a waste to read 4 sectors
when you only need 1.  I suppose I could add a comment there to
clarify the logic.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCgAGBQJTFSAbAAoJEI5FoCIzSKrw/18IAJpp/P/NOz7eOC/Qntu+dft+
OBYeDUXK8kwJ+AukogRI9qAI6D1EX62SQ+cnaIKvGUJgXuw5YwhP5LPq6t68XR6q
1xlWRVdInj+ypTnDyGWLPu+VKuDavDTRKAocBBRjYc5bBf6RfpBYQixn7i9fWg1U
SSHk+mevNYkjpTgRop+qVcuexEVgG5z8GimiBzhwaKDgx6pHbI02e0LV7PyN8BoC
NWLAUpPci/KR5eZJaM2APozlLLzulkeNVxP7whN+swJ5fEms4QejLZPvqZooHVAI
BqRFTBepDB4cNQ9N1Rn8BqxcPl6VioQ1XM5iTCN1eH2rogvTlY/xsZHgQqWojnE=
=SFzt
-----END PGP SIGNATURE-----




This bug report was last modified 11 years and 41 days ago.

Previous Next


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