summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2019-10-30 16:04:36 +0000
committerGitHub <noreply@github.com>2019-10-30 16:04:36 +0000
commit480f1ff16f20d4621bc3848dfa972b5c0ada6a94 (patch)
tree38185326fd3b88921c3d5a101374bcc797d197aa
parent7a925658cf087cddd20852449e20002bfbd52774 (diff)
parent516f37144fc43eb40c051af1482a81399bbdd24d (diff)
downloadgenimage-480f1ff16f20d4621bc3848dfa972b5c0ada6a94.tar.gz
genimage-480f1ff16f20d4621bc3848dfa972b5c0ada6a94.tar.xz
Merge pull request #78 from fviard/add_label_to_vfat
image-vfat: Add label option to set vfat volume name.
-rw-r--r--README.rst1
-rw-r--r--image-vfat.c18
2 files changed, 17 insertions, 2 deletions
diff --git a/README.rst b/README.rst
index e6ecd97..6993de3 100644
--- a/README.rst
+++ b/README.rst
@@ -303,6 +303,7 @@ Generates a VFAT image.
Options:
:extraargs: Extra arguments passed to mkdosfs
+:label: Specify the volume-label. Passed to the ``-n`` option of mkdosfs
:file: Specify a file to be added into the filesystem image. Usage is:
``file foo { image = "bar" }`` which adds a file "foo" in the
filesystem image from the input file "bar"
diff --git a/image-vfat.c b/image-vfat.c
index d3f7bdb..026e1a2 100644
--- a/image-vfat.c
+++ b/image-vfat.c
@@ -27,14 +27,20 @@ static int vfat_generate(struct image *image)
int ret;
struct partition *part;
char *extraargs = cfg_getstr(image->imagesec, "extraargs");
+ char *label = cfg_getstr(image->imagesec, "label");
+
+ if (label && label[0] != '\0')
+ xasprintf(&label, "-n '%s'", label);
+ else
+ label = "";
ret = systemp(image, "%s if=/dev/zero of=\"%s\" seek=%lld count=0 bs=1 2>/dev/null",
get_opt("dd"), imageoutfile(image), image->size);
if (ret)
return ret;
- ret = systemp(image, "%s %s '%s'", get_opt("mkdosfs"),
- extraargs, imageoutfile(image));
+ ret = systemp(image, "%s %s %s '%s'", get_opt("mkdosfs"),
+ extraargs, label, imageoutfile(image));
if (ret)
return ret;
@@ -73,11 +79,18 @@ static int vfat_generate(struct image *image)
static int vfat_setup(struct image *image, cfg_t *cfg)
{
+ char *label = cfg_getstr(image->imagesec, "label");
+
if (!image->size) {
image_error(image, "no size given or must not be zero\n");
return -EINVAL;
}
+ if (label && strlen(label) > 11) {
+ image_error(image, "vfat volume name cannot be longer than 11 characters\n");
+ return -EINVAL;
+ }
+
return 0;
}
@@ -113,6 +126,7 @@ static cfg_opt_t file_opts[] = {
static cfg_opt_t vfat_opts[] = {
CFG_STR("extraargs", "", CFGF_NONE),
+ CFG_STR("label", "", CFGF_NONE),
CFG_STR_LIST("files", 0, CFGF_NONE),
CFG_SEC("file", file_opts, CFGF_MULTI | CFGF_TITLE),
CFG_END()