mkfs-util: add support for making vfat partitions
fat is a bit more limited in volume name length and UUID support. Let's add some special support for it. This is particularly useful to generate EFI system partitions.
This commit is contained in:
parent
53171c0453
commit
0f2b2c483f
|
@ -4,6 +4,7 @@
|
|||
#include "mkfs-util.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
int mkfs_exists(const char *fstype) {
|
||||
|
@ -94,6 +95,26 @@ int make_filesystem(
|
|||
else
|
||||
(void) execlp(mkfs, mkfs, "-L", label, "-m", j, "-m", "reflink=1", "-K", node, NULL);
|
||||
|
||||
} else if (streq(fstype, "vfat")) {
|
||||
char mangled_label[8 + 3 + 1], vol_id[8 + 1];
|
||||
|
||||
/* Classic FAT only allows 11 character uppercase labels */
|
||||
strncpy(mangled_label, label, sizeof(mangled_label)-1);
|
||||
mangled_label[sizeof(mangled_label)-1] = 0;
|
||||
ascii_strupper(mangled_label);
|
||||
|
||||
xsprintf(vol_id, "%08" PRIx32,
|
||||
((uint32_t) uuid.bytes[0] << 24) |
|
||||
((uint32_t) uuid.bytes[1] << 16) |
|
||||
((uint32_t) uuid.bytes[2] << 8) |
|
||||
((uint32_t) uuid.bytes[3])); /* Take first 32 byte of UUID */
|
||||
|
||||
(void) execlp(mkfs, mkfs,
|
||||
"-i", vol_id,
|
||||
"-n", mangled_label,
|
||||
"-F", "32", /* yes, we force FAT32 here */
|
||||
node, NULL);
|
||||
|
||||
} else if (streq(fstype, "swap")) {
|
||||
|
||||
(void) execlp(mkfs, mkfs,
|
||||
|
|
Loading…
Reference in New Issue