From 7a84746d5c71d4dcb651742c08b97f4669b8d80d Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 22 Oct 2009 23:43:35 +0200 Subject: [PATCH 3/3] =?utf-8?q?Bug=2024673=20=E2=80=94=20support=20creating=20swap=20fs=20with=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit mkswapfs supports labels just fine, add support for it to FilesystemCreate(). --- src/devkit-disks-daemon.c | 2 +- src/job-mkfs.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/devkit-disks-daemon.c b/src/devkit-disks-daemon.c index 777786a..324bea6 100644 --- a/src/devkit-disks-daemon.c +++ b/src/devkit-disks-daemon.c @@ -334,7 +334,7 @@ static const DevkitDisksFilesystem known_file_systems[] = { FALSE, /* supports_unix_owners */ FALSE, /* can_mount */ TRUE, /* can_create */ - 0, /* max_label_len (TODO: not actually true for new style swap areas) */ + 15, /* max_label_len */ FALSE, /* supports_label_rename */ FALSE, /* supports_online_label_rename*/ FALSE, /* supports_fsck */ diff --git a/src/job-mkfs.c b/src/job-mkfs.c index 7b5854a..af6236a 100644 --- a/src/job-mkfs.c +++ b/src/job-mkfs.c @@ -229,8 +229,19 @@ main (int argc, char **argv) s = g_string_new ("mkswap"); for (n = 0; options[n] != NULL; n++) { - g_printerr ("option %s not supported\n", options[n]); - goto out; + if (g_str_has_prefix (options[n], "label=")) { + label = strdup (options[n] + sizeof ("label=") - 1); + if (!validate_and_escape_label (&label, 15)) { + g_string_free (s, TRUE); + goto out; + } + g_string_append_printf (s, " -L \"%s\"", label); + g_free (label); + label = NULL; + } else { + g_printerr ("option %s not supported\n", options[n]); + goto out; + } } g_string_append_printf (s, " %s", device); command_line = g_string_free (s, FALSE); -- 1.6.3.3