OSDN Git Service

android-x86/external-parted.git
14 years agotests: weaken t0202-gpt-pmbr to assume a preexisting GPT table
Jim Meyering [Fri, 13 Nov 2009 10:38:34 +0000 (11:38 +0100)]
tests: weaken t0202-gpt-pmbr to assume a preexisting GPT table

* tests/t0202-gpt-pmbr.sh: Lay down an initial GPT table before
writing to the MBR, so this test passes with the new semantics.

14 years agotests: rewrite t0202 to use new framework
Jim Meyering [Fri, 13 Nov 2009 08:45:49 +0000 (09:45 +0100)]
tests: rewrite t0202 to use new framework

* tests/t0202-gpt-pmbr.sh: Rewrite.

14 years agoped_disk_type_get_next: fix a const-correctness bug
Jim Meyering [Fri, 13 Nov 2009 08:44:30 +0000 (09:44 +0100)]
ped_disk_type_get_next: fix a const-correctness bug

* libparted/disk.c (ped_disk_type_get_next): Make param const.
* include/parted/disk.h (ped_disk_type_get_next): Update prototype.

14 years agoNEWS: mention recent changes
Hans de Goede [Tue, 10 Nov 2009 08:26:15 +0000 (09:26 +0100)]
NEWS: mention recent changes

14 years agomaint: more const-correctness fixes
Jim Meyering [Tue, 10 Nov 2009 12:32:30 +0000 (13:32 +0100)]
maint: more const-correctness fixes

14 years agodasd: fix ped_disk_new_fresh to not read old data from disk
Hans de Goede [Mon, 9 Nov 2009 17:26:55 +0000 (18:26 +0100)]
dasd: fix ped_disk_new_fresh to not read old data from disk

dasd_write(), was reading the volume label from the disk (trough
fdasd_check_volume()) and later writing it back again, this is fine for
existing dasd labels, but when creating a fresh label, this would
also cause the old volume label to be re-used, and if the old label
was corrupt, it would cause fdasd_check_volume() and thus dasd_write()
to fail.  Reported here: http://bugzilla.redhat.com/533808

* libparted/arch/linux.c: include fdasd.h.
(init_dasd): Do BIODASDINFO ioctl, and store the dasd devno in
arch_specific.
(init_dasd): Remove dead (never reached) code.
* libparted/arch/linux.h (struct _LinuxSpecific): Add devno member.
* libparted/labels/dasd.c (DasdDiskSpecific): add vlabel member.
(dasd_alloc): Init DasdDiskSpecific.vlabel for fresh disks
(dasd_read): Store read vlabel in DasdDiskSpecific.vlabel.
(dasd_write): Write DasdDiskSpecific.vlabel instead of on disk vlabel.

14 years agobuild: avoid s390-specific compilation failiure
Jim Meyering [Tue, 10 Nov 2009 12:06:39 +0000 (13:06 +0100)]
build: avoid s390-specific compilation failiure

* libparted/labels/vtoc.c (vtoc_volume_label_init): Don't use
strncpy to copy 84 bytes into a 4-byte field.  Instead, use
memcpy to copy "sizeof *vlabel" bytes into the "vlabel".

14 years agomaint: fix s390-specific const correctness problems
Jim Meyering [Tue, 10 Nov 2009 11:19:26 +0000 (12:19 +0100)]
maint: fix s390-specific const correctness problems

* libparted/labels/vtoc.c (vtoc_error, vtoc_ebcdic_enc):
(vtoc_ebcdic_dec): Declare parameters to be const, as required.
* libparted/labels/fdasd.c (fdasd_error): Likewise.
* include/parted/vtoc.h (vtoc_ebcdic_enc, vtoc_ebcdic_enc): Update
prototypes.

14 years agogpt: fix a bug in the new PE-array CRC checks on big-endian systems
Jim Meyering [Tue, 10 Nov 2009 14:20:08 +0000 (15:20 +0100)]
gpt: fix a bug in the new PE-array CRC checks on big-endian systems

* libparted/labels/gpt.c (check_PE_array_CRC, gpt_read): Always
convert the PartitionEntryArrayCRC32 to CPU endianness before
comparing with a just-computed CRC.

14 years agobuild: use gnulib's canonicalize-lgpl module
Jim Meyering [Sun, 8 Nov 2009 16:35:52 +0000 (17:35 +0100)]
build: use gnulib's canonicalize-lgpl module

Replace Parted's private version of canonicalize_file_name.
* libparted/device.c: Include <stdlib.h>.
(canonicalize_file_name) [!HAVE_CANONICALIZE_FILE_NAME]:
Remove definition.
* bootstrap.conf (gnulib_modules): Add canonicalize-lgpl.

14 years agolibparted: linux: don't deref NULL upon failed malloc or realloc
Jim Meyering [Sat, 7 Nov 2009 16:02:50 +0000 (17:02 +0100)]
libparted: linux: don't deref NULL upon failed malloc or realloc

* libparted/arch/linux.c (_read_fd): Handle allocation failure.

14 years agobuild: update gnulib submodule to latest
Jim Meyering [Sat, 7 Nov 2009 15:32:37 +0000 (16:32 +0100)]
build: update gnulib submodule to latest

14 years agomaint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exit
Jim Meyering [Sat, 7 Nov 2009 15:47:37 +0000 (16:47 +0100)]
maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exit

Convert all uses automatically, via these two commands:
git grep -l '\<exit *(1)'|xargs --no-run-if-empty \
  perl -pi -e 's/\b(exit ?)\(1\)/$1(EXIT_FAILURE)/'
git grep -l '\<exit *(0)'|xargs --no-run-if-empty \
  perl -pi -e 's/\b(exit ?)\(0\)/$1(EXIT_SUCCESS)/'
* libparted/fs/fat/table.c (fat_table_get): Use symbolic exit codes.
* libparted/labels/vtoc.c (vtoc_update_format5_label_add): Likewise.
(vtoc_update_format5_label_del): Likewise.
(vtoc_update_format7_label_add): Likewise.
(vtoc_update_format7_label_del): Likewise.
* m4/parted.m4 (PARTED_CHECK_LIBPARTED): Likewise.
* parted/parted.c (do_quit): Likewise.
* parted/strlist.c (gettext_to_wchar, wchar_to_str): Likewise.
* parted/ui.c (reset_env, help_msg, non_interactive_mode): Likewise.

14 years agodasd: fix unused variable warning
Hans de Goede [Fri, 6 Nov 2009 16:50:52 +0000 (17:50 +0100)]
dasd: fix unused variable warning

* libparted/labels/dasd.c (dasd_get_partition_alignment): Fix unused
variable warning.

14 years agolinux: use cached major minor instead of statting the device again
Hans de Goede [Fri, 6 Nov 2009 16:50:51 +0000 (17:50 +0100)]
linux: use cached major minor instead of statting the device again

* libparted/arch/linux.c (_dm_remove_parts): Use cached major/minor
numbers.

14 years agolinux: use devicemapper task name instead of device node name
Hans de Goede [Fri, 6 Nov 2009 16:50:50 +0000 (17:50 +0100)]
linux: use devicemapper task name instead of device node name

Use devicemapper task name instead of device node name as basename for
devicemapper disk partitions.

This is needed for upcoming lvm changes where the /dev/mapper/foobar
files are becoming symlinks, so we will end up opening /dev/dm-#,
and naming our partitions dm-#p1, dm-#p2, instead of foobarp1,
foobarp2, etc.

14 years agolinux: use major / minor to specify device mapper device in dm_task
Hans de Goede [Fri, 6 Nov 2009 16:50:49 +0000 (17:50 +0100)]
linux: use major / minor to specify device mapper device in dm_task

Use major / minor to specify device mapper device instead of
dm_task_set_name. This is needed for upcoming lvm changes where the
/dev/mapper/foobar files are becoming symlinks, so we will end up
opening /dev/dm-#, and dm-# is not a valid dm_task name.

This is only needed in this one place, as in the other places where we
use dm_task_set_name, the name we use was returned by libdevicemapper
itself in an earlier function call.

14 years agotests: enable the FS-resizing (tests only HFS and FAT)
Jim Meyering [Fri, 6 Nov 2009 08:57:49 +0000 (09:57 +0100)]
tests: enable the FS-resizing (tests only HFS and FAT)

* tests/Makefile.am (TESTS): Add t3000-resize-fs.sh.

14 years agomaint: remove stray "types and" in the big FS-op warning
Jim Meyering [Fri, 6 Nov 2009 08:55:26 +0000 (09:55 +0100)]
maint: remove stray "types and" in the big FS-op warning

* parted/parted.c (issue_fs_op_warning): Correct grammar in diagnostic.

14 years agotests: convert more tests to new framework
Jim Meyering [Fri, 6 Nov 2009 07:14:32 +0000 (08:14 +0100)]
tests: convert more tests to new framework

* tests/t0400-loop-clobber-infloop.sh: Convert.
* tests/t0010-script-no-ctrl-chars.sh: Likewise.
* tests/t3000-resize-fs.sh: Likewise, and convert it to use scsi_debug.
* tests/t-local.sh (require_512_byte_sector_size_): Copy this
function from test-lib.sh.

14 years agodasd: fix disk duplication
Hans de Goede [Tue, 3 Nov 2009 12:09:00 +0000 (13:09 +0100)]
dasd: fix disk duplication

Fix dasd_duplicate and add a dasd_partition_duplicate function.
* libparted/labels/dasd.c(dasd_partition_duplicate): New function.
(dasd_duplicate): Don't set the disk_specific pointer to NULL!
(dasd_duplicate): Copy DasdDiskSpecific from old disk to new disk.

14 years agodasd: set disk_specific->format_type in dasd_alloc
Hans de Goede [Tue, 3 Nov 2009 12:08:59 +0000 (13:08 +0100)]
dasd: set disk_specific->format_type in dasd_alloc

Set disk_specific->format_type in dasd_alloc, so that the disk
returned by ped_disk_new_fresh is a valid dasd disk.
* libparted/labels/dasd.c (dasd_alloc): Set disk_specific->format_type.

14 years agodasd: cache real_sector_size in linux_probe
Hans de Goede [Tue, 3 Nov 2009 12:08:58 +0000 (13:08 +0100)]
dasd: cache real_sector_size in linux_probe

dasd_alloc was doing an ioctl to get the real sector size for the dasd
device (we are faking 512 bytes sectors), but when called directly
from ped_disk_new_fresh(), the device is not open causing this to fail.

This patch fixes things by caching the real_sector_size in the linux
arch_specific data and making the dasd label handling use this.
libparted/arch/linux.c(_device_set_sector_size): Cache real sector size.
(_device_set_sector_size, init_dasd, linux_new): Only compile dasd code
on s390 and s390x.

14 years agodasd: remove bogus part_info pointer from DasdPartitionData
Hans de Goede [Tue, 3 Nov 2009 12:08:57 +0000 (13:08 +0100)]
dasd: remove bogus part_info pointer from DasdPartitionData

The part_info pointer in DasdPartitionData was only used to
pass fdasd partition_info_t pointers from dasd_write to
the dasd_write dasd_update_type utility function. Since these
pointers are not valid outside the lifetime of dasd_write, they
should not be stored in the longer lived DasdPartitionData.

* libparted/labels/dasd.c(DasdPartitionData): Remove part_info member.
(dasd_read): Stop setting DasdPartitionData part_info.
(dasd_update_type): Add part_info argument to pass fdasd
partition_info_t pointers from dasd_write.
(dasd_write): Stop setting DasdPartitionData part_info, pass
partition_info_t pointers to dasd_update_type as a separate argument.

14 years agodasd: clean up anchor handling
Hans de Goede [Tue, 3 Nov 2009 12:08:56 +0000 (13:08 +0100)]
dasd: clean up anchor handling

The current dasd label code keeps an fdasd anchor struct in the
DasdDiskSpecific struct, and fills this during dasd_read. However this
anchor does not get updated with any future mods, until dasd_write,
at which points it gets completely re-initialized.

Since the contents of the anchor saved during read does not get used
anywhere else, this patch switches to using local anchor structs in
dasd_read and dasd_write. This will also allow writing a significantly
simpler duplicate implementation, then the one which is currently
added to the Fedora package with a patch from Joel Granados (The
current master dasd_duplicate implementation is not functional).

This patch also fixes several missing calls to fdasd_cleanup() fixing
several memory leaks.

* libparted/arch/linux.h (struct _LinuxSpecific): Drop anchor member.
* libparted/labels/dasd.c (DasdDiskSpecific): Drop anchor member.
(dasd_clobber): Add missing fdasd_cleanup().
(dasd_read, dasd_write): Use local anchor struct instead of a
dynamically allocated one in DasdDiskSpecific.
(dasd_read): Don't leak a PedConstraint in 2 error paths.
(dasd_update_type): Pass in the used anchor as argument.

14 years agotests: distribute new files, t-local.sh and t-lvm.sh
Jim Meyering [Tue, 3 Nov 2009 18:33:35 +0000 (19:33 +0100)]
tests: distribute new files, t-local.sh and t-lvm.sh

* tests/Makefile.am (EXTRA_DIST): Add t-local.sh and t-lvm.sh.

14 years agotests: appease "make syntax-check"
Jim Meyering [Tue, 3 Nov 2009 18:26:13 +0000 (19:26 +0100)]
tests: appease "make syntax-check"

* tests/print-align.c: Include "progname.h".  Call set_program_name.

14 years agotests: t6000-dm.sh: update and adapt to changed LVM2
Jim Meyering [Tue, 3 Nov 2009 17:25:33 +0000 (18:25 +0100)]
tests: t6000-dm.sh: update and adapt to changed LVM2

* tests/t6000-dm.sh: Rewrite to use new test framework and
to disable multipath testing, since LVM2 has changed in such
a way that it no longer works with loop devices.

14 years agotests: do not invoke scsi_debug_setup_ in a subshell
Jim Meyering [Tue, 3 Nov 2009 16:19:17 +0000 (17:19 +0100)]
tests: do not invoke scsi_debug_setup_ in a subshell

* tests/t9010-big-sector.sh: Do not invoke scsi_debug_setup_ in
a subshell, since it sets a variable that cleanup machinery expects
to see.
* tests/t9020-alignment.sh: Likewise.

14 years agotests: tweak temporary dirname prefix
Jim Meyering [Tue, 3 Nov 2009 15:42:01 +0000 (16:42 +0100)]
tests: tweak temporary dirname prefix

* tests/t-lib.sh (t_): Use "pe-" as prefix, not "gz-".

14 years agotests: update lvm-utils.sh from lvm2
Jim Meyering [Tue, 3 Nov 2009 15:40:39 +0000 (16:40 +0100)]
tests: update lvm-utils.sh from lvm2

* tests/lvm-utils.sh: Merge in changes from lvm2.

14 years agotests: adapt/update lvm-related infrasture, too
Jim Meyering [Tue, 3 Nov 2009 15:33:03 +0000 (16:33 +0100)]
tests: adapt/update lvm-related infrasture, too

* tests/t-local.sh: Source t-lvm.sh.
* tests/t-lvm.sh: Clone and update of lvm-utils.sh,
for when we retire that file in favor of this one.

14 years agotests: adapt t8000-loop.sh
Jim Meyering [Tue, 3 Nov 2009 15:31:11 +0000 (16:31 +0100)]
tests: adapt t8000-loop.sh

* tests/t8000-loop.sh: Rewrite in new style, and adjust to
expect new diagnostic.

14 years agotests: print and check partition alignment info, too
Jim Meyering [Tue, 3 Nov 2009 15:29:35 +0000 (16:29 +0100)]
tests: print and check partition alignment info, too

* tests/print-align.c: Print partition alignment info, too
* tests/t9020-alignment.sh: Check partition alignment too.

14 years agotests: serialize tests that use the scsi_debug module
Jim Meyering [Mon, 2 Nov 2009 18:44:40 +0000 (19:44 +0100)]
tests: serialize tests that use the scsi_debug module

* tests/t-local.sh (scsi_debug_lock_file_): New global.
(scsi_debug_acquire_lock_): New function.
(scsi_debug_setup_): Call it, to acquire the lock.
(scsi_debug_cleanup_): Release the lock.

14 years agotests: test the new alignment functions
Jim Meyering [Mon, 2 Nov 2009 14:34:34 +0000 (15:34 +0100)]
tests: test the new alignment functions

* tests/t9020-alignment.sh: New test.
* tests/Makefile.am (TESTS): Add it to the list.

14 years agotests: factor out some more
Jim Meyering [Mon, 2 Nov 2009 14:33:15 +0000 (15:33 +0100)]
tests: factor out some more

* tests/t-local.sh (require_scsi_debug_module_): New function.
* tests/t9010-big-sector.sh: Use it.

14 years agotests: perform scsi_debug cleanup automatically...
Jim Meyering [Mon, 2 Nov 2009 11:12:24 +0000 (12:12 +0100)]
tests: perform scsi_debug cleanup automatically...

...rather than requiring each test to do it.
* tests/t-lib.sh ($cleanup_eval): New variable.  Initialize.
(remove_tmp_): Use it.
* tests/t-local.sh: Record whether modprobe succeeded.
(cleanup_eval_): Append an invocation of scsi_debug_cleanup_
so that it is always run.
(scsi_debug_cleanup_): Run rmmod only if the modprobe succeeded.
* tests/t9010-big-sector.sh (cleanup_): Remove.

14 years agotests: move scsi_debug framework into shared script
Jim Meyering [Mon, 2 Nov 2009 10:35:02 +0000 (11:35 +0100)]
tests: move scsi_debug framework into shared script

* tests/t-local.sh (-scsi_debug_cleanup_, wait_for_dev_to_appear_):
(print_sd_names_, scsi_debug_setup_): New functions, factored out of ...
* tests/t9010-big-sector.sh: ...this file.

14 years agotests: document and begin to factor out scsi_debug framework
Jim Meyering [Mon, 2 Nov 2009 10:21:06 +0000 (11:21 +0100)]
tests: document and begin to factor out scsi_debug framework

* tests/t9010-big-sector.sh: Add comments, fix a bug in
"comm" usage, prepare to factor out scsi_debug framework.

14 years agotests: add a helper program to print alignment info for a device
Jim Meyering [Sat, 31 Oct 2009 23:56:30 +0000 (00:56 +0100)]
tests: add a helper program to print alignment info for a device

* tests/print-align.c: New file.
* tests/Makefile.am (check_PROGRAMS): Define.
(AM_CPPFLAGS, LDADD): Define.
(AM_CFLAGS): Enable warnings here, too, by adding
$(WARN_CFLAGS) and $(WERROR_CFLAGS).

14 years agoImplement get_partition_alignment DiskOp for all labels which need it
Hans de Goede [Fri, 30 Oct 2009 11:59:05 +0000 (12:59 +0100)]
Implement get_partition_alignment DiskOp for all labels which need it

Implement get_partition_alignment DiskOp for all labels which require
an alignment with a grain_size != 1.

14 years agolibparted: add ped_disk_get_partition_alignment() function
Hans de Goede [Fri, 30 Oct 2009 11:59:04 +0000 (12:59 +0100)]
libparted: add ped_disk_get_partition_alignment() function

This functions get the alignment needed for partition boundaries on this disk.
The returned alignment describes the alignment for the start sector of the
partition, for all disklabel types which require alignment, except Sun
disklabels, the end sector must be aligned too. To get the end sector
alignment decrease the PedAlignment offset by 1.

14 years agolibparted: add ped_device_get_xxx_aligned_constraint() functions
Hans de Goede [Fri, 30 Oct 2009 11:59:03 +0000 (12:59 +0100)]
libparted: add ped_device_get_xxx_aligned_constraint() functions

Add ped_device_get_minimal_aligned_constraint() and
ped_device_get_optimal_aligned_constraint() functions to libparted.

These functions can be used to get a device constraint taking alignment into
account.

14 years agoped_device_get_constraint: return constraint without alignment
Hans de Goede [Fri, 30 Oct 2009 11:59:02 +0000 (12:59 +0100)]
ped_device_get_constraint: return constraint without alignment

In libparted-1.9 ped_device_get_constraint() would always return a constraint
without any start / end aligning (grain_size == 1). Now that we are starting to
support disks with a physical sector size other then 512, the old
ped_device_get_constraint() code may actually start returning constrains
with alignment info with a grain_size != 1.

Since this is a behavior change and since the old code does not take a possible
alignment info into account, this patch removes the aligning code from
ped_device_get_constraint(), so that its behavior is unchanged.

This patch also updates the functions doxygen documentation to reflect what
it has actually done all these years.

14 years agolinux: add get_xxx_alignment() functions
Hans de Goede [Fri, 30 Oct 2009 11:59:01 +0000 (12:59 +0100)]
linux: add get_xxx_alignment() functions

* libparted/arch/linux.c (get_minimum_alignment): New function.
(get_optimum_alignment): New function.

14 years agolinux: save blkid topology in arch_specific data for later use
Hans de Goede [Fri, 30 Oct 2009 11:59:00 +0000 (12:59 +0100)]
linux: save blkid topology in arch_specific data for later use

This is a preparation patch for adding get_minimum_alignment
and get_optimum_alignment functions to linux's _PedDeviceArchOps.
* libparted/arch/linux.h (struct_LinuxSpecific) [probe, topology]:
Add members.
* libparted/arch/linux.c (linux_new): initialize
arch_specific->probe and arch_specific->topology to NULL,
(linux_destroy): Free arch_specific->probe.
(get_minimum_io_size): Remove function.
(get_blkid_topology): New function.
(_device_set_sector_size): Call get_blkid_topology() instead of
get_minimum_io_size() and retrieve minimum io size from the cached
topology.

14 years agolibparted: add ped_device_get_xxx_alignment() functions
Hans de Goede [Fri, 30 Oct 2009 11:58:59 +0000 (12:58 +0100)]
libparted: add ped_device_get_xxx_alignment() functions

Add ped_device_get_minimum_alignment() and ped_device_get_optimum_alignment()
functions to libparted.

Note this is a resent of my previous patchset with a number of typos corrected:
aligment -> alignment
minimal_alignment -> minimum_aligment
optimal_alignment -> optimum_aligment

Sorry for the noise.

14 years agotests: protect t7000 from the environment
Jim Meyering [Thu, 29 Oct 2009 12:29:26 +0000 (13:29 +0100)]
tests: protect t7000 from the environment

* tests/t7000-scripting.sh: Initialize fail=0, so that an
environment setting cannot perturb the test.

14 years agotests: convert to new testing framework
Jim Meyering [Thu, 29 Oct 2009 11:34:08 +0000 (12:34 +0100)]
tests: convert to new testing framework

* tests/t0200-gpt.sh: Convert to new testing framework.
* tests/t0201-gpt.sh: Likewise.
* tests/t0300-dos-on-gpt.sh: Likewise.
* tests/t0100-print.sh: Likewise.
* tests/t0250-gpt.sh: Likewise.

14 years agodvh: document an as-yet-unplugged (but not serious) leak
Jim Meyering [Thu, 29 Oct 2009 11:22:25 +0000 (12:22 +0100)]
dvh: document an as-yet-unplugged (but not serious) leak

* libparted/disk.c (ped_disk_add_partition): List some of the
things I've tried to plug a leak exposed by a root-only test
on dvh's partition-creation error path.  This leak is enough
of a corner case that I may even leave it for now, and add a
suppression for it, so that we're not distracted by it.

14 years agodvh: plug three constraint-sized leaks
Jim Meyering [Wed, 28 Oct 2009 16:25:46 +0000 (17:25 +0100)]
dvh: plug three constraint-sized leaks

* libparted/labels/dvh.c (dvh_read, dvh_alloc_metadata):
Free constraint upon failure, too.

14 years agoui: plug multiple command_line_get_word leaks
Jim Meyering [Wed, 28 Oct 2009 15:40:07 +0000 (16:40 +0100)]
ui: plug multiple command_line_get_word leaks

* parted/parted.c (do_mkpart, do_print):

14 years agocheck: plug an even smaller (formatted "unit") leak
Jim Meyering [Wed, 28 Oct 2009 15:37:07 +0000 (16:37 +0100)]
check: plug an even smaller (formatted "unit") leak

* libparted/disk.c (ped_disk_check): Free fs_size also upon success.

14 years agocheck: plug a geometry-sized leak
Jim Meyering [Wed, 28 Oct 2009 15:19:43 +0000 (16:19 +0100)]
check: plug a geometry-sized leak

* libparted/disk.c (ped_disk_check): Destroy "geom", when done with it.

14 years agoloop: don't leak a sector in loop_clobber
Jim Meyering [Wed, 28 Oct 2009 15:03:11 +0000 (16:03 +0100)]
loop: don't leak a sector in loop_clobber

* libparted/labels/loop.c (loop_clobber): Replace leaky open-coded
version with a use of Use ptt_clear_sectors.

14 years agotests: t7000: remove mkpartfs tests
Jim Meyering [Fri, 18 Sep 2009 06:40:54 +0000 (08:40 +0200)]
tests: t7000: remove mkpartfs tests

This test tested both mkpart and mkpartfs.
* tests/t7000-scripting.sh: Remove the mkpartfs tests.

14 years agotests: remove tests that are too FS-centric
Jim Meyering [Thu, 17 Sep 2009 18:12:50 +0000 (20:12 +0200)]
tests: remove tests that are too FS-centric

* tests/t1000-mkpartfs.sh: Remove file.
* tests/t1500-small-ext2.sh: Likewise.
* tests/t2000-mkfs.sh: Likewise.
* tests/t3100-resize-ext2-partion.sh: Likewise.
* tests/t3000-constraints.sh: Likewise.
* tests/Makefile.am (TESTS): Remove them here, too.

14 years agoui: plug a constraint leak in do_mkpart
Jim Meyering [Tue, 27 Oct 2009 22:10:35 +0000 (23:10 +0100)]
ui: plug a constraint leak in do_mkpart

* parted/parted.c (do_mkpart): Free constraint after using it to
add partition.

14 years agogpt: plug two gpt-header leaks in gpt_read_headers
Jim Meyering [Tue, 27 Oct 2009 21:44:04 +0000 (22:44 +0100)]
gpt: plug two gpt-header leaks in gpt_read_headers

* libparted/labels/gpt.c (gpt_read_headers): Free locals pri and/or
bak if they are not valid.

14 years agogpt: plug a 1-sector leak in gpt_read_headers
Jim Meyering [Tue, 27 Oct 2009 21:38:02 +0000 (22:38 +0100)]
gpt: plug a 1-sector leak in gpt_read_headers

* libparted/labels/gpt.c (gpt_read_headers): Free a sector.

14 years agoui: plug a leak (partition_print_flags)
Jim Meyering [Tue, 27 Oct 2009 20:42:25 +0000 (21:42 +0100)]
ui: plug a leak (partition_print_flags)

* parted/parted.c (do_print): Free flags, after printing.

14 years agolibparted: plug an FS-alias-related leak
Jim Meyering [Tue, 27 Oct 2009 20:36:30 +0000 (21:36 +0100)]
libparted: plug an FS-alias-related leak

* libparted/filesys.c (ped_file_system_alias_unregister):
Free the alias we've just unregistered.

14 years agodoc: update NEWS
Jim Meyering [Mon, 26 Oct 2009 14:34:55 +0000 (15:34 +0100)]
doc: update NEWS

* NEWS (Bug fixes): Describe two.

14 years agogpt: header validity: also consider whether a PE array crc matches
Jim Meyering [Fri, 23 Oct 2009 14:32:20 +0000 (16:32 +0200)]
gpt: header validity: also consider whether a PE array crc matches

* libparted/labels/gpt.c (check_PE_array_CRC): New function.
(_header_is_valid): Use it to verify that partition entry array
checksums match, too.
Karel Zak noticed that this check was not being performed.
* tests/t0280-gpt-corrupt.sh: Adapt to changed diagnostic.

14 years agogpt: tweak interfaces to pass disk, not disk->dev
Jim Meyering [Fri, 23 Oct 2009 14:15:19 +0000 (16:15 +0200)]
gpt: tweak interfaces to pass disk, not disk->dev

* libparted/labels/gpt.c: required for upcoming CRC-checking function.

14 years agogpt: don't ignore an improbable (1-in-2^32) failure
Jim Meyering [Fri, 23 Oct 2009 10:48:11 +0000 (12:48 +0200)]
gpt: don't ignore an improbable (1-in-2^32) failure

pth_crc32 mapped failure to a crc32 value of 0.  If that happened
to match the stored value, there would be no indication that there
had been a malloc failure.
* libparted/labels/gpt.c (pth_crc32): Change interface so we can
distinguish failure from a CRC value of 0.
Update all callers.
(_generate_header): Now that we recognize pth_crc32 can fail,
we must admit that its void-returning caller _generate_header
may fail, too.  Return "int" and adjust *its* callers.

14 years agogpt: factor out code that is about to be reused
Jim Meyering [Thu, 22 Oct 2009 20:14:03 +0000 (22:14 +0200)]
gpt: factor out code that is about to be reused

* libparted/labels/gpt.c: Include <errno.h>.
(gpt_read_PE_array): New function, ...
(gpt_read): ...factored out of this one.  Use it.

14 years agogpt: don't dereference NULL upon OOM (pth_get_raw callers)
Jim Meyering [Thu, 22 Oct 2009 19:46:00 +0000 (21:46 +0200)]
gpt: don't dereference NULL upon OOM (pth_get_raw callers)

Handle each case in which pth_get_raw may return NULL.
* libparted/labels/gpt.c (pth_get_raw): Upon OOM error, return 0
rather than dereferencing NULL.
(gpt_write): Don't dereference NULL upon OOM error.
(gpt_read): Yet another.

14 years agogpt: don't dereference NULL upon OOM (in pth_get_raw)
Jim Meyering [Thu, 22 Oct 2009 19:34:48 +0000 (21:34 +0200)]
gpt: don't dereference NULL upon OOM (in pth_get_raw)

* libparted/labels/gpt.c (pth_get_raw): Don't dereference NULL
on out of memory error.

14 years agogpt: remove dead store
Jim Meyering [Thu, 22 Oct 2009 19:26:26 +0000 (21:26 +0200)]
gpt: remove dead store

* libparted/labels/gpt.c (pth_crc32): Remove useless initialization.

14 years agogpt: make an internal function "const"-correct
Jim Meyering [Thu, 22 Oct 2009 18:55:39 +0000 (20:55 +0200)]
gpt: make an internal function "const"-correct

* libparted/labels/gpt.c (_parse_header): Make "gpt" const.

14 years agotests: convert t0280 to new test style.
Jim Meyering [Thu, 22 Oct 2009 18:18:48 +0000 (20:18 +0200)]
tests: convert t0280 to new test style.

* tests/t0280-gpt-corrupt.sh: Convert to new test style.
* tests/t-lib.sh: Source t-local.sh.
* tests/t-local.sh: New file.

14 years agogpt: clean up
Jim Meyering [Thu, 22 Oct 2009 16:08:57 +0000 (18:08 +0200)]
gpt: clean up

* libparted/labels/gpt.c (gpt_probe): Remove now-useless test before
pth_free.
(gpt_read): Use ptt_clear_sectors in place of open-coded equivalent.
* cfg.mk (useless_free_options): Add --name=pth_free.

14 years agogpt: make its header check a tiny bit more strict
Jim Meyering [Thu, 22 Oct 2009 09:35:44 +0000 (11:35 +0200)]
gpt: make its header check a tiny bit more strict

* libparted/labels/gpt.c (_header_is_valid): Declare a header
to be invalid if its AlternateLBA is the same as MyLBA.

2009-10-21  Jim Meyering  <meyering@redhat.com>

complete most of gpt-CRC-related rewrite
* libparted/labels/gpt.c (_read_header): Remove now-unused function.

14 years agot0280-gpt-corrupt.sh: adapt for new output, improve test
Jim Meyering [Wed, 21 Oct 2009 16:21:07 +0000 (18:21 +0200)]
t0280-gpt-corrupt.sh: adapt for new output, improve test

14 years agogpt: rewrite GPT header-reading code
Jim Meyering [Wed, 21 Oct 2009 11:33:20 +0000 (13:33 +0200)]
gpt: rewrite GPT header-reading code

* libparted/labels/gpt.c (read_header): Remove now-unused function.
(gpt_read_headers): New function.
(gpt_read): Rewrite to use gpt_read_headers.

14 years agogpt: require that the backup table's AlternateLBA is 1
Jim Meyering [Mon, 19 Oct 2009 18:14:44 +0000 (20:14 +0200)]
gpt: require that the backup table's AlternateLBA is 1

* libparted/labels/gpt.c (_header_is_valid): When checking
the backup header, ensure that its AlternateLBA is 1.

14 years agotests: gpt: test for detection of corrupt backup partition header
Jim Meyering [Mon, 19 Oct 2009 18:12:41 +0000 (20:12 +0200)]
tests: gpt: test for detection of corrupt backup partition header

* tests/t0280-gpt-corrupt.sh: Corrupt the backup partition header's
MyLBA, and require that an attempt to print the table fails.

14 years agotests: hook up new GPT-crc-corrupting script
Jim Meyering [Mon, 19 Oct 2009 16:55:06 +0000 (18:55 +0200)]
tests: hook up new GPT-crc-corrupting script

* tests/Makefile.am (TESTS): Add t0280-gpt-corrupt.sh.
* libparted/labels/gpt.c (gpt_read): Change diagnostic to say that
the PTE CRC mismatch is in the primary table.
* tests/t0280-gpt-corrupt.sh: Tweak diagnostic to match
what the code now prints.

14 years agogpt: also verify MyLBA when checking table validity
Jim Meyering [Mon, 19 Oct 2009 16:47:00 +0000 (18:47 +0200)]
gpt: also verify MyLBA when checking table validity

* libparted/labels/gpt.c (_header_is_valid): Add parameter, my_lba.
(_read_header): Update caller.
(_parse_header): Comment out this use of _header_is_valid
in an assertion.

14 years agogpt: clean up formatting of static initializers
Jim Meyering [Mon, 19 Oct 2009 16:03:46 +0000 (18:03 +0200)]
gpt: clean up formatting of static initializers

* libparted/labels/gpt.c (NULL_IF_DISCOVER_ONLY): Define.
(gpt_disk_ops): Use it to avoid in-decl #if directives.

14 years agogpt.c: filter through indent --no-tabs...
Jim Meyering [Mon, 19 Oct 2009 15:34:19 +0000 (17:34 +0200)]
gpt.c: filter through indent --no-tabs...

and manual fix-up to shorten long lines.
Also, manually format the static initializers in e.g., gpt_disk_ops,
since GNU indent botches that.

14 years agogpt: add a comment
Jim Meyering [Mon, 19 Oct 2009 14:56:21 +0000 (16:56 +0200)]
gpt: add a comment

* libparted/labels/gpt.c (_header_is_valid): Add a comment to explain
the new partition entry size limitation of UINT32_MAX/16.

14 years agobuild: update gnulib submodule to latest
Jim Meyering [Mon, 19 Oct 2009 12:41:00 +0000 (14:41 +0200)]
build: update gnulib submodule to latest

14 years agotests: use scsi_debug to test-for 4k-sector-specific bug
Jim Meyering [Fri, 16 Oct 2009 17:14:38 +0000 (19:14 +0200)]
tests: use scsi_debug to test-for 4k-sector-specific bug

* tests/t9010-big-sector.sh: New root-only test.
Requires 2.6.31, and the scsi_debug module, /sys/block/... support
and an upcoming version of libblkid.
* tests/Makefile.am (TESTS): Add t9010-big-sector.sh.
Thanks to Mike Snitzer for advice and for pointing me to similar
code he wrote to test LVM.

14 years agotests: begin the transition to coreutils' testing framework
Jim Meyering [Mon, 19 Oct 2009 10:03:20 +0000 (12:03 +0200)]
tests: begin the transition to coreutils' testing framework

The existing testing framework makes it hard to diagnose test failures,
so I'm switching to one that works better for me, from coreutils.
* tests/t-lib.sh: New file.  Mostly from coreutils/tests/test-lib.sh.
* tests/Makefile.am (TMPDIR): Update to pass more info to test scripts.
(EXTRA_DIST): Add t-lib.sh.

14 years agolinux: use libblkid to determine ->phys_sector_size
Jim Meyering [Thu, 15 Oct 2009 19:29:36 +0000 (21:29 +0200)]
linux: use libblkid to determine ->phys_sector_size

Before this change, creating a memory-mapped disk on a fedora-based
system running 2.6.31.1-56.fc12.x86_64 using this command:
modprobe scsi_debug dev_size_mb=1025 sector_size=4096
and then running "parted -s /dev/sdd mklabel gpt print"
would mistakenly print "Sector size (logical/physical): 4096B/512B"
The "512B" is what's wrong.  It should be "4096B".
* configure.ac: Test for a new-enough blkid library.
* libparted/Makefile.am (libparted_la_LIBADD): Add $(LIB_BLKID).
* libparted/arch/linux.c (get_minimum_io_size): New function.
(_device_set_sector_size): Use it.

14 years agolibparted: weaken a diagnostic
Jim Meyering [Wed, 14 Oct 2009 18:53:48 +0000 (20:53 +0200)]
libparted: weaken a diagnostic

* libparted/arch/linux.c (_kernel_reread_part_table): Give a more
accurate diagnostic.  Reported by Curtis Gedak.

14 years agogpt: verify CRC32 of partition table entry array, too
Jim Meyering [Wed, 14 Oct 2009 18:50:39 +0000 (20:50 +0200)]
gpt: verify CRC32 of partition table entry array, too

The partition table entry array's CRC was not being verified at all.
This adds an interim check.  The full-blown change required to make
this implementation conform to the EFI spec will be more invasive.
* libparted/labels/gpt.c (gpt_read): Check CRC of PTE array, too.
* tests/t0280-gpt-corrupt.sh: New test for this.
Reported by Karel Zak.

14 years agodoc: mention the "bios_grub" flag
Jim Meyering [Wed, 14 Oct 2009 10:34:56 +0000 (12:34 +0200)]
doc: mention the "bios_grub" flag

I don't like the idea of documenting this "flag setting" option,
but it's been in the code for long enough now, and in actual use,
that I feel obliged.  In the longer term, we'll probably deprecate
it and instead add an interface to set a partition's type independent
of mkpart's "type" argument.
* doc/parted.texi (set): Mention bios_grub.

14 years agotests: gpt: do not munge GPT data manually
Jim Meyering [Wed, 14 Oct 2009 09:36:47 +0000 (11:36 +0200)]
tests: gpt: do not munge GPT data manually

Otherwise, an upcoming change would cause this test to fail.
* tests/t5000-tags.sh: Do not munge GPT data manually, since that
does not update embedded CRCs, and thus renders it invalid.
Set the attribute via "set 1 bios_grub on" instead.
Also, use "name1" as the partition name, rather than the
misleading "primary".
Adjust diagnostics: the changes we make are no longer "manual."

14 years agolibparted: fix big-endian bug in gpt_get_max_supported_partition_count
Jim Meyering [Thu, 8 Oct 2009 20:03:37 +0000 (22:03 +0200)]
libparted: fix big-endian bug in gpt_get_max_supported_partition_count

* libparted/labels/gpt.c (gpt_get_max_supported_partition_count):
Convert ->SizeOfPartitionEntry from little-endian to CPU endianness
here, too.  This is along the same lines as commit d6e9b3bb, but
with the difference that this code is not reachable via the
command-line interface.

14 years agopost-release administrivia
Jim Meyering [Tue, 6 Oct 2009 18:38:19 +0000 (20:38 +0200)]
post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

14 years agoversion 2.0
Jim Meyering [Tue, 6 Oct 2009 18:29:16 +0000 (20:29 +0200)]
version 2.0

* NEWS: Record release date.

14 years agogpt: don't malfunction on big-endian systems
Jim Meyering [Tue, 6 Oct 2009 18:10:00 +0000 (20:10 +0200)]
gpt: don't malfunction on big-endian systems

Numerous GPT tests would fail when run on e.g., big-endian PPC.
* libparted/labels/gpt.c (gpt_read): Now that we use the
SizeOfPartitionEntry member, be sure to convert from GPT's
little-endian on-disk format to to CPU endianness.
This bug was introduced via commit 14cce9b2, 2009-06-10, "gpt:
fix gpt_read to read all of the partition entries correctly".
* libparted/labels/gpt.c (_header_is_valid): Also convert it here.
Add a test to ensure that the partition entry size is no larger
than the slightly arbitrary UINT32_MAX/16.
* NEWS (Bug fixes): Mention it.

14 years agobuild: update gnulib submodule to latest
Jim Meyering [Tue, 6 Oct 2009 14:56:45 +0000 (16:56 +0200)]
build: update gnulib submodule to latest

14 years agomaint: add gnulib's gnu-web-doc-update module
Jim Meyering [Tue, 6 Oct 2009 14:39:13 +0000 (16:39 +0200)]
maint: add gnulib's gnu-web-doc-update module

* bootstrap.conf (gnulib_modules): Add gnu-web-doc-update

14 years agodoc: add pointer to NEWS in README
Jim Meyering [Tue, 6 Oct 2009 14:26:00 +0000 (16:26 +0200)]
doc: add pointer to NEWS in README

* README: Mention NEWS.

14 years agodoc: update README
Jim Meyering [Tue, 6 Oct 2009 14:23:19 +0000 (16:23 +0200)]
doc: update README

* README (WARNING): Mention upcoming removal of FS-manipulation
capabilities and that we'll retain FAT/HFS resize capabilities.
Remove an obsolete URL.  Do not encourage email to individuals.
Update info-viewing instructions, provide the on-line doc URL.