OSDN Git Service

android-x86/external-parted.git
12 years agolibparted: optimize _disk_sync_part_table
Petr Uzel [Wed, 28 Sep 2011 08:45:09 +0000 (10:45 +0200)]
libparted: optimize _disk_sync_part_table

In _disk_sync_part_table, if the largest partition number (lpn) is 0,
it does not make sense to go through the loops below.  Return
immediately instead.
* libparted/arch/linux.c (_disk_sync_part_table): Return immediately
if lpn == 0.

12 years agobuild: ignore more generated files
Petr Uzel [Wed, 28 Sep 2011 08:45:03 +0000 (10:45 +0200)]
build: ignore more generated files

12 years agoparted: remove obsolete comments
Petr Uzel [Wed, 28 Sep 2011 08:45:06 +0000 (10:45 +0200)]
parted: remove obsolete comments

is_start_exact and is_end_exact were removed from the source.
* parted/parted.c (constraint_from_start_end): Remove obsolete
documentation of the function.

12 years agolibparted: check return value from ped_geometry_init
Petr Uzel [Wed, 28 Sep 2011 08:45:05 +0000 (10:45 +0200)]
libparted: check return value from ped_geometry_init

If ped_geometry_init() failed in ped_disk_set_partition_geom(),
then new_geom remains uninitialized, but still later used, which
leads to unexpected results.
* libparted/disk.c (ped_disk_set_partition_geom): Check return
value from ped_geometry_init().

12 years agotests: add test for partitionable loop devices
Petr Uzel [Thu, 29 Sep 2011 13:14:24 +0000 (15:14 +0200)]
tests: add test for partitionable loop devices

* tests/t8001-loop-blkpg.sh: New file.
* tests/Makefile.am: Add test.

12 years agolibparted: improve support for partitions on loopback devices
Petr Uzel [Thu, 29 Sep 2011 13:14:23 +0000 (15:14 +0200)]
libparted: improve support for partitions on loopback devices

Since linux-2.6.26, the kernel allows partitions on loopback devices.
Implement support for this feature in parted.
* libparted/arch/linux.c (_sysfs_int_entry_from_dev): New function.
(_loop_get_partition_range): New function.
(_device_get_partition_range): Add special handling for loop devices.
* NEWS: Mention this change.

12 years agolibparted: differentiate between plain files and loop devices
Petr Uzel [Thu, 29 Sep 2011 13:45:23 +0000 (15:45 +0200)]
libparted: differentiate between plain files and loop devices

Stop using PED_DEVICE_FILE for loopback devices;
loopback are significantly different from plain files.
* include/parted/device.h (PedDeviceType): Add PED_DEVICE_LOOP.
* libparted/arch/linux.c (_device_probe_type): Detect loopback device.
* parted/parted.c (do_print): Add "loopback" to list of transports.

12 years agodvh: factor out read_sector and use ptt_read_sector
Petr Uzel [Thu, 29 Sep 2011 09:38:30 +0000 (11:38 +0200)]
dvh: factor out read_sector and use ptt_read_sector

* libparted/labels/dvh.c (read_sector): Factor out this function.
(dvh_probe): Use ptt_read_sector instead of read_sector.
(dvh_read): Likewise.

12 years agobuild: update gnulib to latest; adapt use of _GL_ATTRIBUTE_FORMAT
Jim Meyering [Wed, 28 Sep 2011 13:19:52 +0000 (15:19 +0200)]
build: update gnulib to latest; adapt use of _GL_ATTRIBUTE_FORMAT

* libparted/arch/linux.c (_GL_ATTRIBUTE_FORMAT): Define here,
now that it's no longer defined by gnulib.

12 years agobuild: avoid new syntax-check failure
Jim Meyering [Wed, 28 Sep 2011 19:46:56 +0000 (21:46 +0200)]
build: avoid new syntax-check failure

* cfg.mk: Exempt libparted/arch/beos.c from the PATH_MAX check.
I suspect that this is ok, because parted compiles only on systems
that define PATH_MAX to something reasonable.

12 years agodoc: mention the origin of the other two bugs
Jim Meyering [Sat, 25 Jun 2011 06:52:04 +0000 (08:52 +0200)]
doc: mention the origin of the other two bugs

* NEWS: Mention that the other two bugs were introduced long ago.

12 years agotests: test for the nilfs2 bug
Jim Meyering [Wed, 28 Sep 2011 17:43:40 +0000 (19:43 +0200)]
tests: test for the nilfs2 bug

* tests/t4300-nilfs2-tiny.sh: New test.
* tests/Makefile.am (TESTS): Add it.

12 years agolibparted: fix a bug in the nilfs2 probe function
Jim Meyering [Sat, 25 Jun 2011 06:49:58 +0000 (08:49 +0200)]
libparted: fix a bug in the nilfs2 probe function

* libparted/fs/nilfs2/nilfs2.c (nilfs2_probe): Reject this partition
if we get a negative sb2 offset.  Passing a negative offset to
ped_geometry_read_alloc would evoke a failed assertion.
Bug introduced by 2010-07-09 commit d463e7de.
* NEWS: (Bug fixes): Mention it.
Reported by Daniel Fandrich in
http://thread.gmane.org/gmane.comp.gnu.parted.bugs/10466/focus=10472

12 years agogpt: don't abort for a truncated GPT-formatted device
Jim Meyering [Fri, 24 Jun 2011 11:32:33 +0000 (13:32 +0200)]
gpt: don't abort for a truncated GPT-formatted device

This fixes the problem two ways.  The first fix (via gpt_alloc)
rejects any device that is too small, but it is insufficient.
Choose a slightly larger truncated device with an otherwise intact
primary GPT header and you can still trigger the failed assertion.
To fix it in general, we make _header_is_valid detect the problem.
* libparted/labels/gpt.c (gpt_alloc): Reject a device that is so
small that there is no room for a single partition.
(_header_is_valid): Validate LastUsableLBA here, as well, so that
we now reject as invalid any GPT header that specifies a
LastUsableLBA larger than the device size.
Leave the assertion in _parse_header.
* tests/t0203-gpt-tiny-device-abort.sh: Test for this.
* tests/Makefile.am (TESTS): Add it.
* NEWS: (Bug fixes): Mention it.
Reported by Daniel Fandrich in
http://thread.gmane.org/gmane.comp.gnu.parted.bugs/10466

12 years agolibparted: avoid invalid diagnostic in interactive mode
Jim Meyering [Fri, 24 Jun 2011 13:51:57 +0000 (15:51 +0200)]
libparted: avoid invalid diagnostic in interactive mode

* libparted/arch/linux.c (linux_read): In interactive mode,
a truncated device with a preexisting GPT could evoke this:
  Error: end of file while reading Success
it should have been like this:
  Error: end of file while reading /full/name/of/device
Use %0.0s to discard the strerror argument.

12 years agotests: add test for value less than 1
Brian C. Lane [Tue, 21 Jun 2011 17:44:18 +0000 (10:44 -0700)]
tests: add test for value less than 1

* tests/t9023-value-lt-one.sh: New file.
* tests/Makefile.am (TESTS): Add it.

12 years agotests: add test for radius divide by 2 fix
Brian C. Lane [Tue, 21 Jun 2011 17:44:17 +0000 (10:44 -0700)]
tests: add test for radius divide by 2 fix

* tests/t9022-one-unit-snap.sh: New file.
* tests/Makefile.am (TESTS): Add it.

12 years agolibparted: don't allow values less than 1 (#665496)
Brian C. Lane [Tue, 21 Jun 2011 17:44:16 +0000 (10:44 -0700)]
libparted: don't allow values less than 1 (#665496)

When a value < 1 is used there is the possibility that the range can
overlap sector 0. The user should use smaller units instead. 0 is a
special case and is still allowed.

* libparted/unit.c (ped_unit_parse_custom): Throw error if a value
between 0 and 1 is used.

12 years agolibparted: fix snap radius so that it is using half (#665496)
Brian C. Lane [Tue, 21 Jun 2011 17:44:15 +0000 (10:44 -0700)]
libparted: fix snap radius so that it is using half (#665496)

The snap radius didn't match the documentation, it has been using +/-
unit size instead +/- 0.5 * unit (eg. 500KB for a MB unit). This caused
problems when specifying 1MB, 1GB, etc. as a partition start or end
resulting in partitions being created that were nowhere near the
specified size.

* libparted/unit.c (ped_unit_parse_custom): divide radius by 2
This addresses http://bugzilla.redhat.com/665496

13 years agomaint: prefer AC_PROG_LIBTOOL over slightly deprecated AM_PROG_LIBTOOL
Jim Meyering [Fri, 10 Jun 2011 10:13:02 +0000 (12:13 +0200)]
maint: prefer AC_PROG_LIBTOOL over slightly deprecated AM_PROG_LIBTOOL

* configure.ac: Use AC_PROG_LIBTOOL rather than slightly deprecated
AM_PROG_LIBTOOL.

13 years agolibparted: simplify kernel version-parsing logic
H. Peter Anvin [Tue, 7 Jun 2011 16:03:14 +0000 (18:03 +0200)]
libparted: simplify kernel version-parsing logic

* libparted/arch/linux.c: (_get_linux_version): Simplify and add
an assertion.

13 years agolibparted: accommodate two-component linux version number like 3.0
Jim Meyering [Sun, 5 Jun 2011 16:15:31 +0000 (18:15 +0200)]
libparted: accommodate two-component linux version number like 3.0

* libparted/arch/linux.c (_get_linux_version): Also accept 2-component
version numbers.
* NEWS: (Bug fixes): Mention it.
Reported by Richard W.M. Jones.

13 years agopost-release administrivia
Jim Meyering [Mon, 30 May 2011 11:48:54 +0000 (13:48 +0200)]
post-release administrivia

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

13 years agoversion 3.0
Jim Meyering [Mon, 30 May 2011 11:44:35 +0000 (13:44 +0200)]
version 3.0

* NEWS: Record release date.

13 years agomaint: placate coverity: don't ignore some return values
Jim Meyering [Mon, 30 May 2011 11:09:01 +0000 (13:09 +0200)]
maint: placate coverity: don't ignore some return values

* libparted/cs/constraint.c: Include <assert.h>.
(ped_constraint_exact): Don't ignore ped_alignment_init's return
value or that from ped_geometry_init.

13 years agoloop: avoid NULL dereference upon failure
Jim Meyering [Mon, 30 May 2011 10:49:21 +0000 (12:49 +0200)]
loop: avoid NULL dereference upon failure

* libparted/labels/loop.c (loop_partition_duplicate): Don't dereference
NULL upon failure.

13 years agoshared library version: increment major: 1.0.0
Jim Meyering [Mon, 30 May 2011 10:40:59 +0000 (12:40 +0200)]
shared library version: increment major: 1.0.0

* libparted/Makefile.am (CURRENT, REVISION): Update from 0.2.0 to 1.0.0,
due to removed interfaces.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Mon, 30 May 2011 07:06:26 +0000 (09:06 +0200)]
build: update gnulib submodule to latest

13 years agodoc: update NEWS
Jim Meyering [Fri, 27 May 2011 15:54:46 +0000 (17:54 +0200)]
doc: update NEWS

* NEWS (Changes in behavior): Describe the change.
(Bug fixes): Mention the leak fixes.

13 years agodoc: reflect removal of FS-related commands
Jim Meyering [Fri, 27 May 2011 09:48:27 +0000 (11:48 +0200)]
doc: reflect removal of FS-related commands

* README (WARNING): Say that all FS-manipulation code is now gone.
* doc/parted.texi (Command explanations): Remove descriptions of and
any examples or references to the following commands: check, cp,
mkfs, mkpartfs, move, resize.

13 years agobuild: remove configure-time options: --disable-fs, --enable-Werror
Jim Meyering [Tue, 17 May 2011 21:08:42 +0000 (23:08 +0200)]
build: remove configure-time options: --disable-fs, --enable-Werror

* configure.ac: Remove support for --enable-fs and --disable-fs.
Remove support for --enable-Werror and --disable-Werror.
* README: Remove paragraph about --disable-fs and
--enable-discovery-only.
* libparted/libparted.c: Now that --disable-fs is gone (i.e.,
ENABLE_FS would be always 1), remove its #ifdefs.

13 years agotests: make t0220 more useful when it fails
Jim Meyering [Sat, 21 May 2011 13:18:15 +0000 (15:18 +0200)]
tests: make t0220 more useful when it fails

13 years agomaint: update po/POTFILES.in
Jim Meyering [Sat, 21 May 2011 13:03:04 +0000 (15:03 +0200)]
maint: update po/POTFILES.in

* po/POTFILES.in: Remove file names, to reflect file deletions.

13 years agodoc: remove FS-related documentation and other stale bits
Jim Meyering [Tue, 17 May 2011 21:10:16 +0000 (23:10 +0200)]
doc: remove FS-related documentation and other stale bits

* doc/parted.texi: Remove FS-related documentation and other
stale bits.

13 years agolinux_swap: remove all-but-probe FS-related code
Jim Meyering [Tue, 17 May 2011 12:23:25 +0000 (14:23 +0200)]
linux_swap: remove all-but-probe FS-related code

13 years agoxfs: remove all-but-probe FS-related code
Jim Meyering [Mon, 16 May 2011 13:47:02 +0000 (15:47 +0200)]
xfs: remove all-but-probe FS-related code

13 years agojfs: remove all-but-probe FS-related code
Jim Meyering [Mon, 16 May 2011 12:35:19 +0000 (14:35 +0200)]
jfs: remove all-but-probe FS-related code

13 years agoufs: remove all-but-probe FS-related code
Jim Meyering [Mon, 16 May 2011 12:33:58 +0000 (14:33 +0200)]
ufs: remove all-but-probe FS-related code

13 years agoreiserfs: remove all-but-probe FS-related code
Jim Meyering [Mon, 16 May 2011 12:33:04 +0000 (14:33 +0200)]
reiserfs: remove all-but-probe FS-related code

13 years agohfs: remove all-but-probe FS-related code
Jim Meyering [Mon, 16 May 2011 12:21:44 +0000 (14:21 +0200)]
hfs: remove all-but-probe FS-related code

13 years agontfs: remove all-but-probe FS-related code
Jim Meyering [Mon, 16 May 2011 12:12:07 +0000 (14:12 +0200)]
ntfs: remove all-but-probe FS-related code

13 years agoamiga: build with warning and error options
Jim Meyering [Mon, 16 May 2011 11:58:10 +0000 (13:58 +0200)]
amiga: build with warning and error options

* libparted/fs/amiga/Makefile.am (AM_CFLAGS): Add $(WARN_CFLAGS)
and $(WERROR_CFLAGS).

13 years agoext2: remove all-but-probe FS-related code
Jim Meyering [Mon, 16 May 2011 10:11:23 +0000 (12:11 +0200)]
ext2: remove all-but-probe FS-related code

13 years agofat: remove all-but-probe FS-related code
Jim Meyering [Fri, 13 May 2011 19:26:17 +0000 (21:26 +0200)]
fat: remove all-but-probe FS-related code

13 years agoremove all top-level FS-op code and the clearfat program
Jim Meyering [Fri, 13 May 2011 19:02:59 +0000 (21:02 +0200)]
remove all top-level FS-op code and the clearfat program

13 years agoUI: remove all file-system-aware sub-commands
Jim Meyering [Thu, 17 Sep 2009 14:20:56 +0000 (16:20 +0200)]
UI: remove all file-system-aware sub-commands

Note that we are removing the resize command, even though parted
appears to be the only free tool that provides the ability to
resize FAT16 and FAT32 file systems.
* parted/parted.c (do_mkfs, do_cp, do_mkpartfs): Remove functions.
(do_move, do_check, do_resize): Likewise.
(_init_commands): Remove each command-definition clause.
* parted/parted.c (_partition_warn_loss): Remove now-unused function.
* include/parted/filesys.h: Remove declarations of now-removed
FS-munging functions

13 years agotests: t1100: show that adding a partition on a busy device succeeds
Jim Meyering [Fri, 27 May 2011 15:06:31 +0000 (17:06 +0200)]
tests: t1100: show that adding a partition on a busy device succeeds

* tests/t1100-busy-label.sh: Demonstrate that adding a partition
succeeds, even when another on the same device is mounted (active).

13 years agoamiga: avoid NULL-deref-on-OOM and an error-path leak
Jim Meyering [Fri, 27 May 2011 12:45:19 +0000 (14:45 +0200)]
amiga: avoid NULL-deref-on-OOM and an error-path leak

* libparted/labels/rdb.c (amiga_read): Don't dereference NULL on OOM.
Don't leak a constraint when failing to add a partition.

13 years agomac: avoid NULL-deref-on-OOM and an error-path leak
Jim Meyering [Fri, 27 May 2011 12:38:16 +0000 (14:38 +0200)]
mac: avoid NULL-deref-on-OOM and an error-path leak

* libparted/labels/mac.c (mac_read): Don't dereference NULL on OOM.
Don't leak a constraint when failing to add a partition.

13 years agosun: avoid NULL-deref-on-OOM and an error-path leak
Jim Meyering [Fri, 27 May 2011 12:35:07 +0000 (14:35 +0200)]
sun: avoid NULL-deref-on-OOM and an error-path leak

* libparted/labels/sun.c (sun_read): Don't dereference NULL on OOM.
Don't leak a constraint when failing to add a partition.

13 years agoUI: avoid leak when interactive sector selection matches default
Jim Meyering [Fri, 27 May 2011 12:31:45 +0000 (14:31 +0200)]
UI: avoid leak when interactive sector selection matches default

* parted/ui.c (command_line_get_fs_type): Don't leak an input "word".

13 years agoUI: plug a leak
Jim Meyering [Fri, 27 May 2011 12:27:41 +0000 (14:27 +0200)]
UI: plug a leak

* parted/ui.c (command_line_get_fs_type): Don't leak an FS type name
string.

13 years agobsd: avoid NULL-deref-on-OOM and an error-path leak
Jim Meyering [Fri, 27 May 2011 12:24:33 +0000 (14:24 +0200)]
bsd: avoid NULL-deref-on-OOM and an error-path leak

* libparted/labels/bsd.c (bsd_read): Don't dereference NULL on OOM.
Don't leak a constraint when failing to add a partition.

13 years agolinux: don't leak a FILE* upon /proc read failure
Jim Meyering [Fri, 27 May 2011 11:53:36 +0000 (13:53 +0200)]
linux: don't leak a FILE* upon /proc read failure

* libparted/arch/linux.c (_probe_proc_partitions): Call fclose
upon failure.

13 years agolinux: plug a file descriptor leak
Jim Meyering [Fri, 27 May 2011 11:46:40 +0000 (13:46 +0200)]
linux: plug a file descriptor leak

* libparted/arch/linux.c (read_device_sysfs_file): Don't leak a
file descriptor.

13 years agotests: t1100-busy-label: don't use mkpartfs; rework to use scsi_debug
Jim Meyering [Fri, 27 May 2011 09:56:11 +0000 (11:56 +0200)]
tests: t1100-busy-label: don't use mkpartfs; rework to use scsi_debug

* tests/t1100-busy-label.sh: Remove one last use of mkpartfs.
Use scsi_debug rather than requiring an explicitly-provided device.

13 years agomaint: correct coverity-reported "suspicious sizeof"
Jim Meyering [Tue, 24 May 2011 14:57:57 +0000 (16:57 +0200)]
maint: correct coverity-reported "suspicious sizeof"

* parted/table.c (table_add_row): Use sizeof(*VAR), rather than
erroneous sizeof(explicit_type) that just happened to be ok.

13 years agomaint: remove unreachable code
Jim Meyering [Tue, 24 May 2011 14:54:51 +0000 (16:54 +0200)]
maint: remove unreachable code

* libparted/labels/sun.c (sun_partition_new): Remove unreachable stmt.
* libparted/labels/pc98.c (pc98_partition_new): Likewise.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Fri, 27 May 2011 05:49:32 +0000 (07:49 +0200)]
build: update gnulib submodule to latest

13 years agopost-release administrivia
Jim Meyering [Wed, 18 May 2011 16:38:41 +0000 (18:38 +0200)]
post-release administrivia

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

13 years agoversion 2.4
Jim Meyering [Wed, 18 May 2011 16:33:50 +0000 (18:33 +0200)]
version 2.4

* NEWS: Record release date.

13 years agoshared library version: increment REVISION
Jim Meyering [Wed, 18 May 2011 16:03:30 +0000 (18:03 +0200)]
shared library version: increment REVISION

* libparted/Makefile.am (REVISION): Increment, since there have
been changes to the library, but no interface addition or removal.
* README-release: Mention the shared-library version update procedure.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Wed, 18 May 2011 15:08:30 +0000 (17:08 +0200)]
build: update gnulib submodule to latest

13 years agotests: avoid nasty FP-causing race condition
Jim Meyering [Wed, 18 May 2011 14:46:38 +0000 (16:46 +0200)]
tests: avoid nasty FP-causing race condition

* tests/t9040-many-partitions.sh: Remove all partitions before
exiting -- otherwise, the rmmod-prompted removal of those many
partitions would continue long after rmmod completion and the
release of the scsi_debug lock, and thus partition-device removals
provoked by this test would cause failure in the subsequent test,
e.g., when the devices for partitions 14,15,16 have just been
successfully created (verified that they exist), yet the next
step -- to create a file system on one of them -- fails or is
erroneously skipped because the device has been removed asynchronously.

13 years agotests: add double quotes around another use of $VERBOSE
Jim Meyering [Wed, 18 May 2011 11:24:28 +0000 (13:24 +0200)]
tests: add double quotes around another use of $VERBOSE

* tests/t-local.sh (scsi_debug_setup_): Quote another $VERBOSE.

13 years agobuild: list bc as a build-requirement
Jim Meyering [Wed, 18 May 2011 07:57:36 +0000 (09:57 +0200)]
build: list bc as a build-requirement

* bootstrap.conf (buildreq): Also require "bc", since it's used
in some of 'make check's tests.

13 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/t2100-mkswap.sh: Likewise.
* tests/t3000-resize-fs.sh: Remove file, now that all FS-ops are gone.
* tests/Makefile.am (TESTS): Remove them here, too.

13 years agolinux: fix diagnostic about operating on very small file or device
Jim Meyering [Mon, 16 May 2011 16:13:25 +0000 (18:13 +0200)]
linux: fix diagnostic about operating on very small file or device

* libparted/arch/linux.c (init_file): Correct diagnostic.
Parted would claim that a small-but-non-empty file has zero length.

13 years agobfs: remove unused files
Jim Meyering [Mon, 16 May 2011 11:51:23 +0000 (13:51 +0200)]
bfs: remove unused files

13 years agotests: add double quotes around a use of $VERBOSE
Jim Meyering [Fri, 13 May 2011 18:55:10 +0000 (20:55 +0200)]
tests: add double quotes around a use of $VERBOSE

* tests/t-local.sh (scsi_debug_cleanup_): Add missing double quotes.

13 years agotests: avoid new, spurious test failure
Jim Meyering [Thu, 12 May 2011 19:36:40 +0000 (21:36 +0200)]
tests: avoid new, spurious test failure

* tests/t9050-partition-table-types.sh: Use a "device size"
that is large enough to accommodate 1KiB and 4KiB sectors.
The original size, 3MiB was too small for a dvh partition
with PARTED_SECTOR_SIZE=1024.  Increase it to 30MiB.

13 years agotests: adapt t1101-busy-partition not to use mkpartfs
Jim Meyering [Tue, 10 May 2011 17:29:23 +0000 (19:29 +0200)]
tests: adapt t1101-busy-partition not to use mkpartfs

* tests/t1101-busy-partition.sh: Use mkfs.vfat instead.

13 years agotests: write all pairs of partition table types
Jim Meyering [Sat, 19 Sep 2009 06:23:40 +0000 (08:23 +0200)]
tests: write all pairs of partition table types

* tests/t9050-partition-table-types.sh: New file.
* tests/Makefile.am (TESTS): Add it.

13 years agotests: add a NEWS entry and a test to exercise today's bug fix
Jim Meyering [Mon, 9 May 2011 19:14:42 +0000 (21:14 +0200)]
tests: add a NEWS entry and a test to exercise today's bug fix

* tests/t9041-undetected-in-use-16th-partition: New file.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Describe it.

13 years agolinux: also detect "in-use" dmraid and scsi-Nth (N>=16) partitions
Phillip Susi [Tue, 10 May 2011 10:00:10 +0000 (12:00 +0200)]
linux: also detect "in-use" dmraid and scsi-Nth (N>=16) partitions

Prior to this change, Parted would fail to detect any in-use
partition on a dmraid disk, as well as any in-use partition
numbered 16 or greater on a regular scsi disk.
This was because assumptions were being made about the device node
major/minor numbers and how they relate to the partition number.
These assumptions are invalid for dmraid devices, and for normal
disks with >= 16 partitions.
* libparted/arch/linux.c (_partition_get_part_dev): Remove function.
(_partition_is_mounted): Rewrite to use _partition_is_mounted_by_path
instead of _by_dev.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Mon, 9 May 2011 19:00:35 +0000 (21:00 +0200)]
build: update gnulib submodule to latest

13 years agotests: avoid subtle shell semantics bug
Jim Meyering [Mon, 9 May 2011 20:00:57 +0000 (22:00 +0200)]
tests: avoid subtle shell semantics bug

This bug was causing some root-only tests to be mistakenly skipped.
This bash command will always exit successfully,
i.e., the "return 1" will never happen:
  bash -c 'f(){ local f=$(false)||return 1; return 0; }; f'
That's because the assignment always succeeds, and that success
is what determines the return value, not the $(...) command.
This is very counter-intuitive, sigh.
The work-around is to separate the declaration and assignment, as in
local f; f=$(...) || ...
* tests/t-local.sh (new_sdX_): Do that.
(gpt_corrupt_primary_table_): Likewise.

13 years agotests: minor fix; add/adjust comments
Jim Meyering [Tue, 10 May 2011 09:37:06 +0000 (11:37 +0200)]
tests: minor fix; add/adjust comments

* tests/t1101-busy-partition.sh: Don't ignore failed comparison.
Add a comment.

13 years agos390/dasd: avoid buffer overrun upon API mismatch diagnostic
Brian C. Lane [Thu, 21 Apr 2011 07:36:08 +0000 (09:36 +0200)]
s390/dasd: avoid buffer overrun upon API mismatch diagnostic

* libparted/labels/fdasd.c (fdasd_check_api_version): The static
buffer for the error string was too small.  Double its length.
This resolves http://bugzilla.redhat.com/693852

13 years agolinux: fix typo in comment: /path%d => /part%d
Brian C. Lane [Wed, 20 Apr 2011 11:04:20 +0000 (13:04 +0200)]
linux: fix typo in comment: /path%d => /part%d

* libparted/arch/linux.c (_device_get_part_path): Fix typo in comment.

13 years agolinux: don't free invalid pointer upon asprintf failure
Jim Meyering [Sun, 17 Apr 2011 12:25:41 +0000 (14:25 +0200)]
linux: don't free invalid pointer upon asprintf failure

* libparted/arch/linux.c (_device_get_part_path): When asprintf
fails, it leaves its first argument in an undefined state, and
hence that pointer must not be freed.  However, here, in two
places we could potentially free an invalid pointer.  Use
zasprintf; then the pointer is either NULL or allocated,
and hence always freeable.

13 years agolinux: clean up device naming code (no semantic change)
Jim Meyering [Thu, 14 Apr 2011 11:22:28 +0000 (13:22 +0200)]
linux: clean up device naming code (no semantic change)

* libparted/arch/linux.c (zasprintf): New function.
(_device_get_part_path): Clean up:
Use size_t, not "int" for strlen-returned value.
Combine mostly duplicate snprintf uses.
Use zasprintf instead of malloc+snprintf.

13 years agodon't reference before start of buffer for short device name
Jim Meyering [Sun, 17 Apr 2011 12:15:54 +0000 (14:15 +0200)]
don't reference before start of buffer for short device name

* libparted/arch/linux.c (_device_get_part_path): Avoid invalid
reference to memory before dev->path when its length is 4 or less.

13 years agomaint: s/can not/cannot/ in a comment and documentation
Jim Meyering [Thu, 14 Apr 2011 10:46:03 +0000 (12:46 +0200)]
maint: s/can not/cannot/ in a comment and documentation

Without this, a new "make syntax-check" rule would fail.
* libparted/filesys.c: s/can not/cannot/
* doc/parted-pt_BR.texi (BIOSes and Firmware): Likewise.

13 years agotests: remove now-unused Makefile rule
Jim Meyering [Sat, 9 Apr 2011 20:22:49 +0000 (22:22 +0200)]
tests: remove now-unused Makefile rule

* libparted/tests/Makefile.am (old-init.sh): Remove obsolete rule.

13 years agotests: improve t1101-busy-partition.sh
Jim Meyering [Sat, 9 Apr 2011 20:21:50 +0000 (22:21 +0200)]
tests: improve t1101-busy-partition.sh

* tests/t1101-busy-partition.sh: Fail hard upon timeout while
waiting for device to appear.

13 years agotests: make the tests in libparted/tests work properly once again
Jim Meyering [Sat, 9 Apr 2011 20:20:08 +0000 (22:20 +0200)]
tests: make the tests in libparted/tests work properly once again

Since switching to init.sh, the root-only tests did not clean up.
* libparted/tests/Makefile.am (prereq): Always create a symlink
to tests/init.sh.
* tests/init.cfg: Source $abs_top_srcdir/tests-relative names,
not $srcdir-relative names.  This way, it works also when run
from libparted/tests/.
* tests/t-local.sh: Likewise.

13 years agotests: avoid a race condition in the scsi_debug-using tests
Jim Meyering [Fri, 8 Apr 2011 16:30:40 +0000 (18:30 +0200)]
tests: avoid a race condition in the scsi_debug-using tests

* tests/t-local.sh (new_sdX_): New function.
(scsi_debug_setup_): Use new_sdX_ to find the just-created device name,
rather relying on the list of file names in /sys/block/sd* changing.
Sometimes the list would not change, which would lead to tests failing
with I/O errors when run in parallel.  Thanks to Brian Lane for the
tip that /sys/block/sd*/device/model contains "scsi_debug" if there
is a device created by our "modprobe scsi_debug" command.

13 years agomake parted "do what I say" with IEC start and end values like 5GiB
Jim Meyering [Tue, 22 Feb 2011 15:12:28 +0000 (16:12 +0100)]
make parted "do what I say" with IEC start and end values like 5GiB

In a command like this,
  parted -s -- $dev mklabel gpt mkpart P-NAME 4MB -34s
parted interprets the "4MB" as merely a suggestion for the starting
sector number.  It uses half of the MB-units value as a "radius"
about the sector containing byte 4,000,000, and it may choose some
other more appropriate sector, based on partition table or alignment
constraints within the range 3,500,000B..4,500,000B.
Before, parted handled IEC units, i.e., KiB, MiB, GiB, etc.,
with identically "helpful" sloppiness, of course honoring the
power-of-two semantics.
Now, however if you use IEC units, i.e., KiB, MiB, GiB, etc.,
the "radius" is taken to be zero, so parted uses precisely
whatever multiple of a power of two you've specified.
Hence, adjusting the example above to use MiB, rather than "MB",
  parted -s -- $dev mklabel gpt mkpart P-NAME 4MiB -34s
With this change, that is equivalent to the following:
  parted -s -- $dev mklabel gpt mkpart P-NAME 4194304B -34s
I.e., it uses the sector containing precisely that byte, and
does not perform any "extra" adjustment.
* libparted/unit.c (is_power_of_2): New function.
(ped_unit_parse_custom): Use it to avoid interpreting a large
input string as "sloppy" (i.e. large radius) when it uses IEC
binary notation like 34KiB, 3GiB and 65TiB.
* tests/t0207-IEC-binary-notation.sh: New test.
* tests/Makefile.am (TESTS): Add it.
* doc/parted.texi (unit): Describe the new behavior.
* NEWS (Changes in behavior): Mention it here, too.

13 years agomaint: stop using .x-sc_* files to list syntax-check exemptions
Jim Meyering [Sun, 20 Mar 2011 10:03:10 +0000 (11:03 +0100)]
maint: stop using .x-sc_* files to list syntax-check exemptions

Instead, use the new mechanism with which you merely use a
variable (derived from the rule name) defined in cfg.mk to an ERE
matching the exempted file names.
* gnulib: Update to latest, to get maint.mk that implements this.
* .x-sc_GPL_version: Remove file.
* .x-sc_prohibit_always-defined_macros: Likewise.
* Makefile.am (EXTRA_DIST): Remove them from here, too.
* cfg.mk: Define variables to exempt the same files.

13 years agomaint: rename a variable
Jim Meyering [Fri, 11 Mar 2011 07:22:13 +0000 (08:22 +0100)]
maint: rename a variable

* libparted/labels/gpt.c (_header_is_valid): Rename a variable,
and switch to more readable range-checking logic.

13 years agogpt: avoid division by zero
Jim Meyering [Fri, 11 Mar 2011 12:35:06 +0000 (13:35 +0100)]
gpt: avoid division by zero

* libparted/labels/gpt.c (_header_is_valid): Reject as invalid if
FirstUsableLBA < 3.
(gpt_get_max_supported_partition_count): Ensure that we don't divide
by zero: verify that the GPT header is valid before dividing by its
"size of partition entry".  Under normal circumstances, the on-disk
PE size field is reasonable because we have just written it.  However,
there are two ways it can end up zero: we lose the race when some other
process pokes a 4-byte 0 into just the right location between when
we write it and when we re-read the value we're about to divide by.
Then there's the case that I encountered: using an old USB (8MB) key,
mklabel gpt failed due to division by zero.  The device reported no
failure when writing the initial header, yet when reading back that
very same sector (also successful), parted got all 0 bytes.
* NEWS (Bug fixes): Mention it.

13 years agobuild: enable compilation warnings also for new nilfs2 subdir
Jim Meyering [Mon, 7 Mar 2011 14:46:42 +0000 (15:46 +0100)]
build: enable compilation warnings also for new nilfs2 subdir

* libparted/fs/nilfs2/Makefile.am (AM_CFLAGS): Define.

13 years agonilfs2: remove unused nilfs2_clobber function
Jim Meyering [Wed, 16 Mar 2011 17:11:53 +0000 (18:11 +0100)]
nilfs2: remove unused nilfs2_clobber function

* libparted/fs/nilfs2/nilfs2.c (nilfs2_clobber): Remove unused
function.
(nilfs2_ops) [clobber]: Always set to NULL.

13 years agomaint: avoid shadowing warning
Jim Meyering [Mon, 7 Mar 2011 14:44:50 +0000 (15:44 +0100)]
maint: avoid shadowing warning

* parted/parted.c (do_mkpart): Rename inner added_ok to add_ok.

13 years agobuild: don't let parted_CFLAGS override our AM_CFLAGS setting
Jim Meyering [Mon, 7 Mar 2011 14:42:57 +0000 (15:42 +0100)]
build: don't let parted_CFLAGS override our AM_CFLAGS setting

* parted/Makefile.am (parted_CFLAGS): Remove unused (and interfering)
definition.

13 years agomaint: avoid new compiler warnings
Jim Meyering [Wed, 16 Mar 2011 17:56:06 +0000 (18:56 +0100)]
maint: avoid new compiler warnings

* parted/parted.c (do_print): Remove now-unused "error" label.
(_print_disk_info): Use one more "const" attribute, to avoid
compiler warnings.

13 years agotests: do not fail if some utilities are missing
Petr Uzel [Fri, 11 Mar 2011 12:26:43 +0000 (13:26 +0100)]
tests: do not fail if some utilities are missing

* tests/t1700-probe-fs.sh: Skip the test if mkfs.ext3 or tune2fs
is missing or is not in $PATH.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
13 years agotests: test 'parted print' with empty disk
Petr Uzel [Fri, 11 Mar 2011 12:50:01 +0000 (13:50 +0100)]
tests: test 'parted print' with empty disk

* tests/t0101-print-empty.sh: New test.
* tests/Makefile.am: Add it.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
13 years agoparted: rework 'parted print' so that it works with empty disk
Petr Uzel [Fri, 11 Mar 2011 12:50:00 +0000 (13:50 +0100)]
parted: rework 'parted print' so that it works with empty disk

'parted $dev print' on a device without a partition table used to fail
with an 'unrecognised disk label' error, without printing the following:
disk model, transport, size, sector size, BIOS geometry
all of which are available, and do not dependent on the partition table.

With this patch, parted prints all of this information (BIOS geometry
only if 'unit cyl' is specified) and reports success even if the disk
does not have a valid partition table.

As a side efect, 'parted $dev print devices/all/list' now prints
information about all the devices, even if $dev does not have a
partition table.

* parted/parted.c (_print_disk_info): New function.
(do_print): Do not immediately fail if the partition table is not
recognized, but print disk information and report success instead.
* NEWS (Changes in behavior): Mention it.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>