From 698bb074a316015bd9ec7529a2781422004fe6c8 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 19 Sep 2022 20:30:29 +0900 Subject: [PATCH] dissect-image: split-out dissected_image_probe_filesystem() No functional changes, just preparation for later commits. --- src/shared/dissect-image.c | 57 +++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 2ea053e009..cc5cee0451 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -126,6 +126,38 @@ not_found: } #if HAVE_BLKID +static int dissected_image_probe_filesystem(DissectedImage *m) { + int r; + + assert(m); + + /* Fill in file system types if we don't know them yet. */ + + for (PartitionDesignator i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) { + DissectedPartition *p = m->partitions + i; + + if (!p->found) + continue; + + if (!p->fstype && p->node) { + r = probe_filesystem(p->node, &p->fstype); + if (r < 0 && r != -EUCLEAN) + return r; + } + + if (streq_ptr(p->fstype, "crypto_LUKS")) + m->encrypted = true; + + if (p->fstype && fstype_is_ro(p->fstype)) + p->rw = false; + + if (!p->rw) + p->growfs = false; + } + + return 0; +} + static void check_partition_flags( const char *node, unsigned long long pflags, @@ -1108,28 +1140,9 @@ int dissect_image( blkid_free_probe(b); b = NULL; - /* Fill in file system types if we don't know them yet. */ - for (PartitionDesignator i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) { - DissectedPartition *p = m->partitions + i; - - if (!p->found) - continue; - - if (!p->fstype && p->node) { - r = probe_filesystem(p->node, &p->fstype); - if (r < 0 && r != -EUCLEAN) - return r; - } - - if (streq_ptr(p->fstype, "crypto_LUKS")) - m->encrypted = true; - - if (p->fstype && fstype_is_ro(p->fstype)) - p->rw = false; - - if (!p->rw) - p->growfs = false; - } + r = dissected_image_probe_filesystem(m); + if (r < 0) + return r; *ret = TAKE_PTR(m); return 0; -- 2.25.1