OSDN Git Service
Hans de Goede [Thu, 27 Aug 2009 18:16:09 +0000 (20:16 +0200)]
parted: avoid unnecessary open/close on commit, and thus udev activity
* libparted/disk.c (ped_disk_commit): Open/close the underlying file
descriptor in this function, so that callees, ped_disk_commit_to_dev
and ped_disk_commit_to_os do not each perform open/close syscalls.
This saves an open/close pair, and thus avoids unneeded udev
activity on Linux.
Before this change, when calling commit() on a ped_disk, the
following would happen:
open /dev/sda
write partition table
close /dev/sda
open /dev/sda
ioctl (BLKRRPART)
close /dev/sda
This is rather inefficient, and causes 2 udev change events to be fired
for /dev/sda (+ the change events from the BLKRRPART), causing all kind
of scanning (blkid & friends) twice.
This patch fixes things to only open the device once.
Petr Uzel [Wed, 26 Aug 2009 10:29:46 +0000 (12:29 +0200)]
dos: adjust variable declarations
* libparted/labels/dos.c (write_ext_table): Move declaration of S down
to just before its first use.
Fix alignment of lba_offset declaration.
Petr Uzel [Wed, 26 Aug 2009 10:29:26 +0000 (12:29 +0200)]
dos: factor out and define DOS_N_PRI_PARTITIONS
* dos.c (DOS_N_PRI_PARTITIONS): Define.
Petr Uzel [Wed, 26 Aug 2009 10:28:41 +0000 (12:28 +0200)]
dos: use sizeof(variable) instead of sizeof(type)
* libparted/labels/dos.c (write_ext_table): Use sizeof(variable)
instead of sizeof(type)
(write_empty_table, msdos_write): Likewise.
Petr Uzel [Wed, 26 Aug 2009 13:10:49 +0000 (15:10 +0200)]
tests: t0202-gpt-pmbr.sh: various fixes
* tests/t0202-gpt-pmbr.sh: use $bootcode_size variable instead
of plain 446. Do not use /dev/urandom since it might not exist.
Petr Uzel [Wed, 26 Aug 2009 13:10:31 +0000 (15:10 +0200)]
tests: t2300-dos-label-extended-bootcode.sh: various fixes
* tests/t2300-dos-label-extended-bootcode.sh:
- fix typo where only first 400B of fake bootcode was installed
- use bootcode_size variable and increase its value from 440 to 446
- do not use /dev/urandom since it might not exist
Jim Meyering [Sat, 22 Aug 2009 13:58:34 +0000 (15:58 +0200)]
build: ignore more generated files
* .gitignore: Ignore a few more build artifacts.
Jim Meyering [Sat, 22 Aug 2009 13:52:14 +0000 (15:52 +0200)]
tests: don't use "echo -n"
* tests/t7000-scripting.sh: Use printf, not "echo -n", for portability.
Petr Uzel [Thu, 20 Aug 2009 13:27:30 +0000 (15:27 +0200)]
test for the bootcode-in-extended-partition fix
* tests/t2300-dos-label-extended-bootcode.sh: New file.
* tests/Makefile.am (TESTS): Add t2300-dos-label-extended-bootcode.sh.
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Petr Uzel [Thu, 20 Aug 2009 13:27:09 +0000 (15:27 +0200)]
do not discard bootcode from extended partition
* libparted/labels/dos.c (write_ext_table): Do not discard
bootcode from extended partition on msdos label when some of
the logical partitions are changed
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Joel Granados Moreno [Tue, 18 Aug 2009 16:23:35 +0000 (18:23 +0200)]
Remove unneeded test.
This test made sure that "md" was ignored when doing partition specific
actions. We have added code that allows this scan once more, therefore
the test is no longer needed.
* tests/t6001-dm-ignoremd.sh: Remove file.
* tests/Makefile.am: Remove the test file from the list of tests.
Joel Granados Moreno [Tue, 18 Aug 2009 15:21:09 +0000 (17:21 +0200)]
Compensate for different behavior in t7000 test.
When the t7000 test was first engineered the "n" did not appear in the
output when testing mkpart & mkpartfs. ATM, for an unknown reason,
the "n" is being echoed in the resulting string causing test failure
when compared with the errI string. This patch attempts to make both
behaviors (with and without the echoed "n") pass the test.
* tests/t7000-scripting.sh: Make sure we don't have an " n" at the end
of the output string.
Gilles Espinasse [Tue, 18 Aug 2009 08:24:07 +0000 (10:24 +0200)]
Fix 2 typos.
* libparted/labels/fdasd.c (fdasd_enqueue_new_partition): Fix typo in
comment.
* parted/parted.c (_init_commands): Fix typo in message.
Jim Meyering [Tue, 18 Aug 2009 20:05:34 +0000 (22:05 +0200)]
build: update dist-check rules
* dist-check.mk: Merge from coreutils.
Jim Meyering [Tue, 18 Aug 2009 19:24:53 +0000 (21:24 +0200)]
build: ignore new -Wjump-misses-init warnings
* configure.ac: Ignore warnings from gcc's new -Wjump-misses-init.
Jim Meyering [Tue, 18 Aug 2009 18:50:03 +0000 (20:50 +0200)]
build: update from gnulib
* gnulib: Update submodule to latest.
* bootstrap.conf (gnulib_modules): Add update-copyright
* cfg.mk (update-copyright-env): Define.
Otavio Salvador [Wed, 12 Aug 2009 13:24:42 +0000 (10:24 -0300)]
label/dasd: add missing prototype for dasd_get_max_supported_partition_count
Colin Watson [Fri, 24 Jul 2009 17:25:22 +0000 (18:25 +0100)]
Use fsync rather than O_DIRECT
O_DIRECT doesn't work on all filesystems (e.g. tmpfs), and fsync does
just as good a job to ensure that buffers are flushed.
Based on
http://lists.alioth.debian.org/pipermail/parted-devel/2008-August/002392.html
by Olaf Hering, but with added fsync/close error checking.
Joel Granados Moreno [Fri, 31 Jul 2009 11:50:10 +0000 (13:50 +0200)]
Update the NEWS has.
* cfg.mk (old_NEWS_hash): Update the NEWS hash.
Joel Granados Moreno [Thu, 30 Jul 2009 16:07:53 +0000 (18:07 +0200)]
Rescue the news file from the stable-1.8.x branch
* NEWS: Add all the contents from the NEWS file from the stable-1.8.x
branch. Did some indentation and
addeded some "**" where needed.
Joel Granados Moreno [Fri, 24 Jul 2009 12:37:13 +0000 (14:37 +0200)]
Explicitly handle the signing key.
If we are sure that we have the key, we are able to use it in any
subroutine (like make major).
* build-aux/parted-release (_find_signingkey): New function.
(_do_release): Use the key_id to sign the tag and to execute `make
major`.
Joel Granados Moreno [Mon, 27 Jul 2009 09:12:30 +0000 (11:12 +0200)]
Minor corrections to the release README.
* README-release: Change "$v" to "$VERSION", its more explicit. Include
a reminder to add the definition of parted to the release mail.
Colin Watson [Fri, 24 Jul 2009 11:43:42 +0000 (12:43 +0100)]
linux: recognize md devices again, but know they can't be partitioned
* libparted/arch/linux.c (_skip_entry): Don't skip "md" devices.
(_has_partitions): New function; "loop" labels can't be partitioned.
(_blkpg_add_partition, _blkpg_remove_partition, _dm_add_partition,
_have_blkpg): Don't attempt to apply partition table changes to
unpartitionable devices.
Jim Meyering [Fri, 10 Jul 2009 21:02:36 +0000 (23:02 +0200)]
dos: plug just-introduced leaks on error path
* libparted/labels/dos.c (write_ext_table): Also free new buffer
on error paths.
Jim Meyering [Fri, 10 Jul 2009 20:54:54 +0000 (22:54 +0200)]
dos: don't write sector-size (>512) bytes from a 512-byte buffer
* libparted/labels/dos.c (write_ext_table): Fix this error reported
by valgrind, by allocating/using a sector-sized buffer, rather than
using a 512-byte buffer on the stack.
Syscall param write(buf) points to uninitialised byte(s)
at 0x33E12D13A0: __write_nocancel (in /lib64/libc-2.10.1.so)
by 0x432B48: linux_write (linux.c:1782)
by 0x42648C: write_ext_table (dos.c:1063)
by 0x426471: write_ext_table (dos.c:1059)
by 0x4268C5: msdos_write (dos.c:1094)
by 0x40E9C4: ped_disk_commit_to_dev (disk.c:479)
by 0x40EA08: ped_disk_commit (disk.c:502)
by 0x408AE0: test_duplicate (disk.c:79)
by 0x4C249ED: srunner_run_all (in /usr/lib64/libcheck.so.0.0.0)
by 0x4089AD: main (disk.c:121)
Address 0x4e48e00 is 512 bytes inside a block of size 1,024 alloc'd
at 0x4A05260: memalign (vg_replace_malloc.c:460)
by 0x4A05317: posix_memalign (vg_replace_malloc.c:569)
by 0x432B06: linux_write (linux.c:1777)
by 0x42648C: write_ext_table (dos.c:1063)
by 0x426471: write_ext_table (dos.c:1059)
by 0x4268C5: msdos_write (dos.c:1094)
by 0x40E9C4: ped_disk_commit_to_dev (disk.c:479)
by 0x40EA08: ped_disk_commit (disk.c:502)
by 0x408AE0: test_duplicate (disk.c:79)
by 0x4C249ED: srunner_run_all (in /usr/lib64/libcheck.so.0.0.0)
by 0x4089AD: main (disk.c:121)
Jim Meyering [Fri, 26 Jun 2009 19:24:14 +0000 (21:24 +0200)]
sun: don't read freed memory
* libparted/labels/sun.c (_use_old_info): Rename from
_probe_and_use_old_info. Don't read sector 0 here.
(sun_write): Read it here instead.
Write not a constant-sized 512-byte buffer, but the sector-sized
buffer just read above.
Jim Meyering [Wed, 17 Jun 2009 11:42:32 +0000 (13:42 +0200)]
gpt: adjust _write_pmbr[*] to work with >512-byte sectors
* libparted/labels/gpt.c (_write_pmbr): Adjust, to work with
larger-than 512-byte sectors.
[*] commit
14a15891 "gpt: preserve first 446 bytes of the PMBR"
Jim Meyering [Wed, 17 Jun 2009 11:03:34 +0000 (13:03 +0200)]
tests: skip t2100-mkswap.sh for >512-byte SS, now that it fails
* tests/t2100-mkswap.sh: Use require_512_byte_sector_size_
Jim Meyering [Wed, 17 Jun 2009 09:21:17 +0000 (11:21 +0200)]
build: arrange for "make check" to run the tests four times,
each using a different simulated partition size. First with an
explicit size of 1024, then 2048, then 4096, and finally with
the default of 512.
* Makefile.am (check-other-sector_sizes): New rule.
(check): Depend on it.
* README-big-sector: Update accordingly.
Suggestion from Otavio Salvador.
Jim Meyering [Wed, 17 Jun 2009 08:12:57 +0000 (10:12 +0200)]
build: enable many warnings
* configure.ac: New configure-time option: --enable-gcc-warnings.
* bootstrap.conf: Use gnulib modules: warnings manywarnings.
* debug/Makefile.am: Define AM_CFLAGS.
* libparted/Makefile.am: Likewise.
* libparted/tests/Makefile.am: Likewise.
* parted/Makefile.am: Likewise.
* partprobe/Makefile.am: Likewise.
* debug/clearfat/Makefile.am: Likewise.
* libparted/labels/Makefile.am: Likewise.
Jim Meyering [Wed, 17 Jun 2009 08:21:31 +0000 (10:21 +0200)]
build: avoid new warnings
* debug/clearfat/clearfat.c (usage): Declare static.
* partprobe/partprobe.c (usage): Likewise.
* libparted/cs/natmath.c (abs_mod, extended_euclid): Declare static.
* libparted/timer.c (PED_TIMER_START_DELAY): Remove unused definition.
* libparted/unit.c (ped_unit_format_custom_byte): Remove an unnecessary
cast-to-double.
Jim Meyering [Tue, 16 Jun 2009 14:02:15 +0000 (16:02 +0200)]
sun: remove obsolete FIXME comments
* libparted/labels/sun.c:
Jim Meyering [Tue, 16 Jun 2009 13:25:52 +0000 (15:25 +0200)]
ui: avoid infloop in testing
These commands would provoke an infinite loop:
ss=4096 N=100; dd if=/dev/zero of=testfile bs=${ss}c count=$N
./parted ---pretend-input-tty testfile -- mklabel gpt mkpart \
primary ext3 1s -1s < /dev/null
* parted/ui.c (command_line_prompt_words): Treat EOF like ^C.
Jim Meyering [Tue, 16 Jun 2009 13:23:14 +0000 (15:23 +0200)]
tests: skip FS-related part when sector size is larger than 512
* tests/t7000-scripting.sh: Adapt to work with large sector sizes.
Jim Meyering [Tue, 16 Jun 2009 10:26:29 +0000 (12:26 +0200)]
tests: handle SS>512, clean up, add consistency check
* tests/t5000-tags.sh: Don't fail for sector size of 4096 and greater.
Jim Meyering [Tue, 16 Jun 2009 09:50:42 +0000 (11:50 +0200)]
tests: t4000-sun-raid-type: accommodate arbitrary sector sizes
* tests/t4000-sun-raid-type.sh: Make the expected output depend
on the sector size.
Jim Meyering [Tue, 16 Jun 2009 09:33:17 +0000 (11:33 +0200)]
tests: reenable sun label tests
* libparted/tests/common.c (_implemented_disk_label): Remove "sun".
Jim Meyering [Mon, 15 Jun 2009 21:20:39 +0000 (23:20 +0200)]
disk.c: add assertions
Jim Meyering [Fri, 12 Jun 2009 19:40:02 +0000 (21:40 +0200)]
sun: don't segfault for sector sizes larger than 512
* libparted/labels/sun.c Include "pt-tools.h" and "verify.h".
(sun_verify_checksum): Make parameter "const".
(sun_probe): Don't always return 0, now that this code works.
(sun_probe): Rewrite to work with sector sizes larger than 512.
(_probe_and_use_old_info): Likewise.
(sun_clobber): Likewise.
(sun_read): Likewise.
(_check_geometry_sanity) Don't accept all-zeros c,h,s.
Add assertions and uses of verify.
(sun_alloc): Remove bogus cast.
Don't modify through const pointer.
Jim Meyering [Fri, 12 Jun 2009 10:32:53 +0000 (12:32 +0200)]
msdos: clean-up (no semantic change)
* libparted/labels/dos.c (msdos_write): Remove useless initialization.
(msdos_clobber): Remove unnecessary cast.
Jim Meyering [Fri, 12 Jun 2009 09:34:50 +0000 (11:34 +0200)]
msdos: do not scale counts by sector_size/512
* libparted/labels/dos.c (chs_to_sector, linear_start):
(linear_end, fill_raw_part, fill_ext_raw_part_geom):
(sector_to_chs): Scaling (e.g., a starting sector number) by
sector_size/512 loses information when sector_size > 512. Don't do it.
Jim Meyering [Fri, 12 Jun 2009 08:20:49 +0000 (10:20 +0200)]
parted-ui: when failing, include more information in an unusual case
* libparted/cs/geom.c (ped_geometry_set): Include starting sector
number and length in diagnostic. To trigger this, run the following:
dev=f; rm -f $dev; dd if=/dev/null of=$dev bs=1 seek=100k
PARTED_SECTOR_SIZE=2048 ./parted -s $dev mklabel msdos
PARTED_SECTOR_SIZE=2048 ./parted -s $dev mkpart primary 1s 40s
PARTED_SECTOR_SIZE=2048 ./parted -s $dev p
Error: Can't have the end before the start! (start sector=128 \
length=-78)
Jim Meyering [Fri, 12 Jun 2009 08:09:47 +0000 (10:09 +0200)]
tests: t2200-dos-label-recog.sh: adapt to work with larger sector size
Using a 100K image is inadequate for larger sector sizes, since it
triggers a bug whereby the device length (in sectors) smaller than
the cylinder_size: from dos.c:
if (!ped_geometry_init (&start_geom, dev, cylinder_size,
dev->length - cylinder_size))
That would pass a negative value for the 3rd argument.
* tests/t2200-dos-label-recog.sh: Use an image of size 10MB, not 100K.
Jim Meyering [Fri, 12 Jun 2009 07:58:57 +0000 (09:58 +0200)]
tests: add infrastructure: when skipping a test, say why
* tests/Makefile.am (TESTS_ENVIRONMENT): Arrange for the first line
of 'skip_test_'s argument to be printed on stderr.
* tests/test-lib.sh (skip_test_): New function.
Jim Meyering [Fri, 12 Jun 2009 07:55:10 +0000 (09:55 +0200)]
tests: skip FS-related tests when sector size != 512
* tests/test-lib.sh (require_512_byte_sector_size_): New function.
* tests/t1000-mkpartfs.sh: Skip when sector size != 512.
* tests/t3100-resize-ext2-partion.sh: Likewise.
* tests/t3000-constraints.sh: Likewise.
* tests/t2000-mkfs.sh: Likewise.
* tests/t1700-ext-probe.sh: Likewise.
* tests/t1500-small-ext2.sh: Likewise.
Jim Meyering [Fri, 12 Jun 2009 07:30:43 +0000 (09:30 +0200)]
tests: t0100-print.sh: adjust to work with arbitrary sector size
* tests/t0100-print.sh: Parameterize on $sector_size_.
Remove sed xform that hard-coded for 2048.
Jim Meyering [Fri, 12 Jun 2009 06:38:23 +0000 (08:38 +0200)]
tests: revamp t4100-starting-sector.sh to work with other sector sizes
* tests/t4100-msdos-starting-sector.sh: Adjust to work with arbitrary
PARTED_SECTOR_SIZE.
Jim Meyering [Thu, 11 Jun 2009 13:21:38 +0000 (15:21 +0200)]
tests: correct t2200-dos-label-recog.sh
* tests/t2200-dos-label-recog.sh: Concatenate output from successive
partition-creation commands, rather than letting output from the
second one clobber that of the first.
Joel Granados Moreno [Mon, 18 May 2009 15:37:44 +0000 (17:37 +0200)]
put the maximum sector checks in pt-tools.c
* libparted/labels/dos.c (msdos_partition_check): Use new
ptt_partition_max_start_len function to test for len and start maxs.
* libparted/labels/dvh.c (msdos_partition_check): Likewise.
* libparted/labels/pt-tools.c (ptt_partition_max_start_len):
New function.
* libparted/labels/pt-tools.h: Likewise.
* po/POTFILES.in: Add pt-tools.c to the translation list.
Joel Granados Moreno [Mon, 18 May 2009 15:37:43 +0000 (17:37 +0200)]
put partition-table-specific logic in the corresponding files
* include/parted/disk.h (struct _PedDiskOps) [partition_check]:
New member function.
* libparted/disk.c (_check_partition): Replace open-coded tests with
use of the new ->partition_check().
(_partition_max_start, _partition_max_len): Remove functions.
* libparted/labels/dvh.c (dvh_partition_check): New function.
* libparted/labels/dos.c (dos_partition_check): Likewise.
* libparted/labels/aix.c (aix_partition_check): New stub.
* libparted/labels/bsd.c (bsd_partition_check): Likewise.
* libparted/labels/gpt.c (gpt_partition_check): Likewise.
* libparted/labels/loop.c (loop_partition_check): Likewise.
* libparted/labels/mac.c (mac_partition_check): Likewise.
* libparted/labels/pc98.c (pc98_partition_check): Likewise.
* libparted/labels/rdb.c (rdb_partition_check): Likewise.
* libparted/labels/sun.c (sun_partition_check): Likewise.
Jim Meyering [Sat, 21 Mar 2009 17:45:13 +0000 (18:45 +0100)]
* .gitignore: Ignore more.
Jim Meyering [Sat, 21 Mar 2009 17:44:48 +0000 (18:44 +0100)]
tests: clean up partition-table-testing code
* libparted/tests/common.c (_implemented_disk_label): Record here
that sun and pc98 are not yet implemented...
* libparted/tests/label.c: ...rather than in 4 places in this file.
Jim Meyering [Sat, 21 Mar 2009 17:38:17 +0000 (18:38 +0100)]
tests: improve coverage in label tests
* libparted/tests/label.c (create_disk): Increase image size from
20MB to 80MB, so that tests with PARTED_SECTOR_SIZE=8192 don't
fail right away.
(START_TEST): Don't skip the "loop" type. It works now.
Jim Meyering [Mon, 16 Mar 2009 16:47:04 +0000 (17:47 +0100)]
tests: make t8000-loop.sh stop immediately upon failiure
* tests/t8000-loop.sh (immediate): ... to avoid cascading.
Jim Meyering [Thu, 12 Mar 2009 18:58:34 +0000 (19:58 +0100)]
tests: fix the final test failure on RHEL 5.3
* tests/t1700-ext-probe.sh (dev): Use mkfs.$type, not mkfs -t $type.
The latter doesn't work on RHEL5: a file system created with
"mkfs -F -t ext3" appears to be created as ext2.
Jim Meyering [Wed, 11 Mar 2009 19:40:20 +0000 (20:40 +0100)]
tests: skip xfs-requiring tests when mkfs.xfs is not installed
* tests/test-lib.sh (require_xfs_): New function.
* tests/t4100-dvh-partition-limits.sh: Use it.
* tests/t4100-msdos-partition-limits.sh: Likewise.
Jim Meyering [Wed, 11 Mar 2009 18:38:35 +0000 (19:38 +0100)]
tests: skip t7000-scripting.sh if configure without readline
Otherwise, that test would fail due to slight differences in output.
* tests/Makefile.am (TESTS_ENVIRONMENT): Define CONFIG_HEADER.
* tests/t7000-scripting.sh: Skip if configured without readline.
Jim Meyering [Wed, 11 Mar 2009 17:36:04 +0000 (18:36 +0100)]
tests: don't infloop for manual test invocation with unrecognized option
* tests/test-lib.sh: Diagnose an invalid option.
Jim Meyering [Wed, 11 Mar 2009 16:45:27 +0000 (17:45 +0100)]
tests: add one to exercise the dos/gpt seg-faulting bug
* tests/t0300-dos-on-gpt.sh: Test for this bug.
* tests/Makefile.am (TESTS): Add it to the list.
Jim Meyering [Wed, 11 Mar 2009 15:06:53 +0000 (16:06 +0100)]
gpt_clobber: avoid segfault when 512 < sector_size
* libparted/labels/gpt.c (gpt_clobber): Rewrite not to use a
fixed-size buffer assuming a 512-byte sector.
Eliminate entirely a buffer that is allocated (not long enough)
and zeroed-out solely so to help zero out a few sectors.
Instead, use the new ptt_clear_sectors function.
Jim Meyering [Tue, 10 Mar 2009 21:58:20 +0000 (22:58 +0100)]
ptt_clear_sectors: new function
* libparted/labels/pt-tools.c (ptt_clear_sectors): New function.
* libparted/labels/pt-tools.h: Declare.
Jim Meyering [Wed, 11 Mar 2009 11:46:55 +0000 (12:46 +0100)]
linux_write: use sector_size, not hard-coded 512
* libparted/arch/linux.c (linux_write): Use sector_size,
not a hard-coded 512, to find start of last sector.
Jim Meyering [Thu, 8 Jan 2009 12:05:23 +0000 (13:05 +0100)]
parted/ui.c: Include <config.h> before everything else
Jim Meyering [Mon, 28 Jul 2008 16:20:38 +0000 (18:20 +0200)]
* README-big-sector: New file.
Jim Meyering [Mon, 28 Jul 2008 12:34:46 +0000 (14:34 +0200)]
reenabling probe-related code exposed problems with amiga and bsd
* libparted/tests/common.c (_implemented_disk_label): Pretend they're
not implemented, so we skip them, temporarily.
Jim Meyering [Sat, 26 Jul 2008 19:16:57 +0000 (21:16 +0200)]
tests: re-enable "mac" tests
* libparted/tests/label.c: Remove "mac" exclusion.
Jim Meyering [Sat, 26 Jul 2008 19:15:05 +0000 (21:15 +0200)]
mac clone: avoid failed assertion for sector size > 512
* libparted/labels/mac.c (mac_duplicate): Do not assume that
the first sector of the partition-map partition is "1".
Running this: cd libparted/tests &&
PARTED_SECTOR_SIZE=1024 CK_FORK=no valgrind ./label
would result in a failed assertion:
ped_disk_remove_partition (...) at disk.c:1897
1897 PED_ASSERT (part->part_list == NULL, goto error);
At first glance, it looked like the free(part) in
mac_partition_destroy was the culprit. And removing that free
does indeed avoid the failed assertion. However, not only does
the name "mac_partition_destroy" imply/require the "free", but
all other *_partition_destroy functions free their PART parameter,
so removing this free statement cannot be the solution.
Another possibility is that mac_duplicate's use of
ped_disk_remove_partition is in error. Removing it appears
to solve the problem, but I don't know why that code is removing
the partition-map partition manually, so can't safely remove
such a thing.
The real problem is that with >512-byte sectors, the "1" in this
code from mac_duplicate is wrong:
partition_map = ped_disk_get_partition_by_sector (new_disk, 1);
PED_ASSERT (partition_map != NULL, return 0);
ped_disk_remove_partition (new_disk, partition_map);
E.g., with 1024-byte sectors, the desired partition-map
partition starts at sector 2, so the above gets the tiny
metadata partition in the gap. Calling ped_disk_remove_partition
to remove a metadata partition provokes some nasty corruption.
The desired first-sector number is old_mac_data->ghost_size, not "1".
Jim Meyering [Wed, 23 Jul 2008 16:54:23 +0000 (18:54 +0200)]
* libparted/labels/mac.c (mac_duplicate): Remove dead code.
Jim Meyering [Wed, 23 Jul 2008 16:05:50 +0000 (18:05 +0200)]
mac partitions pass all label+disk tests @1024 & @2048 sector size
* libparted/labels/mac.c (mac_read): Allow for variable sector size.
(_pad_raw_part): Likewise.
(get_pme): New convenience function, adapted to work for
variable sector size and factored out of 4 functions:
(_generate_raw_part): ...here,
(_generate_raw_freespace_part): ...here,
(_generate_empty_part): ...here,
(_get_first_empty_part_entry): ...and here.
Jim Meyering [Mon, 21 Jul 2008 20:15:02 +0000 (22:15 +0200)]
mac.c (_disk_analyse_ghost_size): allow >512-byte sector size
* libparted/labels/mac.c (_disk_analyse_ghost_size):
Jim Meyering [Mon, 21 Jul 2008 14:27:52 +0000 (16:27 +0200)]
mac.c: remove dead code
* libparted/labels/mac.c (mac_partition_new): Remove dead code.
Return "NULL", not "0".
Jim Meyering [Mon, 21 Jul 2008 13:36:18 +0000 (15:36 +0200)]
make "mac" partition table support pass the 512-byte ./label tests
* libparted/labels/mac.c (mac_probe, mac_clobber): FIX!
Jim Meyering [Tue, 15 Jul 2008 12:47:22 +0000 (14:47 +0200)]
factor out the read_sector function
* libparted/labels/pt-tools.c (ptt_read_sector): New function.
Factored out of...
* libparted/labels/aix.c (aix_probe, aix_clobber, read_sector):
* libparted/labels/bsd.c (bsd_probe, bsd_clobber, bsd_read)
(_probe_and_add_boot_code, read_sector):
* libparted/labels/dos.c (_, msdos_probe, msdos_clobber)
(read_table, msdos_write, msdos_disk_type, read_sector):
* libparted/labels/gpt.c (gpt_probe, gpt_disk_type, read_sector):
* libparted/labels/loop.c (loop_probe, loop_read, loop_disk_type)
(read_sector):
* libparted/labels/mac.c (_, mac_probe, mac_read)
(write_block_zero, mac_disk_type, read_sector):
* libparted/labels/pt-tools.h: Declare.
Jim Meyering [Tue, 15 Jul 2008 10:51:25 +0000 (12:51 +0200)]
fix >512-byte sector label/disk-test failure
* libparted/tests/disk.c: Include xstrtol.h.
(get_sector_size): New function: get sector size from the environment.
(create_disk): Use the new function to calculate a usable size,
rather than hard-coding the 512-byte-sector-specific size of 20MB.
* libparted/tests/common.c (_create_disk): Change meaning (and name)
of parameter to be size in bytes, not MiB.
Adjust callers.
* po/POTFILES.in: Add lib/xstrtol-error.c.
Jim Meyering [Mon, 14 Jul 2008 12:07:58 +0000 (14:07 +0200)]
linux.c: also set phys_sector_size. Must be the same.
Jim Meyering [Mon, 14 Jul 2008 12:01:13 +0000 (14:01 +0200)]
tests: Phew! finally make t5000-tags.sh work with >512-byte sectors
* tests/t5000-tags.sh: Many adjustments, along lines of t0200-gpt.
Also, be explicit: bios_boot_magic goes in 2nd *sector*.
Jim Meyering [Fri, 11 Jul 2008 21:41:55 +0000 (23:41 +0200)]
Don't hard-code 512 for sector-size.
We'd get the wrong value for dev->length.
* libparted/arch/linux.c (init_file): In computing dev->length,
divide by dev->sector_size (not 512) to compute number of sectors.
Define dev->sector_size earlier.
Jim Meyering [Fri, 11 Jul 2008 19:42:58 +0000 (21:42 +0200)]
test basic GPT functionality earlier
* tests/t0250-gpt.sh: New file.
* tests/Makefile.am (TESTS): Add it.
Jim Meyering [Fri, 11 Jul 2008 19:30:05 +0000 (21:30 +0200)]
tests: avoid test output mismatch for >512-byte sectors
* tests/test-lib.sh (normalize_part_diag_): New function.
(sector_size_): New variable.
* tests/t7000-scripting.sh: Use them.
Jim Meyering [Fri, 11 Jul 2008 19:29:42 +0000 (21:29 +0200)]
tests: make t5000-tags.sh less sensitive to >512-byte sector size
* tests/t5000-tags.sh: Use -m option and "unit s".
FIXME: But still fails when invoked via
PARTED_SECTOR_SIZE=2048 ./t5000-tags.sh --verbose --debug
Jim Meyering [Fri, 11 Jul 2008 18:20:34 +0000 (20:20 +0200)]
t7000-scripting.sh: adapt to work with >512-byte sectors
Jim Meyering [Fri, 11 Jul 2008 14:48:56 +0000 (16:48 +0200)]
label.c tests: don't skip dvh, now that it works; clean up
Jim Meyering [Fri, 11 Jul 2008 14:44:02 +0000 (16:44 +0200)]
dvh: probe, read, clobber, write: adapt for >512-byte sectors
Jim Meyering [Fri, 11 Jul 2008 14:36:11 +0000 (16:36 +0200)]
bsd.c: use pt-tools
* libparted/labels/bsd.c: Include pt-tools.h.
(bsd_write): Use ptt_write_sector.
Jim Meyering [Fri, 11 Jul 2008 14:34:50 +0000 (16:34 +0200)]
the beginnings of library partition-table tools
* libparted/labels/pt-tools.h: New file.
* libparted/labels/pt-tools.c: New file.
* libparted/labels/Makefile.am (liblabels_la_SOURCES): Add them.
Jim Meyering [Fri, 11 Jul 2008 10:27:17 +0000 (12:27 +0200)]
avoid dvh label-clone test failure
* libparted/labels/dvh.c (dvh_duplicate): Initialize with
ped_disk_new_fresh, not with _ped_disk_alloc. The former
sets disk->update_mode = 1, as required (and enforced via an
assertion in ped_disk_destroy).
Jim Meyering [Fri, 11 Jul 2008 09:18:16 +0000 (11:18 +0200)]
* libparted/labels/gpt.c (gpt_clobber): Plug a leak.
Jim Meyering [Fri, 21 Dec 2007 14:39:09 +0000 (15:39 +0100)]
amiga: Avoid writing uninitialized 1.5KB after initial 512B.
Jim Meyering [Tue, 18 Dec 2007 15:17:06 +0000 (16:17 +0100)]
disable some file-system-related probe tests for sector size > 512
These changes keep us from recognizing most file systems
when the sector size is larger than 512. However, for now (while
concentrating on getting partition table support right) that's not
a problem. Besides, the code we're avoiding would inevitably make
parted smash its stack.
* libparted/fs/linux_swap/linux_swap.c (_generic_swap_probe): Fail
the swap-file-system-recognizing test when sector size is not 512.
* libparted/filesys.c (ped_file_system_probe_specific): Fail all
fs-specific probe-related tests when sector size is not 512.
* libparted/fs/jfs/jfs.c (jfs_probe): For now, don't even try to
deal with larger sector size.
* libparted/label.c: Skip tests of problematic file system types.
* tests/t0100-print.sh: Print with units of sectors, and adjust
expected output accordingly.
* tests/t1000-mkpartfs.sh: Use a smaller test file.
Jim Meyering [Wed, 4 Jul 2007 19:15:05 +0000 (21:15 +0200)]
Fix compile failures.
Jim Meyering [Wed, 4 Jul 2007 19:03:07 +0000 (21:03 +0200)]
Add fat support for sector_size > 512.
Jim Meyering [Wed, 4 Jul 2007 18:50:18 +0000 (20:50 +0200)]
avoid compiler warnings
* libparted/fs/ext2/interface.c (_ext2_generic_probe): Likewise.
(_ext2_clobber): Likewise.
Jim Meyering [Fri, 15 Jun 2007 14:13:59 +0000 (16:13 +0200)]
Make loop_probe and loop_clobber work with sector_size > 512, too.
Jim Meyering [Fri, 15 Jun 2007 14:06:34 +0000 (16:06 +0200)]
Still working on making label support work.
* libparted/fs/ext2/interface.c (_ext2_generic_probe): The call to
ped_geometry_read_alloc would clobber the stack after SB whenever
block_size > 512. Instead, use new function, ped_geometry_read_alloc,
and adjust all uses of SB.
(_ext2_clobber): Likewise.
* libparted/cs/geom.c (ped_geometry_read_alloc): New function.
* include/parted/geom.h: Declare it.
Jim Meyering [Fri, 15 Jun 2007 09:13:35 +0000 (11:13 +0200)]
(msdos_clobber): Plug the leak I just introduced.
Jim Meyering [Fri, 15 Jun 2007 08:42:39 +0000 (10:42 +0200)]
Make "mklabel loop" work with >512 sector_size, even when...
there is an existing "msdos" label.
(msdos_clobber): Make it work with >512 sector_size.
Jim Meyering [Fri, 15 Jun 2007 08:08:16 +0000 (10:08 +0200)]
Make "mklabel loop" work with >512 sector_size.
Jim Meyering [Fri, 15 Jun 2007 07:12:04 +0000 (09:12 +0200)]
Make "mklabel msdos" work with >512 sector_size.
Jim Meyering [Fri, 15 Jun 2007 06:59:44 +0000 (08:59 +0200)]
Make "mklabel bsd" work with >512 sector_size.
Jim Meyering [Thu, 14 Jun 2007 10:48:50 +0000 (12:48 +0200)]
Make "mklabel mac" work with >512-byte sector_size.