OSDN Git Service

android-x86/external-parted.git
16 years agoRemoving unnecessary type-casts and eerie comments.
Debarshi Ray [Fri, 2 Nov 2007 11:53:32 +0000 (17:23 +0530)]
Removing unnecessary type-casts and eerie comments.

16 years agoAdded information to message about ext2 incompatible features.
Mark Neyhart [Mon, 29 Oct 2007 18:15:03 +0000 (10:15 -0800)]
Added information to message about ext2 incompatible features.

Modifed the message about incompatible ext2 features installed to include a
list of compatible features and to recommend the usage of tune2fs or
debugfs to remove features which are not compatible.

16 years agoReally duplicate the disk instead of readd every partition
Otavio Salvador [Thu, 30 Aug 2007 12:52:03 +0000 (09:52 -0300)]
Really duplicate the disk instead of readd every partition

To avoid possible differences between the original disk layout and the
duplicated one, a raw copy is done. Has been identified a case[1]
where extended partitions had their positions changed due this.

 1. http://bugs.debian.org/294520

The recipe[2] to reproduce the problem, on the provided URI, has been
used to produced a test and hence be sure it's not forgotten anymore.

 2. http://bugs.debian.org/294520#34

The fix has been produced by Samuel Thibault <samuel.thibault@ens-lyon.org>

16 years agoSet partprobe's text domain.
Benno Schulenberg [Thu, 16 Aug 2007 14:24:50 +0000 (16:24 +0200)]
Set partprobe's text domain.

* partprobe/partprobe.c (main): Set textdomain.

16 years agoFix mkpart linux-swap bug: would use 0x83 rather than 0x82
Jim Meyering [Mon, 13 Aug 2007 20:36:27 +0000 (22:36 +0200)]
Fix mkpart linux-swap bug: would use 0x83 rather than 0x82

* libparted/labels/bsd.c (bsd_partition_set_system): Include "misc.h".
Use is_linux_swap to test whether the type string matches.
* libparted/labels/dasd.c (dasd_read, dasd_partition_set_system): Likewise.
* libparted/labels/dos.c (msdos_partition_set_system): Likewise.
* libparted/labels/mac.c (mac_partition_set_system): Likewise.
* libparted/labels/rdb.c (amiga_partition_set_system): Likewise.
* libparted/labels/sun.c (sun_partition_set_system): Likewise.
Based on a patch by Kenneth MacDonald, from
<http://lists.gnu.org/archive/html/bug-parted/2007-07/msg00012.html>.
* libparted/labels/misc.h (is_linux_swap): New function/file.
* libparted/labels/Makefile.am (liblabels_la_SOURCES): Add misc.h.
* tests/t2100-mkswap.sh: New file, test for the above fix.
* tests/Makefile.am (TESTS): Add t2100-mkswap.sh.

16 years agoDon't try to avoid "free (x)" when x is NULL.
Jim Meyering [Mon, 13 Aug 2007 20:41:39 +0000 (22:41 +0200)]
Don't try to avoid "free (x)" when x is NULL.

* libparted/arch/linux.c (linux_read):
Part of http://git.debian.org/?p=parted/parted.git;a=commitdiff;h=080d3e7078
changed this:

  free(diobuf);

to this:

  if (diobuf)
      free(diobuf);

Yet, free doesn't have any problem with NULL.
Some very old (non-POSIX) implementations did (like SunOS4),
but even for them, gnulib's lib/free.c protects us.

Signed-off-by: Jim Meyering <jim@meyering.net>
16 years agoAvoid test failure with dash's builtin printf.
Jim Meyering [Tue, 14 Aug 2007 09:06:29 +0000 (11:06 +0200)]
Avoid test failure with dash's builtin printf.
* tests/t0100-print.sh (msdos_magic): Use more-portable octal escapes,
not hexadecimal ones.

16 years agoSanity check for dev, safety checks on diobuf.
David Cantrell [Wed, 8 Aug 2007 22:04:00 +0000 (18:04 -0400)]
Sanity check for dev, safety checks on diobuf.

Make sure diobuf is NULL before we begin and make sure it isn't NULL when
we try to free it.  Throw an exception if dev is NULL and we enter this
function.
(cherry picked from commit be2ace6e8d381fb836647234ac65d34a4a547e31)

16 years agoRevert "History with undo and redo capabilities."
David Cantrell [Thu, 9 Aug 2007 15:20:44 +0000 (11:20 -0400)]
Revert "History with undo and redo capabilities."

This reverts commit 3bb8494e1ed5af0a48ad0211c3219e653167854f.

16 years agoHistory with undo and redo capabilities.
David Cantrell [Wed, 8 Aug 2007 22:14:08 +0000 (18:14 -0400)]
History with undo and redo capabilities.

Author: Matt Davis <mattdavis@gmail.com>

Here is a working version of the history with undo/redo capabilities.  The
idea here was based on a talk with Otavio Salvador who mentioned the concepts
from Vanni Brutto.  The idea being to capture all changes and only apply them
all at once.  This protects the user from performing an unwanted change.  What
I did was capture all disk modifications that are committed to disk, and put
them in a list.  The history manager allows the list to be traversed linearly,
so that a change can be undone, viewed in parted (print command), or reapplied
again.  Nothing actually happens to the physical disk until the 'save' command
is issued.

Jim Meyering suggested that the functionality might be useful to libparted
thus most of the functionality has been moved there.  The stdout displays
(printf) are placed in parted.c as the library should not do any output
printing on its own.

Three commands were added:
1) Undo : Undoes a disk modification
2) Redo : Redoes the most recent 'undone' modification
3) Save : Actually commits the list of non-undone modifications to disk

I feel a bit more testing needs to be done, but I am happy with the results
right now.

16 years agoRevert "If we cannot create a new PedDisk for the device we're looking at, return...
Jim Meyering [Wed, 1 Aug 2007 07:44:56 +0000 (09:44 +0200)]
Revert "If we cannot create a new PedDisk for the device we're looking at, return NULL rather than the device path."
The reverted change causes almost all tests to fail.

This reverts commit a6f86144c0b5fd07c462e256bc7b54095c7b8e7a.

16 years agoRevert "Removed unused label (compiler warning)."
Jim Meyering [Wed, 1 Aug 2007 07:37:13 +0000 (09:37 +0200)]
Revert "Removed unused label (compiler warning)."
The label *is* used.

This reverts commit f4bc90ac22de605ad927d2d85ba468a16bf55ae7.

16 years agoProbe for all device-mapper devices.
David Cantrell [Tue, 31 Jul 2007 19:41:22 +0000 (15:41 -0400)]
Probe for all device-mapper devices.

Add _dm_probe_all() from Debian and patch linux_probe_all() to probe for
device-mapper devices after probing for standard devices.
(cherry picked from commit 609b7ae6d274e479027bb46c4bd10227cd921803)

16 years agoAdd the PED_DEVICE_XVD device type for Xen virtual block devices.
David Cantrell [Tue, 31 Jul 2007 17:57:55 +0000 (13:57 -0400)]
Add the PED_DEVICE_XVD device type for Xen virtual block devices.
(cherry picked from commit af4bea2ac854343609f3e6688bedd727ddf76ae6)

16 years agoDetect Xen virtual block devices and identify them as such.
David Cantrell [Tue, 31 Jul 2007 17:58:40 +0000 (13:58 -0400)]
Detect Xen virtual block devices and identify them as such.
(cherry picked from commit 64861efcaae95f605614d5e4c6d9c35c5d5712d7)

16 years agoIf we cannot create a new PedDisk for the device we're looking at, return NULL rather...
David Cantrell [Tue, 31 Jul 2007 17:59:27 +0000 (13:59 -0400)]
If we cannot create a new PedDisk for the device we're looking at, return NULL rather than the device path.
(cherry picked from commit 865ea3d3f2eb7918b64a00825dfa44e05651e2ad)

16 years agoWhen reading the DASD disk label, look at the partition flags as well as what is...
David Cantrell [Tue, 31 Jul 2007 18:00:31 +0000 (14:00 -0400)]
When reading the DASD disk label, look at the partition flags as well as what is on the actual partition using ped_file_system_probe().  This avoids flags being set for partitions when they shouldn't be.
(cherry picked from commit dfafc45a3775cc92d3cd89c9b35926cab23db512)

16 years agoRemoved unused label (compiler warning).
David Cantrell [Tue, 31 Jul 2007 18:06:09 +0000 (14:06 -0400)]
Removed unused label (compiler warning).
(cherry picked from commit b43bda3134059cdacb13e1a4d0a0bee8a543cfb0)

17 years agoFix bootstrap script to support the new translationproject html files
Otavio Salvador [Fri, 27 Jul 2007 01:46:31 +0000 (22:46 -0300)]
Fix bootstrap script to support the new translationproject html files

17 years agoUpdated GPL license boilerplate.
David Cantrell [Mon, 23 Jul 2007 17:54:23 +0000 (13:54 -0400)]
Updated GPL license boilerplate.

17 years agoUpdated COPYING file to the GNU General Public License version 3. Updated boilerplat...
David Cantrell [Mon, 23 Jul 2007 17:07:02 +0000 (13:07 -0400)]
Updated COPYING file to the GNU General Public License version 3.  Updated boilerplate GPL text to reference version 3 of the license.

17 years agoFlip the switch (expected-failure -> expected-success) in tests/t3100-
Jim Meyering [Tue, 10 Jul 2007 10:03:49 +0000 (12:03 +0200)]
Flip the switch (expected-failure -> expected-success) in tests/t3100-
resize-ext2-partion.sh, now that this bug is fixed.

17 years agoFix block state checking for realocated blocks
Flavio Leitner [Tue, 12 Jun 2007 17:54:26 +0000 (14:54 -0300)]
Fix block state checking for realocated blocks

A busy block should be realocated and it's correct in
ext2_block_relocator_mark(), but not in ext2_metadata_push().

Signed-off-by: Flavio Leitner <flavio.leitner@gmail.com>
Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoFix block number used when checking for state
Flavio Leitner [Tue, 12 Jun 2007 17:53:20 +0000 (14:53 -0300)]
Fix block number used when checking for state

Hi there,

The ext2_bread() returns a descriptor containing a
pointer ->data representing the contents of 1 block.

In ext2_block_relocate_grow(), it reads the block bitmap from
a group descriptor representing a range of blocks:
   bh = ext2_bread(fs, EXT2_GROUP_BLOCK_BITMAP(fs->gd[i]));

Then it does:
   k = EXT2_GROUP_INODE_TABLE(fs->gd[i]) + fs->inodeblocks + j;
k is the absolute block number and then checks the state doing:
if (bh->data[k>>3] & _bitmap[k&7])

The k should be the offset inside of group descriptor and not
the absolute block number. Example:
. Block bitmap represents 512 blocks
. Block absolute number is 1023.

GrpDesc = Block absolute number / block bitmap size = 1
bh = ext2_bread(fs, EXT2_GROUP_BLOCK_BITMAP(fs->gd[GrpDesc]))
bh->data[] contains a bitmap of 512 blocks from 512-1024
relative = absolute block number % block bitmap size
relative = 1023/512 = 511

The block state is in bitmap bh->data[relative>>3] & ...

Signed-off-by: Flavio Leitner <flavio.leitner@gmail.com>
Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoFix syntax error and LIBS problem in configure.ac
Michael Brennan [Tue, 10 Jul 2007 02:26:38 +0000 (04:26 +0200)]
Fix syntax error and LIBS problem in configure.ac

Make sure LIBS doesn't contain libraries that will prevent
successful compilations after libreadline has been tested.
A trailing comma generated a syntax error in the configure script.

Signed-off-by: Michael Brennan <brennan.brisad@gmail.com>
17 years agoMore correct handling of the HeaderSize field in GPT labels
Matthew S. Harris [Sun, 8 Jul 2007 19:27:07 +0000 (12:27 -0700)]
More correct handling of the HeaderSize field in GPT labels

- Use the HeaderSize field value when determining how many bytes to
compute the CRC over.

- Don't abort if the HeaderSize field value is bigger than our struct,
since more fields may be defined in the future.

Signed-off-by: Matthew S. Harris <mharris@coruscant.(none)>
17 years agoDon't let the automatically-generated ChangeLog cause "make dist" failure.
Jim Meyering [Fri, 6 Jul 2007 19:29:46 +0000 (21:29 +0200)]
Don't let the automatically-generated ChangeLog cause "make dist" failure.
* Makefile.cfg (local-checks-to-skip): Add sc_changelog.

17 years agoLet "make distcheck" pass once again.
Jim Meyering [Fri, 6 Jul 2007 11:53:39 +0000 (13:53 +0200)]
Let "make distcheck" pass once again.
* parted/strlist.c (str_list_alloc): Remove unnecessary
cast of xmalloc return value.

17 years agoFix a problem where a partial read would not be handled correctly;
Michael Brennan [Fri, 6 Jul 2007 11:39:39 +0000 (13:39 +0200)]
Fix a problem where a partial read would not be handled correctly;
also change the status variable to ssize_t.

17 years agoDon't include config.h from internal headers.
Jim Meyering [Tue, 3 Jul 2007 08:47:03 +0000 (10:47 +0200)]
Don't include config.h from internal headers.
This avoids redefinition errors (on the new symbol, __STDC_LIMIT_MACROS_TRIGGER)
when config.h is included twice.

Bob Proulx reported the buildbot failures: http://buildbot.proulx.com:9001/

17 years agoAvoid test failure on Linux-2.6.8 due to too small underlying file.
Jim Meyering [Fri, 22 Jun 2007 17:44:27 +0000 (19:44 +0200)]
Avoid test failure on Linux-2.6.8 due to too small underlying file.
Overwrite the label creating a 4KB file; 1KB was too small and would
trigger the failure.  Reported by Bob Proulx.

17 years agoWork around test failures caused by inadequate libreadline.
Jim Meyering [Fri, 22 Jun 2007 14:30:16 +0000 (16:30 +0200)]
Work around test failures caused by inadequate libreadline.

* configure.ac: Reject an inadequate libreadline5.0.
* parted/ui.c (_readline) [!HAVE_LIBREADLINE]: Echo each
just-read line, to be consistent with libreadline5.2.

Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoAvoid mklabel test failure with very small file on Linux-2.6.8.
Jim Meyering [Fri, 22 Jun 2007 14:01:59 +0000 (16:01 +0200)]
Avoid mklabel test failure with very small file on Linux-2.6.8.

Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoREADME-hacking: Don't mention Gzip 1.2.4, now that 1.3.12 is out.
Jim Meyering [Mon, 18 Jun 2007 12:52:27 +0000 (14:52 +0200)]
README-hacking: Don't mention Gzip 1.2.4, now that 1.3.12 is out.
Mention uuid-devel and pkg-config, too.

17 years agoReplace some malloc and strdup by xmalloc and xstrdup respectively
David Vazquez [Tue, 12 Jun 2007 19:25:47 +0000 (21:25 +0200)]
Replace some malloc and strdup by xmalloc and xstrdup respectively

I replace some malloc and strdup by xmalloc and xstrdup respectively.

Signed-off-by: David Vazquez <xeos@gmail.com>
17 years agoFix the mkfs final-block-group-too-short bug.
Jim Meyering [Tue, 12 Jun 2007 15:25:18 +0000 (17:25 +0200)]
Fix the mkfs final-block-group-too-short bug.

mkfs would fail for certain sizes resulting in a final block-group
that was too small to accommodate the minimum number of admin blocks.
There was already work-around code for when a decremented "numgroups"
was 1.  This change applies that work-around code for larger values of
numgroups, too.  Also, there was an off-by-one error in the guard test
that would allow a few too-small partition sizes to slip through and
provoke the error (see tests/t2000-mkfs.sh for two examples).
This change fixes that, too.

17 years agoFix two "make check"-as-root failures.
Jim Meyering [Tue, 12 Jun 2007 14:39:55 +0000 (16:39 +0200)]
Fix two "make check"-as-root failures.
t1100-busy-label.sh: Remove extra copy of "o2" temporary file name.
test-lib.sh (emit_superuser_warning): Exit successfully when run as root, too.

17 years agoFix inconsistent prompt for file system type.
Jim Meyering [Mon, 11 Jun 2007 11:19:03 +0000 (13:19 +0200)]
Fix inconsistent prompt for file system type.

* parted/parted.c (do_mkfs): Use a consistent prompt when asking
for a file system type.

17 years agoAdd a test to record the current EXT2 mkpartfs failure for some sizes.
Jim Meyering [Mon, 11 Jun 2007 12:34:39 +0000 (14:34 +0200)]
Add a test to record the current EXT2 mkpartfs failure for some sizes.

Run this:

    dev=F
    dd if=/dev/null of=$dev bs=1 seek=20M
    ./parted -s $dev mklabel gpt
    ./parted -s $dev mkpartfs primary ext2 0 16796160B

It fails with this diagnostic:

    Error: Attempt to write sectors 32772-32773 outside of partition on /t/F.

But if you choose a size that's one byte smaller, it works:

    ./parted -s $dev mkpartfs primary ext2 0 16796159B

The difference is in how ext2_mkfs_write_meta computes
the number of block groups.  In the former case, it computes
numgroups = 3.  In the latter, numgroups = 2.
The trouble with the first case is that there isn't enough
space for 3 full block groups in a file system of that size.
Hence the eventual attempt to write beyond the initially-
established end-of-file-system mark.

17 years agoAvoid unnecessary writes in test scripts.
Jim Meyering [Mon, 11 Jun 2007 10:32:36 +0000 (12:32 +0200)]
Avoid unnecessary writes in test scripts.

This changes the tests to create sparse files for some test inputs
rather than zero-filled non-sparse ones.  Doing this cuts more than 50% off
the run time of "make check" in the tests/ directory.

Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoAdd a test for an ext2-resize failure.
Matt Davis [Fri, 1 Jun 2007 02:36:58 +0000 (22:36 -0400)]
Add a test for an ext2-resize failure.

This patch is based on the change from Matt Davis:

    http://thread.gmane.org/gmane.comp.gnu.parted.devel/1695/focus=1704

Demonstrate an ext2-resize failure in parted-1.8.7, based on the report in
http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket/22

17 years agoTurn off "DEBUG" in libparted/libparted.c, ...
Jim Meyering [Tue, 5 Jun 2007 14:10:33 +0000 (16:10 +0200)]
Turn off "DEBUG" in libparted/libparted.c, ...
thus making it so that ped_malloc no longer initializes all
just-allocated memory to all '1' bits.  Given the two bugs
I've just fixed, this change is long overdue.

17 years agoMake "mklabel amiga" work also when DEBUG is not enabled.
Jim Meyering [Tue, 5 Jun 2007 14:01:46 +0000 (16:01 +0200)]
Make "mklabel amiga" work also when DEBUG is not enabled.

I turned off DEBUG and discovered test failures that its
bogus always-initialize-malloc'd-memory policy had been hiding:

(amiga_write): Initialize all of "->disk_specific" buffer.
Avoid buffer overrun when initializing "TABLE".

17 years ago"mklabel bsd": don't read/write initialized memory, with DEBUG turned off
Jim Meyering [Tue, 5 Jun 2007 10:23:00 +0000 (12:23 +0200)]
"mklabel bsd": don't read/write initialized memory, with DEBUG turned off
I spent the first part of yesterday debugging the ext2-resize failure.
As part of that, I turned off DEBUG and was surprised to see new failures
in the label checks.  At least for label types "amiga" and "bsd", the
implementation required that freshly-allocated memory be filled with all
"1" bits, as was guaranteed by the default setting of

#define DEBUG 1

When I turned that off, bsd.c would read/write uninitialized memory, and
rdb.c(amiga) would do more of the same and produce partition tables that
it would then fail to recognize.

Here's the fix for the bsd problems.
I'll send the rdb/amiga ones separately, and once all tests pass
without malloc-initialization-to-all-1's, I'll remove that, too.

The bsd read-uninit bug was at bsd.c:341 (bsd_write), with this test:

if (!bsd_specific->boot_code [0])
_probe_and_add_boot_code (disk);

that first byte was never initialized.
So, I figured, that'll be easy.  Just initialize it.
Wrong.  That wasn't enough, since then a part of that same 512-byte
buffer (starting at offset 340) would be used uninitialized by
a write syscall.

FYI, the first failure was demonstrated like this:

dev=f
N=1M
dd if=/dev/zero of=$dev bs=$N count=1 && valgrind ./parted -s $dev mklabel bsd

Here's the first one:

==20087== Conditional jump or move depends on uninitialised value(s)
==20087==    at 0x4429EE: bsd_write (bsd.c:341)
==20087==    by 0x411AD3: ped_disk_commit_to_dev (disk.c:485)
==20087==    by 0x411B19: ped_disk_commit (disk.c:508)
==20087==    by 0x403A12: do_mklabel (parted.c:622)
==20087==    by 0x402AF7: command_run (command.c:139)
==20087==    by 0x40B00A: non_interactive_mode (ui.c:1530)
==20087==    by 0x407A8B: main (parted.c:2479)

and even after initializing only that first byte, here's what I got:

==25692== Syscall param write(buf) points to uninitialised byte(s)
==25692==    at 0x54874D0: __write_nocancel (in /usr/lib/debug/libc-2.5.so)
==25692==    by 0x41A15C: linux_write (linux.c:1599)
==25692==    by 0x40D9CA: ped_device_write (device.c:369)
==25692==    by 0x442B1E: bsd_write (bsd.c:368)
==25692==    by 0x411AD3: ped_disk_commit_to_dev (disk.c:485)
==25692==    by 0x411B19: ped_disk_commit (disk.c:508)
==25692==    by 0x403A12: do_mklabel (parted.c:622)
==25692==    by 0x402AF7: command_run (command.c:139)
==25692==    by 0x40B00A: non_interactive_mode (ui.c:1530)
==25692==    by 0x407A8B: main (parted.c:2479)
==25692==  Address 0x59E9C01 is 340 bytes inside a block of size 512 alloc'd
==25692==    at 0x4A1EC7C: memalign (vg_replace_malloc.c:332)
==25692==    by 0x4A1ECD5: posix_memalign (vg_replace_malloc.c:425)
==25692==    by 0x41A11A: linux_write (linux.c:1594)
==25692==    by 0x40D9CA: ped_device_write (device.c:369)
==25692==    by 0x442B1E: bsd_write (bsd.c:368)
==25692==    by 0x411AD3: ped_disk_commit_to_dev (disk.c:485)
==25692==    by 0x411B19: ped_disk_commit (disk.c:508)
==25692==    by 0x403A12: do_mklabel (parted.c:622)
==25692==    by 0x402AF7: command_run (command.c:139)
==25692==    by 0x40B00A: non_interactive_mode (ui.c:1530)
==25692==    by 0x407A8B: main (parted.c:2479)

17 years agoDon't leak a partition table buffer.
Jim Meyering [Thu, 31 May 2007 18:35:04 +0000 (20:35 +0200)]
Don't leak a partition table buffer.
* libparted/labels/rdb.c (amiga_read): Free the buffer upon success
as well as on failure.

17 years agoCorrect a misleading diagnostic.
Jim Meyering [Thu, 31 May 2007 08:31:11 +0000 (10:31 +0200)]
Correct a misleading diagnostic.

* libparted/disk.c (ped_disk_new): Remove always-false "Unable to open"
part of diagnostic.  Leave the "unrecognized disk label" part.

17 years agoFix build failure (conflicting decl of strnlen) and clean up
Jim Meyering [Thu, 31 May 2007 07:04:01 +0000 (09:04 +0200)]
Fix build failure (conflicting decl of strnlen) and clean up

* parted/strlist.h: Include <config.h> first.
[!ENABLE_NLS]: Define wchar_t to char here, too, since we no
longer include "strlist.h" after the definition in table.c.
* parted/table.c: Include <wchar.h> and <string.h> unconditionally,
and before wchar_t redefinition.
Hoist inclusions of xalloc.h and strlist.h, too.
Remove wcwidth and strnlen declarations, since they're guaranteed
to be in the gnulib-supplied-if-needed headers.

17 years agoRead an msdos partition table from a device with 2K sectors.
Jim Meyering [Wed, 30 May 2007 13:55:30 +0000 (15:55 +0200)]
Read an msdos partition table from a device with 2K sectors.

* libparted/labels/dos.c: Include <stdbool.h>.
(msdos_probe): Don't hard-code 512.
Use read_sector, not ped_device_read.
Adapt to changed type of "part_table".
Now that "label" is malloc'd, be sure to free it before returning.
(read_table): Likewise.

17 years agoFix "make distcheck" failure due to not finding usable partition
Jim Meyering [Wed, 30 May 2007 21:19:04 +0000 (23:19 +0200)]
Fix "make distcheck" failure due to not finding usable partition
* m4/o-direct.m4: Require that read as well as write succeed.
Require that both work with blocks of size 512 as well as 4096.
Reiserfs3 doesn't support 512-byte reads.
Allow the user running the test to specify the first directory
to test via the PARTED_TMPDIR envvar, in case none of the dirs
checked by default is usable.

17 years agoFix configure-with-nls vs. wchar.h/wcsdup problem differently.
Jim Meyering [Wed, 30 May 2007 13:40:50 +0000 (15:40 +0200)]
Fix configure-with-nls vs. wchar.h/wcsdup problem differently.
* parted/table.c: Include <config.h> *before* all other #include
directives.  Remove explicit declaration of wcsdup.  Now, we'll
get the one from <wchar.h>.

17 years agoparted/table.c: Fix a warning when compiling with translation support
Otavio Salvador [Wed, 30 May 2007 03:17:43 +0000 (00:17 -0300)]
parted/table.c: Fix a warning when compiling with translation support

,----[ Output when compiling with translation support ]
|...
| table.c: In function 'table_add_row_from_strlist':
| table.c:168: warning: implicit declaration of function 'wcsdup'
| table.c:168: warning: assignment makes pointer from integer without a cast
`----

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
17 years agofdasd label: Move formatting out of translatable strings.
Benno Schulenberg [Tue, 29 May 2007 18:02:25 +0000 (20:02 +0200)]
fdasd label: Move formatting out of translatable strings.

Also gettextize several missed messages, and simplify some of them.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
17 years agovtoc label: Move formatting out of translatable strings.
Benno Schulenberg [Tue, 29 May 2007 17:55:52 +0000 (19:55 +0200)]
vtoc label: Move formatting out of translatable strings.

Also gettextize a few missed messages, and remove some whitespace.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
17 years agoAvoid a leak.
Jim Meyering [Tue, 29 May 2007 19:30:40 +0000 (21:30 +0200)]
Avoid a leak.

* parted/parted.c (do_print): Use separate variables for the header
and for individual rows.  Free each when done.
* parted/table.c (table_add_row_from_strlist): Insert a newly
allocated copy of each string, so that the caller can free
the argument corresponding to the "list" parameter.
* tests/t0100-print.sh: New test for this.
* tests/Makefile.am (TESTS): Add t0100-print.sh.

17 years agoMove a test/utility function into test-lib.sh.
Jim Meyering [Tue, 29 May 2007 18:29:47 +0000 (20:29 +0200)]
Move a test/utility function into test-lib.sh.

* tests/t3000-constraints.sh (emit_superuser_warning): Move this
function to...
* tests/test-lib.sh (emit_superuser_warning): ...here.
* tests/t0000-basic.sh: Use the function instead of open-coding it.

Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoOn IRC, xeos reported test failures in t0000 and t2000
Jim Meyering [Tue, 29 May 2007 15:36:41 +0000 (17:36 +0200)]
On IRC, xeos reported test failures in t0000 and t2000
with diffs like this:

  -/home/xeos/projects/parted/parted/.libs/lt-parted: invalid token: msdos
  +parted: invalid token: msdos

Here's the patch I expect to apply.
It also removes an inter-part dependency by moving the creation
of the "o2" temporary file into the test where it's used.

Some of this duplication should be factored out, eventually...

17 years agoDiagnose invalid command arguments.
Jim Meyering [Sat, 26 May 2007 04:59:34 +0000 (06:59 +0200)]
Diagnose invalid command arguments.

This started because I objected to parted failing with no diagnostic
when given an invalid file system type:

    $ /sbin/parted -s $dev mklabel loop mkpartfs hfsplus 0 1.4
    WARNING: You are not superuser.  Watch out for permissions.
    [Exit 1]

With the changes below, it does this:

    $ ./parted -s $dev mklabel loop mkpartfs hfsplus 0 1.4
    ./parted: invalid token: hfsplus
    [Exit 1]

The following may look like a simple change, but looks are deceptive...
For example, if you try to diagnose via ped_exception_throw instead
of "error", you'll find that the mere fact of diagnosing the problem
introduces new ones because of how the exception handler manipulates the
global command line buffer containing the token we're complaining about.

But this isn't library code, so using error() is fine.

Diagnose invalid command arguments.
When a command argument doesn't match the expected candidate values,
parted would silently exit (in script mode) or simply act as if that
value and any following ones had not been specified (in interactive
mode).  With this change, it complains about the "invalid token",
and in script mode (where there hasn't been a prompt to give context)
sometimes tells what type of token it was expecting.
* parted/ui.c: Include "error.h".
(command_line_get_word): If the user's "token" wasn't a good enough
match, give a diagnostic.  In script mode, return NULL so that the
callers can give additional information.
* tests/t2000-mkfs.sh: New test for the above.
* tests/t0000-basic.sh: Expect the new diagnostic when "msdos" is
treated as an unrecognized first token after "mklabel".  This happens
when trying to label a disk that already has a label.
* tests/t1100-busy-label.sh: Likewise.

17 years agoUse xmalloc and xrealloc, rather than unchecked malloc and realloc.
Jim Meyering [Fri, 25 May 2007 17:40:56 +0000 (19:40 +0200)]
Use xmalloc and xrealloc, rather than unchecked malloc and realloc.
* parted/table.c: Use gnulib's xmalloc and realloc.
Remove anachronistic casts of malloc/realloc return value.
Change "sizeof(type)" to safer "sizeof(*var)" (one of the former
was wrong, but in a harmless way).

17 years agoFix off-by-one error in previous change.
Jim Meyering [Fri, 25 May 2007 17:13:28 +0000 (19:13 +0200)]
Fix off-by-one error in previous change.
* parted/strlist.c (str_list_print_wrap): Don't output a space unconditionally.

17 years agoRemove a silly (and dangerous) function.
Jim Meyering [Fri, 25 May 2007 16:45:39 +0000 (18:45 +0200)]
Remove a silly (and dangerous) function.

This change has no effect, except in a low-memory condition,
where the old code would dereference NULL, the new code no
longer performs that malloc.

* parted/strlist.c (get_spaces): Remove this function.
Not only is it useless, but it also has an unchecked malloc.
(str_list_print_wrap): Don't allocate and initialize a string
just to print a sequence of N spaces.

17 years agodoc/parted.texi (Static binaries): Correct an invalid example.
Jim Meyering [Fri, 25 May 2007 11:58:15 +0000 (13:58 +0200)]
doc/parted.texi (Static binaries): Correct an invalid example.
One cannot specify "primary" for a partition on a loop device.

17 years agoDiagnose "ext2 FS too small" rather than triggering an assertion.
Jim Meyering [Thu, 24 May 2007 18:00:22 +0000 (20:00 +0200)]
Diagnose "ext2 FS too small" rather than triggering an assertion.
* libparted/fs/ext2/ext2_mkfs.c (ext2_mkfs): An overlapping ext2
partition request could still lead to a bug: constraint-resolution
code would produce a single-sector candidate "range", and that
would cause the ext2 fs-creation code to misbehave.  Now, it
properly detects and reports the FS as being too small.
* tests/t3000-constraints.sh: New test for the above.
* tests/Makefile.am (TESTS): Add t3000-constraints.sh.

17 years agoFix typo in privs-required test setup.
Jim Meyering [Thu, 24 May 2007 16:21:43 +0000 (18:21 +0200)]
Fix typo in privs-required test setup.
* tests/test-lib.sh: Fix typo: s/\$parted/$parted_/.

17 years agoDon't fail all tests when "." lacks O_DIRECT support.
Jim Meyering [Wed, 23 May 2007 20:28:53 +0000 (22:28 +0200)]
Don't fail all tests when "." lacks O_DIRECT support.

I often build tools on a tmpfs file system (it's faster), and
found that parted tests always failed there.  That's because it tries
to open the "device" (a file) with O_DIRECT, and at least the linux tmpfs
driver always fails with EINVAL in that case.

So here's a patch that makes it work.
Since the test may require writing in a directory like /tmp,
to which others typically have write access, it is particularly
careful about security (see the mkdtemp script below), in case
"make check" is run by e.g., root.

Don't fail all tests when "." lacks O_DIRECT support.
Before, running "make check" on a file system that doesn't support
O_DIRECT (e.g. tmpfs), would always fail.  Now, it works, as long as
the test machinery can find a writable directory in which open with
O_DIRECT *does* work.
* m4/o-direct.m4: New file.  Find a directory/FS with O_DIRECT support.
* configure.ac: Use the new macro.
* libparted/tests/t1000-label.sh: New file.  Wrap the binary, so
it can take advantage of the code that finds O_DIRECT supporting FS.
* tests/mkdtemp: New file.  Required, since when running tests as
root, we may have to create a temporary directory in a directory
like /tmp that's writable by others.
* tests/Makefile.am (EXTRA_DIST): Add mkdtemp.
* tests/test-lib.sh: When creating test subdir, and setting up "trap",
use the directory specified in $PARTED_USABLE_TEST_DIR.
Don't set PATH here.  Now, that's done via the generated, and always-
sourced, init.sh.  As a result, invoke parted via its full file name.

17 years agoMake all tests get their initialization from the same place.
Jim Meyering [Sat, 19 May 2007 09:10:20 +0000 (11:10 +0200)]
Make all tests get their initialization from the same place.
* tests/t2000-mkfs.sh: Get initialization via ". ./init.sh",
not via ". ./test-lib.sh".
* Makefile.maint (sc_test_init): New test, to ensure we stay consistent.

17 years ago* tests/Makefile.am (init.sh): Make this generated file read-only.
Jim Meyering [Sat, 19 May 2007 06:49:40 +0000 (08:49 +0200)]
* tests/Makefile.am (init.sh): Make this generated file read-only.

17 years agomkpartfs ext2 2 10 would erroneously report "file system too small"
Jim Meyering [Fri, 18 May 2007 13:52:00 +0000 (15:52 +0200)]
mkpartfs ext2 2 10 would erroneously report "file system too small"
for some small (single-group) partitions.  It would also fail to
report "file system too small" in some cases, and instead continue
on to into inode-allocation code where it'd report "File system full!"
* libparted/fs/ext2/ext2_mkfs.c (compute_block_counts): New function,
factored out of...
(ext2_mkfs): ...here.  Call compute_block_counts rather than
open-coded it.  When decrementing numblocks, call compute_block_counts
again, to recompute all of the derived values.
Require at least 14 free blocks in a 16-inode-per-group partition.
* tests/t1500-small-ext2.sh: New file.  Test for the above.
* tests/Makefile.am (TESTS): Add t1500-small-ext2.sh.

17 years agoAvoid spurious test failures due to buggy ncurses-5.6.
Jim Meyering [Thu, 17 May 2007 11:21:00 +0000 (13:21 +0200)]
Avoid spurious test failures due to buggy ncurses-5.6.
* tests/test-lib.sh: Also unset TERM.

17 years agopartprobe: new option: --dry-run, synonym for now-deprecated --no-update; improve...
Benno Schulenberg [Wed, 16 May 2007 20:28:35 +0000 (22:28 +0200)]
partprobe: new option: --dry-run, synonym for now-deprecated --no-update; improve its description

17 years agoTest commit
Anant Narayanan [Wed, 16 May 2007 02:56:37 +0000 (08:26 +0530)]
Test commit

17 years agoRemoved clean.sh script. Using git now, we don't need it anymore (git clean -d -x).
David Cantrell [Wed, 9 May 2007 20:45:38 +0000 (16:45 -0400)]
Removed clean.sh script. Using git now, we don't need it anymore (git clean -d -x).

17 years agoUse gnulib xmalloc() and xrealloc().
David Cantrell [Wed, 9 May 2007 19:15:47 +0000 (15:15 -0400)]
Use gnulib xmalloc() and xrealloc().

17 years agoFix exception handling in mkpart and mkpartfs
Flavio Leitner [Mon, 14 May 2007 10:04:18 +0000 (12:04 +0200)]
Fix exception handling in mkpart and mkpartfs

Parted mkpart and mkpartfs commands does:
...
   ped_exception_fetch_all();
   if (!ped_disk_add_partition (disk, part, final_constraint)) {
 ped_exception_leave_all();
...
   }
...
In mkpart if the ped_disk_add_partition() returns true it skips
ped_exception_leave_all() leaving ex_fetch_count = 1.

In mkpartfs if the ped_disk_add_partition() returns false it will
call ped_exception_leave_all() leaving ex_fetch_count negative.

The wrong count in ex_fetch_count will prevent next commands to
correctly handle exceptions, failing to prompt users for example.

Note: test script t2000-mkfs.sh improved to verify against this issue.

Signed-off-by: Flavio Leitner <flavio.leitner@gmail.com>
Signed-off-by: Jim Meyering <jim@meyering.net>
17 years ago* tests/t1100-busy-label.sh: Quote uses of $dev, in case
Jim Meyering [Fri, 11 May 2007 17:15:05 +0000 (19:15 +0200)]
* tests/t1100-busy-label.sh: Quote uses of $dev, in case
the user's device name contains a shell meta-character.

SCALAR(0x7f6040)

17 years agoWhen labeling a disk in --script mode, fail if it is in use.
Jim Meyering [Fri, 11 May 2007 15:27:47 +0000 (17:27 +0200)]
When labeling a disk in --script mode, fail if it is in use.
* parted/parted.c (_disk_warn_busy): In script mode,
throw a "PED_EXCEPTION_ERROR", not a warning.
(do_mklabel): Guard only the _disk_warn_loss call with
"if (!opt_script_mode...", not the _disk_warn_loss call.
* tests/t1100-busy-label.sh: New file.  Test the above,
in interactive mode as well as in script mode.  Requires
root privilege (to mount a fs), and an actual block device.
* tests/Makefile.am (TESTS): Add t1100-busy-label.sh.
* tests/test-lib.sh: Add infrastructure to support new
privileges_required_=1 and erasable_device_required_=1
settings used by t1100.

17 years agoNo longer require "srcdir=." when running a test manually.
Jim Meyering [Fri, 11 May 2007 15:20:09 +0000 (17:20 +0200)]
No longer require "srcdir=." when running a test manually.
* tests/Makefile.am (init.sh): New rule, so one doesn't have to
set "srcdir=." when running a test manually.
* .gitignore: Ignore new generated file: tests/init.sh.
* tests/t0000-basic.sh: Source new init.sh, rather than test-lib.sh.
* tests/t1000-mkpartfs.sh: Likewise.
* tests/t2000-mkfs.sh: Likewise.
* tests/test-lib.sh: Remove useless srcdir-setting code.

17 years ago[parted] Fix script mode support on mkfs commandline command
Otavio Salvador [Wed, 9 May 2007 19:03:39 +0000 (16:03 -0300)]
[parted] Fix script mode support on mkfs commandline command

Parted was lacking support to script mode on do_mkfs method hence
always failing.

Note: tests/t2000-mkfs.sh was created to avoid it to happen again

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
17 years agoPreventing compilation of DASD code on GNU Hurd systems through the use of AC_COMPILE...
Debarshi Ray [Tue, 8 May 2007 17:35:23 +0000 (23:05 +0530)]
Preventing compilation of DASD code on GNU Hurd systems through the use of AC_COMPILE_IFELSE and AM_CONDITIONAL, instead of #ifdef.

17 years agoRewrite integration tests to use a new framework (git's).
Jim Meyering [Mon, 7 May 2007 16:42:38 +0000 (18:42 +0200)]
Rewrite integration tests to use a new framework (git's).
* tests/t1000-mkpartfs.sh: New file.
* tests/t0000-basic.sh: New file.
* tests/test-lib.sh: New file.  Derived from git's t/test-lib.sh.
* tests/lang-default, tests/priv-check: Remove files.
* tests/Makefile.am (EXTRA_DIST): Add test-lib.sh.
Remove lang-default and priv-check; no longer used.
* tests/part-01, tests/label-01: Remove files.
* tests/part-02, tests/label-02: Likewise.

17 years agoMerge branch 'inhibit-word-wrap'
Jim Meyering [Mon, 7 May 2007 15:09:37 +0000 (17:09 +0200)]
Merge branch 'inhibit-word-wrap'

17 years agoMerge branch 'include-limits-h-for-CHAR_MAX'
Jim Meyering [Mon, 7 May 2007 15:05:31 +0000 (17:05 +0200)]
Merge branch 'include-limits-h-for-CHAR_MAX'

17 years agoMake ---pretend-input-tty inhibit output word-wrap.
Jim Meyering [Mon, 7 May 2007 14:51:29 +0000 (16:51 +0200)]
Make ---pretend-input-tty inhibit output word-wrap.
* parted/ui.c (screen_width): Use effectively-unlimited screen width
with ---pretend-input-tty, just as for '--script' mode.

17 years agoSuppress "you are not superuser..." warning in script mode.
Jim Meyering [Mon, 7 May 2007 14:45:27 +0000 (16:45 +0200)]
Suppress "you are not superuser..." warning in script mode.
* parted/parted.c (_init): Do not emit this warning in script mode:
"You are not superuser.  Watch out for permissions."

17 years agoAvoid "make distcheck" failure, with newer system headers.
Jim Meyering [Mon, 7 May 2007 14:38:00 +0000 (16:38 +0200)]
Avoid "make distcheck" failure, with newer system headers.
* parted/parted.c: Include <limits.h>, for use of CHAR_MAX.

17 years agoUpdated Doxyfile
Anant Narayanan [Thu, 3 May 2007 23:39:52 +0000 (05:09 +0530)]
Updated Doxyfile

17 years agoOn the edge branch, labeled the version as 1.9.0 so we can mark it more correctly...
David Cantrell [Wed, 2 May 2007 18:22:28 +0000 (14:22 -0400)]
On the edge branch, labeled the version as 1.9.0 so we can mark it more correctly as the development tree.

17 years agoWhitespace cleanups.
David Cantrell [Mon, 30 Apr 2007 13:44:24 +0000 (09:44 -0400)]
Whitespace cleanups.

17 years agoWhitespace cleanups.
David Cantrell [Mon, 30 Apr 2007 13:42:33 +0000 (09:42 -0400)]
Whitespace cleanups.

17 years agoWhitespace cleanups.
David Cantrell [Mon, 30 Apr 2007 13:22:44 +0000 (09:22 -0400)]
Whitespace cleanups.

17 years agoWhitespace cleanups.
David Cantrell [Mon, 30 Apr 2007 13:21:48 +0000 (09:21 -0400)]
Whitespace cleanups.

17 years agoRevert "Remove unused label."
David Cantrell [Mon, 23 Apr 2007 20:41:02 +0000 (16:41 -0400)]
Revert "Remove unused label."

This reverts commit bfd9a6d8b6322d870650b0e92bd936035ab28e76.

17 years agoPatch from Jim Meyering <jim@meyering.net> to linux_write() to support logical
David Cantrell [Mon, 23 Apr 2007 20:25:11 +0000 (16:25 -0400)]
Patch from Jim Meyering <jim@meyering.net> to linux_write() to support logical

sector sizes other than 512 (PED_SECTOR_SIZE_DEFAULT).

17 years agoFix primary partition cylinder alignment error for DOS disk labels.
David Cantrell [Mon, 23 Apr 2007 20:02:13 +0000 (16:02 -0400)]
Fix primary partition cylinder alignment error for DOS disk labels.

17 years agoFix off-by-one bug in parted when displaying information about the disk label (the...
David Cantrell [Mon, 23 Apr 2007 20:00:54 +0000 (16:00 -0400)]
Fix off-by-one bug in parted when displaying information about the disk label (the disk size, specifically).

17 years agoDo not translate partition names in 'parted print' command. This causes problems...
David Cantrell [Mon, 23 Apr 2007 19:58:03 +0000 (15:58 -0400)]
Do not translate partition names in 'parted print' command. This causes problems for non-Latin-based character sets. Also, we don't want to translate the partition name here as we are just showing what is in the disklabel, translating it distorts what the value is.

Also added some malloc checks in table.c.

17 years agoRemove unused label.
David Cantrell [Mon, 23 Apr 2007 19:53:48 +0000 (15:53 -0400)]
Remove unused label.

17 years agoReverted my patch to configure.ac to remove -Wl,--as-needed from LDFLAGS when checkin...
David Cantrell [Thu, 15 Mar 2007 16:53:35 +0000 (12:53 -0400)]
Reverted my patch to configure.ac to remove -Wl,--as-needed from LDFLAGS when checking for libreadline.

17 years agolibreadline is a problematic library. Autoconf adds a block to the generated configur...
David Cantrell [Wed, 14 Mar 2007 18:55:49 +0000 (14:55 -0400)]
libreadline is a problematic library. Autoconf adds a block to the generated configure script that checks to see if we should be passing the --as-needed flag to ld(1). There are portability reasons this code exists (best I can figure), but it presents a problem when we scan for libreadline.

libreadline specifically has unresolved symbols on at least Fedora and RHEL.  Why?  Well, the developer can choose to provide libtermcap, libncurses, or libncursesw (wide-char support) at compile time which all satisfy the curses API dependency that libreadline has.  When the parted configure script runs, it fails on readline because the --as-needed flag causes the linker to not include libncurses even though we already have that on the link line.

My solution is to remove the --as-needed flag when we scan for libreadline and then later check for rl_completion_matches() in libreadline.

17 years agoMore changes to set the version number to 1.8.3.
David Cantrell [Tue, 13 Mar 2007 19:05:53 +0000 (15:05 -0400)]
More changes to set the version number to 1.8.3.

17 years agoSet version to 1.8.3 for upcoming release.
David Cantrell [Tue, 13 Mar 2007 17:03:02 +0000 (13:03 -0400)]
Set version to 1.8.3 for upcoming release.