* 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.
}
char*
-_create_disk (const off_t size)
+_create_disk (const off_t n_bytes)
{
char* filename = strdup ("parted-test-XXXXXX");
if (disk == NULL)
goto free_filename;
- off_t total_size = size * 1024 * 1024; /* Mb */
-
- int fail = (fseek (disk, total_size, SEEK_SET) != 0
+ int fail = (fseek (disk, n_bytes, SEEK_SET) != 0
|| fwrite ("", sizeof (char), 1, disk) != 1);
if (fclose (disk) != 0 || fail)
#include "common.h"
#include "progname.h"
+#include "xstrtol.h"
static char* temporary_disk;
+static
+size_t get_sector_size (void)
+{
+ char *p = getenv ("PARTED_SECTOR_SIZE");
+ size_t ss = 512;
+ unsigned long val;
+ if (p
+ && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
+ && val % 512 == 0)
+ ss = val;
+
+ return ss;
+}
+
static void
create_disk (void)
{
- temporary_disk = _create_disk (20);
+ temporary_disk = _create_disk (get_sector_size () * 4 * 10 * 1024);
fail_if (temporary_disk == NULL, "Failed to create temporary disk");
}
static void
create_disk (void)
{
- temporary_disk = _create_disk (20);
+ temporary_disk = _create_disk (20 * 1024 * 1024);
fail_if (temporary_disk == NULL, "Failed to create temporary disk");
}
# libparted
-# Copyright (C) 1999-2001, 2006-2007, 2009 Free Software Foundation, Inc.
+# Copyright (C) 1999-2001, 2006-2009 Free Software Foundation, Inc.
# This file may be modified and/or copied without restriction.
# list of files containing translatable strings