OSDN Git Service
Jim Meyering [Sat, 12 Dec 2009 23:56:54 +0000 (00:56 +0100)]
build: distribute gperf-generated file, pt-limit.c
* libparted/labels/Makefile.am (EXTRA_DIST): Distribute the
gperf-generated file, pt-limit.c, so that people don't need to
run gperf at build-from-tarball time.
Jim Meyering [Sat, 12 Dec 2009 17:31:04 +0000 (18:31 +0100)]
ui: mkpart: avoid double free
* parted/parted.c (do_mkpart): This function frees "part_name"
immediately after the final use, but also upon e.g., ped_disk_commit
failure. Set part_name to NULL after the first free, to make
the second a no-op after the first.
Jim Meyering [Sat, 12 Dec 2009 07:28:20 +0000 (08:28 +0100)]
build: update spec: gperf is a new build-requirement
* parted.spec.in (BuildRequires): Add gperf.
Reported by Jeff Darcy.
Jim Meyering [Fri, 11 Dec 2009 20:18:23 +0000 (21:18 +0100)]
build: update gnulib submodule to latest
Jim Meyering [Fri, 11 Dec 2009 15:56:45 +0000 (16:56 +0100)]
tests: ensure that parted can partition a loop device
* tests/t8000-loop.sh: Reverse sense of tests, now that
partitioning a loop device succeeds again.
* NEWS (Bug fixes): Mention it.
Hans de Goede [Fri, 11 Dec 2009 10:24:52 +0000 (11:24 +0100)]
linux: treat loopback devices as files
We cannot do partition related ioctl's on loopback devices,
so treat them as files.
* libparted/arch/linux.c (LOOP_MAJOR): Define.
* libparted/arch/linux.c (_device_probe_type): Treat loopback
devices as files.
Reported by Josef Bacik in http://bugzilla.redhat.com/546622
Hans de Goede [Thu, 10 Dec 2009 11:43:18 +0000 (12:43 +0100)]
libparted: missing pop update mode in ped_disk_delete_all error path
* libparted/disk.c(ped_disk_delete_all): Add missing update mode pop
call in error path.
Hans de Goede [Thu, 10 Dec 2009 11:43:17 +0000 (12:43 +0100)]
libparted: make pop/push update mode propagate sanity check errors
Sanity check errors indicate something is really really wrong, still
sometimes they happen, when they happen it helps a lot in debugging
them when the libparted caller immediately errors out at the first
moment, rather then slugging along until things crash somewere.
* libparted/disk.c(_disk_push_update_mode,_disk_pop_update_mode):
Change return value from void to int, and return 0 when the sanity
check calls fail.
* libparted/disk.c(*): Update all _disk_push_update_mode /
_disk_pop_update_mode callers to propagate the return value.
Joel Granados Moreno [Thu, 10 Dec 2009 11:43:15 +0000 (12:43 +0100)]
libparted: add missing update mode pop in duplicate error path
* libparted/disk.c(ped_disk_duplicate): Add missing update mode
pop call in error path.
Joel Granados Moreno [Thu, 10 Dec 2009 11:43:14 +0000 (12:43 +0100)]
gpt: Add support for appletv partitions
* include/parted/disk.h(PedPartitionFlag): Add
PED_PARTITION_APPLE_TV_RECOVERY.
* libparted/disk.c(ped_partition_flag_get_name): Handle
PED_PARTITION_APPLE_TV_RECOVERY.
* libparted/labels/gpt.c(PARTITION_APPLE_TV_RECOVERY_GUID):
New define.
* libparted/labels/gpt.c(GPTPartitionData): Add atvrecv member.
* libparted/labels/gpt.c(_parse_part_entry, gpt_partition_new,
gpt_partition_set_system, gpt_partition_set_flag,
gpt_partition_get_flag, gpt_partition_is_flag_available):
Handle atvrecv / PARTITION_APPLE_TV_RECOVERY_GUID.
Joel Granados Moreno [Thu, 10 Dec 2009 11:43:16 +0000 (12:43 +0100)]
build: don't install s390 dasd internal headers into /usr/include
* include/parted/Makefile.am (partedinclude_HEADERS):
Remove $(S390_HDRS).
(noinst_HEADERS): Put them here instead.
Hans de Goede [Thu, 10 Dec 2009 10:33:58 +0000 (11:33 +0100)]
ui: add --align command-line option to specify mkpart alignment
The new --align command-line option can have the following values:
none: Use the minimum alignment allowed by the disk type
cylinder: Align partitions to cylinders (the default)
minimal: Use minimum alignment as given by the disk topology information
optimal: Use optimum alignment as given by the disk topology information
Note the "minimal" and "optimal" values will use layout information
provided by the disk to align the logical partition table addresses
to actual physical blocks on the disks. The "minimal" value is the
minimum aligment needed to align the partition properly to physical
blocks, which avoids performance degradation. Whereas the "optimum"
alignment align's to a multiple of the physical block size in a way
that guarantees optimal performance.
The "minimal" and "optimal" values are useful only when parted is
compiled with libblkid >= 2.17 and running on a kernel >= 2.6.31,
otherwise they are equivalent to --align=none.
* parted/parted.c (ALIGNMENT_ enum values): New enum.
(options, options_help): Add --align option.
(align_args, align_types, alignment): New global variables.
(do_mkpart): Honor aligment variable.
(_parse_options): handle --align option.
* bootstrap.conf (gnulib_modules): Add argmatch.
* NEWS: Mention the new --align option.
* doc/parted.texi: Document --align option.
* doc/C/parted.8: Likewise.
Hans de Goede [Thu, 10 Dec 2009 10:34:00 +0000 (11:34 +0100)]
NEWS: update with libblkid and kernel requirements for alignment funcs
* NEWS: Change the note for the align-check command to also reference
libblkid, add a note to the libparted alignment functions NEWS entry
about libblkid and kernel requirements.
Hans de Goede [Thu, 10 Dec 2009 10:33:57 +0000 (11:33 +0100)]
NEWS: Add new disk flag functions to NEWS
* NEWS: Add new disk flag functions.
Hans de Goede [Wed, 9 Dec 2009 14:38:01 +0000 (15:38 +0100)]
msdos, sun: implement disk flag operations
* libparted/labels/dos.c (DosDiskData): New struct.
* libparted/labels/dos.c (msdos_alloc, msdos_duplicate, msdos_free):
Handle per disk DosDiskData.
* libparted/labels/dos.c (msdos_disk_set_flag, msdos_disk_get_flag,
msdos_disk_is_flag_available): New functions.
* libparted/labels/sun.c (sun_disk_set_flag, sun_disk_get_flag,
sun_disk_is_flag_available): New functions.
Hans de Goede [Wed, 9 Dec 2009 14:38:00 +0000 (15:38 +0100)]
libparted: add disk flag functions and PED_DISK_CYLINDER_ALIGNMENT flag
Sometimes we want to be able to set flags at the disk level rather then
at the parition level, to influence how new partitions will be created
for example. This patch adds functions to do this (modelled after the
partition flag functions), and adds a PED_DISK_CYLINDER_ALIGNMENT flag.
This flag (which defaults to true) controls if disk types for which
cylinder alignment is optional do cylinder alignment when a new
partition gets added. This flag is available for msdos and sun
disklabels (for sun labels it only controls the aligning of the end of
the partition).
* include/parted/disk.h (PedDiskFlag): New type
* include/parted/disk.h (ped_disk_set_flag, ped_disk_get_flag,
ped_disk_is_flag_available): new functions and PedDiskOps members
* include/parted/disk.h (ped_disk_flag_get_name,
ped_disk_flag_get_by_name, ped_disk_flag_next): new functions
* libparted/disk.c (ped_disk_set_flag, ped_disk_get_flag,
ped_disk_is_flag_available, ped_disk_flag_get_name,
ped_disk_flag_get_by_name, ped_disk_flag_next): new functions
Hans de Goede [Wed, 9 Dec 2009 14:38:02 +0000 (15:38 +0100)]
dasd: fix leak in dasd_free
* libparted/labels/dasd.c (dasd_free): Free disk_specific data.
Jim Meyering [Wed, 9 Dec 2009 16:21:42 +0000 (17:21 +0100)]
build: update gnulib submodule to latest
Jim Meyering [Wed, 9 Dec 2009 16:20:47 +0000 (17:20 +0100)]
build: make it clear which sector size is in use upon test failure
* Makefile.am (ss-1024 ss-2048 ss-4096): New targets.
Before this, top-level "make check" would lead to four separate
runs through all the regression tests, one for each of the following
simulated sector sizes: 1024 2048 4096, and one more for the native
(usually 512), and it was not easy to tell which sector size was
in use for a failing test. Now, we still perform exactly the same
tests, but the sector size is now part of each target name.
Jim Meyering [Fri, 4 Dec 2009 18:36:58 +0000 (19:36 +0100)]
tests: exercise the new interfaces
* tests/print-max.c: New file.
* tests/t9021-maxima.sh: New file.
* tests/Makefile.am (TESTS): Add t9021-maxima.sh.
(check_PROGRAMS): Add print-max.
Jim Meyering [Fri, 4 Dec 2009 16:18:57 +0000 (17:18 +0100)]
libparted: new interfaces: max start sector, max partition length
* libparted/disk.c (ped_disk_max_partition_start_sector): New function.
(ped_disk_max_partition_length): New function.
* include/parted/disk.h: Declare them.
* NEWS (New features): Mention them.
Jim Meyering [Thu, 3 Dec 2009 17:52:25 +0000 (18:52 +0100)]
libparted: factor out duplication, hook up new APIs
* include/parted/disk.h [struct _PedDiskOps]:
(max_length, max_start_sector): New members.
* libparted/labels/pt-common.h: New file.
* libparted/labels/Makefile.am (liblabels_la_SOURCES): Add it.
* libparted/labels/dos.c: Include "pt-common.h".
(msdos_partition_check): Remove function.
(msdos_disk_ops): Remove factored out initializers.
* libparted/labels/gpt.c: Likewise.
* libparted/labels/dvh.c: Likewise.
* libparted/labels/aix.c:
(aix_disk_ops, aix_partition_check): Likewise.
* libparted/labels/bsd.c:
(bsd_disk_ops, bsd_partition_check): Likewise.
* libparted/labels/dasd.c:
(dasd_disk_ops, dasd_partition_check): Likewise.
* libparted/labels/loop.c:
(loop_disk_ops, loop_partition_check): Likewise.
* libparted/labels/mac.c:
(mac_disk_ops, mac_partition_check): Likewise.
* libparted/labels/pc98.c:
(pc98_disk_ops, pc98_partition_check): Likewise.
* libparted/labels/rdb.c:
(amiga_disk_ops, amiga_partition_check): Likewise.
* libparted/labels/sun.c:
(sun_disk_ops, sun_partition_check): Likewise.
* libparted/labels/gpt.c (NULL_IF_DISCOVER_ONLY): Remove definition,
now that it's in pt-common.h.
Jim Meyering [Thu, 3 Dec 2009 10:45:05 +0000 (11:45 +0100)]
libparted: use gperf-generated lookup function
* libparted/labels/pt-tools.c (ptt_partition_max_start_len):
Rewrite to use the gperf-generated look-up function.
(ptt_partition_max_start_sector): New function.
(ptt_partition_max_length): New function.
* libparted/labels/pt-tools.h: Declare them.
* libparted/labels/Makefile.am (GPERF, GPERF_OPTIONS): Define.
(BUILT_SOURCES): Define.
(liblabels_la_SOURCES): Append pt-limit.gperf.
(pt-limit.c): New rule.
(MAINTAINERCLEANFILES): Remove useless definition.
(DISTCLEANFILES): Set to $(BUILT_SOURCES).
* libparted/labels/pt-limit.gperf: New file.
* cfg.mk (bootstrap-tools): Mention gperf.
* bootstrap.conf (buildreq): Require gperf-3.0.3.
Jim Meyering [Mon, 7 Dec 2009 18:10:41 +0000 (19:10 +0100)]
pc98: avoid segfault with simulated large sectors
The pc98 partition table is by no means ready for >512-byte sectors,
but at least it now gets past mklabel. E.g., this usage no longer
provokes double-free and read-uninitialized errors:
dd if=/dev/zero of=F bs=512 count=1 seek=10000
PARTED_SECTOR_SIZE=4096 valgrind ../parted/parted -s F mklabel pc98
* libparted/labels/pc98.c (pc98_write): Rewrite to avoid
invalid access with >512-byte sectors.
Jim Meyering [Mon, 7 Dec 2009 19:27:21 +0000 (20:27 +0100)]
libparted: ptt_read_sectors: new function
* libparted/labels/pt-tools.c (ptt_read_sectors): New function.
(ptt_read_sector): Rewrite to use it.
* libparted/labels/pt-tools.h: Declare it.
Jim Meyering [Thu, 3 Dec 2009 09:58:31 +0000 (10:58 +0100)]
mac: hook up the partition_check function for this partition table type
* libparted/labels/pt-tools.c (ptt_partition_max_start_len): Define
for MAC partition tables. They too have 32-bit-limited partition
starting sector number and partition length (in sectors).
* libparted/labels/mac.c (mac_partition_check): Use
ptt_partition_max_start_len.
Jim Meyering [Fri, 27 Nov 2009 11:30:21 +0000 (12:30 +0100)]
tests: exercise new align-check command
* tests/t9030-align-check.sh: New file.
* tests/Makefile.am (TESTS): Add it.
Jim Meyering [Fri, 27 Nov 2009 10:15:53 +0000 (11:15 +0100)]
ui: new command: align-check TYPE N
e.g.,
parted -s /dev/sda align-check min 1 && echo partition 1 is min-aligned
parted -s /dev/sda align-check opt 2 && echo partition 2 is opt-aligned
* parted/parted.c:
* parted/ui.c:
* parted/ui.h:
* NEWS (New features): Mention it.
* doc/parted.texi (align-check): Describe it.
Jim Meyering [Thu, 26 Nov 2009 22:00:47 +0000 (23:00 +0100)]
tests: correct a comment
* tests/t9020-alignment.sh: Correct a comment.
Jim Meyering [Thu, 26 Nov 2009 13:40:04 +0000 (14:40 +0100)]
libparted: ped_disk_clobber_exclude: remove now-unused function
I see no utility in ped_disk_clobber_exclude (just a thin wrapper
around ped_disk_clobber), so am removing the interface.
* include/parted/disk.h (ped_disk_clobber_exclude): Remove prototype.
* libparted/disk.c (ped_disk_clobber_exclude): Remove function.
Now that all callers use NULL as 2nd argument, replace each call
with one to ped_disk_clobber.
* scripts/data/abi/baseline_symbols.txt: Remove it.
Reviewed-by: Karel Zak <kzak@redhat.com>
Jim Meyering [Fri, 13 Nov 2009 10:37:39 +0000 (11:37 +0100)]
ped_disk_clobber: change semantics
Why? Because if we're going to clobber a partition table,
it is wasteful and error prone to try to interpret as a partition
table whatever existing data there may be. It may be corrupt, or
a mix of two or more types. It is far cleaner just to zero out
the key sectors.
The previous mechanism was like this:
for each partition table type, T,
# See if the device has a partition of type T.
# If so, run the partition-table-specific code to clear it.
if t->ops->probe (dev)
t->ops->clobber (dev)
Instead, simply zero out the first few and last few sectors.
Except for GPT, for which we exempt the first sector (the pMBR).
In order to zero out even the bits DASD uses for its identifying
strings, we have to clobber at least the 8.5KiB at the beginning
of the disk, so round up to 9KiB.
* libparted/disk.c: Include "labels/pt-tools.h".
(find_disk_type): New helper function.
(ped_disk_clobber_exclude):
Reviewed-by: Karel Zak <kzak@redhat.com>
Jim Meyering [Thu, 12 Nov 2009 15:00:41 +0000 (16:00 +0100)]
dasd: allow the use of a *regular* backing file
Before this change, dasd partition tables had to be associated with
very specialized block devices available only on IBM s390 systems.
This made testing especially hard. Not only did you need access
to one of those relatively uncommon systems, but you also needed
access to a spare block device. In addition, many of Parted's
tests may be run as a non-privileged user, using regular files,
and those tests would fail when run on an s390.
This change makes it so you may now write a DASD partition table
to a regular backing file, just as you may with any other supported
partition table type. However, note that even now, DASD support
is conditionally compiled and hence enabled only when compiling
for an s390 target.
* libparted/arch/linux.c (_device_set_sector_size) [__s390__]:
Allow operation on a device of type PED_DEVICE_FILE, as well as
those of type PED_DEVICE_DASD.
* libparted/labels/fdasd.c: Include <parted/device.h>.
(fdasd_get_geometry): Add a new "dev" parameter, required for
dev-phys-sector_size, which is needed in order to initialize
the "anc" structure without using the device-specific ioctls.
When file descriptor "f" refers to a regular file, initialize
"anc", "dasd_info", etc. from other sources (fstat and dev->).
Update all callers to reflect added parameter.
(fdasd_check_api_version): Skip ioctl-calling tests when "f" is
a regular file.
* include/parted/fdasd.h: Update fdasd_get_geometry prototype.
* libparted/labels/dasd.c (dasd_probe): Also allow PED_DEVICE_FILE.
(dasd_alloc_metadata): Initialize arch_specific->real_sector_size,
which is used in calculating vtoc_end.
Reviewed-by: Karel Zak <kzak@redhat.com>
Jim Meyering [Tue, 24 Nov 2009 14:55:35 +0000 (15:55 +0100)]
loop: simplify/correct loop_clobber
Before, it would clear a sector only if it recognized its own
signature. In addition, it would continue clearing subsequent
sectors as long as loop_probe succeeded. Now we simply clear
the first sector.
* libparted/labels/loop.c (loop_clobber): Simplify.
Reviewed-by: Karel Zak <kzak@redhat.com>
Jim Meyering [Thu, 26 Nov 2009 15:51:18 +0000 (16:51 +0100)]
tests: indicate that we expect t3200-type-change to fail, for now
* tests/Makefile.am (TESTS): Move t3200-type-change.sh to ...
(XFAIL_TESTS): ...here.
Jim Meyering [Tue, 17 Nov 2009 10:27:29 +0000 (11:27 +0100)]
tests: correct t3200-type-change.sh
* tests/t3200-type-change.sh: The initial version was incomplete.
Jim Meyering [Tue, 17 Nov 2009 11:15:30 +0000 (12:15 +0100)]
tests: provide a new function: fail_
* tests/t-lib.sh (fail_): New function.
Jim Meyering [Tue, 17 Nov 2009 14:39:00 +0000 (15:39 +0100)]
tests: t0001-tiny.sh: avoid spurious failure when run as root.
* tests/t0001-tiny.sh: Control characters were getting in the way.
Filter them out.
Jim Meyering [Mon, 23 Nov 2009 20:46:17 +0000 (21:46 +0100)]
dasd: avoid NULL-dereference via disk->type->ops->partition_check
Commit
f387fee8 added the new ops->partition_check() function,
and a <type>_partition_check function for each partition table
format _except_ dasd. This change adds one for dasd, too.
* libparted/labels/dasd.c: Include "pt-tools.h".
(dasd_partition_check): New function.
* libparted/labels/pt-tools.c (ptt_partition_max_start_len): Add "dasd"
to the list of partition table type names for which the 32-bit
limits on starting sector and partition length apply.
Correct a comment.
Considering the 32-bit fields in "struct fdasd_hd_geometry",
it is safe to assume that larger offset or size is not possible.
Jim Meyering [Wed, 18 Nov 2009 20:46:07 +0000 (21:46 +0100)]
build: "make stable" emitted an invalid gnupload command
* cfg.mk (gnu_ftp_host-stable): Rename from gnu_ftp_host-major.
Jim Meyering [Tue, 17 Nov 2009 10:27:29 +0000 (11:27 +0100)]
test for partition-type-changing bug
* tests/t3200-type-change.sh: New file.
* tests/Makefile.am (TESTS): Add it.
Jim Meyering [Fri, 13 Nov 2009 12:51:53 +0000 (13:51 +0100)]
gpt: greatly simply gpt_clobber; minor semantic change, too
* libparted/labels/gpt.c (gpt_clobber): Don't bother to read and
parse existing headers. Instead, simply clear three sectors:
the pMBR, the primary header (LBA1), and the last sector.
There is no point in clearing what the primary header says is the
AlternateLBA, since once the primary header and the last sector
are cleared, there is no risk of any tool using it by mistake.
Jim Meyering [Fri, 13 Nov 2009 12:47:29 +0000 (13:47 +0100)]
tests: t0000-basic.sh: minor correction
* tests/t0000-basic.sh: When zeroing out the first sector,
use dd's conv=notrunc. Otherwise, we'd also truncate the
backing file size to 4KiB.
Jim Meyering [Fri, 13 Nov 2009 12:43:58 +0000 (13:43 +0100)]
linux_read: give a proper diagnostic for an "end of file" error
Before today's gpt_probe bug fix, its test case would provoke
an invalid diagnostic. This makes the diagnostic useful.
* libparted/arch/linux.c (linux_read): When hitting EOF while reading,
diagnose it properly, rather than via strerror(0) (i.e., "Success").
Jim Meyering [Fri, 13 Nov 2009 12:40:29 +0000 (13:40 +0100)]
gpt_probe: don't attempt to read beyond end of a very small disk
* libparted/labels/gpt.c (gpt_probe): Don't try to read the
2nd sector if that's beyond the end of the disk.
* tests/t0001-tiny.sh: New test, to expose the above boundary-case bug.
Part of the msdos-partition-creation process involves probing for
other types of partition tables. Probing for gpt would evoke a
nonsensical diagnostic.
* tests/Makefile.am (TESTS): Add t0001-tiny.sh.
Jim Meyering [Fri, 13 Nov 2009 10:39:40 +0000 (11:39 +0100)]
dvh: replace open-coded dvh_clobber with equivalent, shorter code
* libparted/labels/dvh.c (dvh_clobber): Simply use ptt_clear_sectors.
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.
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.
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.
Hans de Goede [Tue, 10 Nov 2009 08:26:15 +0000 (09:26 +0100)]
NEWS: mention recent changes
Jim Meyering [Tue, 10 Nov 2009 12:32:30 +0000 (13:32 +0100)]
maint: more const-correctness fixes
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.
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".
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.
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.
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.
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.
Jim Meyering [Sat, 7 Nov 2009 15:32:37 +0000 (16:32 +0100)]
build: update gnulib submodule to latest
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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-".
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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):
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.
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.