From: Lennart Poettering Date: Mon, 2 Jun 2025 08:12:10 +0000 (+0200) Subject: repart: fix generation of UUID= line for vfat in fstab entries X-Git-Tag: v258-rc1~422^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8504721e0e758aadf454141de014fe28d14cefcd;p=thirdparty%2Fsystemd.git repart: fix generation of UUID= line for vfat in fstab entries Fixes: #36735 --- diff --git a/src/repart/repart.c b/src/repart/repart.c index 3f8b24158b5..b8dff34b814 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -7587,6 +7587,29 @@ static bool need_fstab(const Context *context) { return false; } +static int make_by_uuid_symlink_path(const Partition *p, char **ret) { + _cleanup_free_ char *what = NULL; + + assert(p); + assert(ret); + + if (streq_ptr(p->format, "vfat")) { + if (asprintf(&what, "UUID=%04X-%04X", + ((uint32_t) p->fs_uuid.bytes[0] << 8) | + ((uint32_t) p->fs_uuid.bytes[1] << 0), + ((uint32_t) p->fs_uuid.bytes[2] << 8) | + ((uint32_t) p->fs_uuid.bytes[3])) < 0) /* Take first 32 bytes of UUID */ + return log_oom(); + } else { + what = strjoin("UUID=", SD_ID128_TO_UUID_STRING(p->fs_uuid)); + if (!what) + return log_oom(); + } + + *ret = TAKE_PTR(what); + return 0; +} + static int context_fstab(Context *context) { _cleanup_(unlink_and_freep) char *t = NULL; _cleanup_fclose_ FILE *f = NULL; @@ -7620,9 +7643,9 @@ static int context_fstab(Context *context) { if (!need_fstab_one(p)) continue; - what = strjoin("UUID=", SD_ID128_TO_UUID_STRING(p->fs_uuid)); - if (!what) - return log_oom(); + r = make_by_uuid_symlink_path(p, &what); + if (r < 0) + return r; FOREACH_ARRAY(mountpoint, p->mountpoints, p->n_mountpoints) { r = partition_pick_mount_options(