On Mon, Jun 27, 2016 at 01:42:19PM +0200, Teresa Remmet wrote: > Add ubiupdatevol command. This is to update static > and dynamic volumes. > > Signed-off-by: Teresa Remmet <t.remmet@xxxxxxxxx> > --- > Changes in v2: > - instead of using read_file, used a smaller > buffer and read/write in a loop > > commands/ubi.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 81 insertions(+) > > diff --git a/commands/ubi.c b/commands/ubi.c > index dc2b4b5..b8b3f38 100644 > --- a/commands/ubi.c > +++ b/commands/ubi.c > @@ -7,10 +7,91 @@ > #include <getopt.h> > #include <linux/mtd/mtd.h> > #include <linux/kernel.h> > +#include <linux/stat.h> > #include <linux/mtd/mtd-abi.h> > #include <mtd/ubi-user.h> > #include <mtd/ubi-media.h> > > +static int do_ubiupdatevol(int argc, char *argv[]) > +{ > + int fd_img, fd_vol, ret = 0; > + uint64_t size = 0; > + struct stat st; > + unsigned int count; > + void *buf; > + > + if (argc - optind < 2) > + return COMMAND_ERROR_USAGE; > + > + if (stat(argv[optind+1], &st)) { > + perror("stat image"); > + return 1; > + } > + > + size = st.st_size; While applying I added a test that tests for FILESIZE_MAX here and bails out with an error. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox