Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/layout-config-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,20 @@ options:
``filesystem`` (string)
The filesystem type to use during formatting of the partition.

It is possible to set ``filesystem`` to ``null``. This is useful for writing
raw images -- already containing a filesystem -- directly to a partition. For
additional information see :ref:`supported-file-types`.

When no filesystem is specified, the default is ``null``.

.. note::

Versions prior to partup :ref:`release-4.0.0` used ``fat32`` as the
default filesystem.

The following filesystems are currently supported:

- ``null`` (default)
- ``ext2``
- ``ext3``
- ``ext4``
Expand Down Expand Up @@ -336,6 +348,8 @@ at least a ``filename``. For verifying the checksum of the given input file by
checked against the provided file before writing to the target partition or
volume.

.. _supported-file-types:

Supported File Types
....................

Expand Down
2 changes: 1 addition & 1 deletion src/pu-emmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ pu_emmc_parse_partitions(PuEmmc *emmc,
PuEmmcPartition *part = g_new0(PuEmmcPartition, 1);
part->label = pu_hash_table_lookup_string(v->data.mapping, "label", NULL);
part->partuuid = pu_hash_table_lookup_string(v->data.mapping, "partuuid", "");
part->filesystem = pu_hash_table_lookup_string(v->data.mapping, "filesystem", "fat32");
part->filesystem = pu_hash_table_lookup_string(v->data.mapping, "filesystem", NULL);
part->mkfs_extra_args = pu_hash_table_lookup_string(v->data.mapping, "mkfs-extra-args", NULL);
part->size = pu_hash_table_lookup_sector(v->data.mapping, emmc->device, "size", 0);
part->offset = pu_hash_table_lookup_sector(v->data.mapping, emmc->device, "offset", 0);
Expand Down
25 changes: 25 additions & 0 deletions tests/config/gpt-partition-filesystem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
api-version: 1
disklabel: gpt

partitions:
- label: DEFAULT
offset: 1MiB
expand: true
- label: "NULL"
filesystem: null
expand: true
- label: FAT16
filesystem: fat16
expand: true
- label: FAT32
filesystem: fat32
expand: true
- label: EXT2
filesystem: ext2
expand: true
- label: EXT3
filesystem: ext3
expand: true
- label: EXT4
filesystem: ext4
expand: true
70 changes: 68 additions & 2 deletions tests/emmc-root.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#include "pu-error.h"
#include "pu-utils.h"

static gboolean check_partition_alignment(PedDevice *dev,
PedAlignment *alignment)
static gboolean
check_partition_alignment(PedDevice *dev,
PedAlignment *alignment)
{
PedDisk *disk;
PedPartition *part;
Expand Down Expand Up @@ -42,6 +43,37 @@ static gboolean check_partition_alignment(PedDevice *dev,
return TRUE;
}

static gboolean
check_partition_fstype(PedDevice *dev,
int part_idx,
const gchar *name)
{
PedDisk *disk;
PedPartition *part;
gboolean is_correct_fstype = FALSE;

disk = ped_disk_new(dev);
if (disk == NULL) {
return FALSE;
}

part = ped_disk_get_partition(disk, part_idx);
if (part == NULL) {
return FALSE;
}

if (!part->fs_type) {
if (!name) {
is_correct_fstype = TRUE;
}
} else if (g_str_equal(part->fs_type->name, name)) {
is_correct_fstype = TRUE;
}

ped_disk_destroy(disk);
return is_correct_fstype;
}

static void
test_emmc_align_minimal(EmptyDeviceFixture *fixture,
G_GNUC_UNUSED gconstpointer user_data)
Expand Down Expand Up @@ -88,6 +120,37 @@ test_emmc_align_optimal(EmptyDeviceFixture *fixture,
g_assert_true(check_partition_alignment(dev, pu_emmc_get_alignment(emmc)));
}

static void
test_partition_filesystem(EmptyDeviceFixture *fixture,
G_GNUC_UNUSED gconstpointer user_data)
{
g_autoptr(PuConfig) config = NULL;
g_autoptr(PuEmmc) emmc = NULL;
PedDevice *dev = NULL;

config = pu_config_new_from_file("config/gpt-partition-filesystem.yaml",
&fixture->error);
g_assert_nonnull(config);

emmc = pu_emmc_new(fixture->loop_dev, config, "data", FALSE, &fixture->error);
g_assert_nonnull(emmc);

g_assert_true(pu_flash_init_device(PU_FLASH(emmc), &fixture->error));
g_assert_true(pu_flash_setup_layout(PU_FLASH(emmc), &fixture->error));
g_assert_true(pu_flash_write_data(PU_FLASH(emmc), &fixture->error));

dev = ped_device_get(fixture->loop_dev);
g_assert_nonnull(dev);
/* The default for "filesystem" should be "null", as per the documentation */
g_assert_true(check_partition_fstype(dev, 1, NULL));
g_assert_true(check_partition_fstype(dev, 2, NULL));
g_assert_true(check_partition_fstype(dev, 3, "fat16"));
g_assert_true(check_partition_fstype(dev, 4, "fat32"));
g_assert_true(check_partition_fstype(dev, 5, "ext2"));
g_assert_true(check_partition_fstype(dev, 6, "ext3"));
g_assert_true(check_partition_fstype(dev, 7, "ext4"));
}

int
main(int argc,
char *argv[])
Expand All @@ -106,6 +169,9 @@ main(int argc,
test_emmc_align_minimal, empty_device_tear_down);
g_test_add("/emmc/align_optimal", EmptyDeviceFixture, NULL, empty_device_set_up,
test_emmc_align_optimal, empty_device_tear_down);
g_test_add("/emmc/partition_filesystem", EmptyDeviceFixture, NULL,
empty_device_set_up, test_partition_filesystem,
empty_device_tear_down);

return g_test_run();
}
Loading