2011-06-27 15:58:21 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2015-02-09 00:26:29 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-06-27 15:58:21 +08:00
|
|
|
*/
|
|
|
|
|
2011-06-27 14:39:51 +08:00
|
|
|
#include <confuse.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2011-06-30 01:58:08 +08:00
|
|
|
#include <errno.h>
|
2011-06-27 14:39:51 +08:00
|
|
|
|
|
|
|
#include "genimage.h"
|
|
|
|
|
|
|
|
static int ubifs_generate(struct image *image)
|
|
|
|
{
|
2013-04-16 20:19:45 +08:00
|
|
|
int max_leb_cnt;
|
2011-06-27 14:39:51 +08:00
|
|
|
int ret;
|
|
|
|
char *extraargs = cfg_getstr(image->imagesec, "extraargs");
|
2013-04-16 20:19:45 +08:00
|
|
|
unsigned long long max_size = cfg_getint_suffix(image->imagesec, "max-size");
|
2024-02-16 01:11:23 +08:00
|
|
|
cfg_bool_t space_fixup = cfg_getbool(image->imagesec, "space-fixup");
|
2011-06-27 14:39:51 +08:00
|
|
|
|
2013-04-16 20:19:45 +08:00
|
|
|
if (max_size)
|
2013-05-02 05:55:45 +08:00
|
|
|
max_leb_cnt = max_size / image->flash_type->lebsize;
|
2013-04-16 20:19:45 +08:00
|
|
|
else
|
|
|
|
max_leb_cnt = image->size / image->flash_type->lebsize;
|
2011-06-27 14:39:51 +08:00
|
|
|
|
2024-02-16 01:11:23 +08:00
|
|
|
ret = systemp(image, "%s %s%s%s %s -e %d -m %d -c %d -o '%s' %s",
|
2011-06-27 14:39:51 +08:00
|
|
|
get_opt("mkfsubifs"),
|
2019-09-21 18:20:03 +08:00
|
|
|
image->empty ? "" : "-d '",
|
|
|
|
image->empty ? "" : mountpath(image),
|
|
|
|
image->empty ? "" : "'",
|
2024-02-16 01:11:23 +08:00
|
|
|
space_fixup ? "-F" : "",
|
2011-06-27 14:39:51 +08:00
|
|
|
image->flash_type->lebsize,
|
|
|
|
image->flash_type->minimum_io_unit_size,
|
2013-04-16 20:19:45 +08:00
|
|
|
max_leb_cnt,
|
2011-06-27 15:55:09 +08:00
|
|
|
imageoutfile(image),
|
2011-06-27 14:39:51 +08:00
|
|
|
extraargs);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ubifs_setup(struct image *image, cfg_t *cfg)
|
|
|
|
{
|
2011-06-30 01:58:08 +08:00
|
|
|
if (!image->flash_type) {
|
|
|
|
image_error(image, "no flash type given\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2019-09-22 23:38:27 +08:00
|
|
|
if (image->flash_type->lebsize <= 0) {
|
|
|
|
image_error(image, "invalid lebsize (%d) in %s\n",
|
|
|
|
image->flash_type->lebsize, image->flash_type->name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2011-06-30 01:58:08 +08:00
|
|
|
|
2011-06-27 14:39:51 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cfg_opt_t ubifs_opts[] = {
|
|
|
|
CFG_STR("extraargs", "", CFGF_NONE),
|
2013-04-16 20:19:45 +08:00
|
|
|
CFG_STR("max-size", NULL, CFGF_NONE),
|
2024-02-16 01:11:23 +08:00
|
|
|
CFG_BOOL("space-fixup", 0, CFGF_NONE),
|
2011-06-27 14:39:51 +08:00
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
|
|
|
|
struct image_handler ubifs_handler = {
|
|
|
|
.type = "ubifs",
|
|
|
|
.generate = ubifs_generate,
|
|
|
|
.setup = ubifs_setup,
|
|
|
|
.opts = ubifs_opts,
|
|
|
|
};
|
|
|
|
|