From a3ffa97f40dc81f2d6b07ee964f2340fe0c1ba97 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Dec 2009 09:11:09 +0100 Subject: rename U-Boot-v2 project to barebox This has been done with the following script: find -path ./.git -prune -o -type f -print0 | xargs -0 -r sed -i \ -e 's/u2boot/barebox/g' \ -e 's/U2Boot/barebox/g' \ -e 's/U-boot V2/barebox/g' \ -e 's/u-boot v2/barebox/g' \ -e 's/U-Boot V2/barebox/g' \ -e 's/U-Boot-v2/barebox/g' \ -e 's/U_BOOT/BAREBOX/g' \ -e 's/UBOOT/BAREBOX/g' \ -e 's/uboot/barebox/g' \ -e 's/u-boot/barebox/g' \ -e 's/u_boot/barebox/g' \ -e 's/U-Boot/barebox/g' \ -e 's/U-boot/barebox/g' \ -e 's/U-BOOT/barebox/g' find -path ./.git -prune -o \( -name "*u-boot*" -o -name "*uboot*" -o -name "*u_boot*" \) -print0 | \ xargs -0 -r rename 's/u[-_]?boot/barebox/' It needs some manual fixup following in the next patch Signed-off-by: Sascha Hauer --- scripts/.gitignore | 2 +- scripts/Makefile | 4 +- scripts/Makefile.lib | 2 +- scripts/Makefile.modpost | 8 +- scripts/bareboxenv.c | 196 +++++++++++++++++++++++++++++++++++++++++++++ scripts/basic/Makefile | 2 +- scripts/basic/docproc.c | 2 +- scripts/gen_netx_image.c | 16 ++-- scripts/kconfig/conf.c | 2 +- scripts/kconfig/confdata.c | 6 +- scripts/kconfig/mconf.c | 30 +++---- scripts/mkimage.c | 6 +- scripts/mksysmap | 4 +- scripts/mod/modpost.c | 4 +- scripts/ubootenv.c | 196 --------------------------------------------- 15 files changed, 240 insertions(+), 240 deletions(-) create mode 100644 scripts/bareboxenv.c delete mode 100644 scripts/ubootenv.c (limited to 'scripts') diff --git a/scripts/.gitignore b/scripts/.gitignore index 4d60d3f1aa..26317b28c2 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,4 +1,4 @@ -ubootenv +bareboxenv bin2c mkimage kallsyms diff --git a/scripts/Makefile b/scripts/Makefile index cb08458ff9..a6829c56be 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -2,7 +2,7 @@ # scripts contains sources for various helper programs used throughout # the kernel for the build process. # --------------------------------------------------------------------------- -# kallsyms: Find all symbols in uboot +# kallsyms: Find all symbols in barebox # pnmttologo: Convert pnm files to logo files # conmakehash: Create chartable # conmakehash: Create arrays for initializing the kernel console tables @@ -13,7 +13,7 @@ hostprogs-$(CONFIG_VT) += conmakehash hostprogs-$(CONFIG_PROM_CONSOLE) += conmakehash hostprogs-y += bin2c hostprogs-y += mkimage -hostprogs-y += ubootenv +hostprogs-y += bareboxenv hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image always := $(hostprogs-y) $(hostprogs-m) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 6d26dde242..d7e25630dd 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -90,7 +90,7 @@ _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o) _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) _cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F)) -# If building uboot in a separate objtree expand all occurrences +# If building barebox in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). ifeq ($(KBUILD_SRC),) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 0278d29a5f..7620c608bc 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -56,7 +56,7 @@ _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) # Step 2), invoke modpost # Includes step 3,4 -quiet_cmd_modpost = MODPOST $(words $(filter-out uboot FORCE, $^)) modules +quiet_cmd_modpost = MODPOST $(words $(filter-out barebox FORCE, $^)) modules cmd_modpost = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ @@ -67,13 +67,13 @@ quiet_cmd_modpost = MODPOST $(words $(filter-out uboot FORCE, $^)) modules PHONY += __modpost __modpost: $(modules:.ko=.o) FORCE - $(call cmd,modpost) $(wildcard uboot) $(filter-out FORCE,$^) + $(call cmd,modpost) $(wildcard barebox) $(filter-out FORCE,$^) quiet_cmd_kernel-mod = MODPOST $@ cmd_kernel-mod = $(cmd_modpost) $@ -PHONY += uboot -uboot.o: FORCE +PHONY += barebox +barebox.o: FORCE $(call cmd,kernel-mod) # Declare generated files as targets for modpost diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c new file mode 100644 index 0000000000..5c7f10e6b9 --- /dev/null +++ b/scripts/bareboxenv.c @@ -0,0 +1,196 @@ +/* + * bareboxenv.c - generate or read a barebox environment archive + * + * Copyright (c) 2007 Sascha Hauer , Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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 + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define debug(...) + +void *xmalloc(size_t size) +{ + void *p = NULL; + + if (!(p = malloc(size))) { + printf("ERROR: out of memory\n"); + exit(1); + } + + return p; +} + +void *xzalloc(size_t size) +{ + void *p = xmalloc(size); + memset(p, 0, size); + return p; +} + +/* Find out if the last character of a string matches the one given. + * Don't underrun the buffer if the string length is 0. + */ +char* last_char_is(const char *s, int c) +{ + if (s && *s) { + size_t sz = strlen(s) - 1; + s += sz; + if ( (unsigned char)*s == c) + return (char*)s; + } + return NULL; +} + +enum { + ACTION_RECURSE = (1 << 0), + /* ACTION_FOLLOWLINKS = (1 << 1), - unused */ + ACTION_DEPTHFIRST = (1 << 2), + /*ACTION_REVERSE = (1 << 3), - unused */ +}; + +int recursive_action(const char *fileName, unsigned flags, + int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData, int depth), + int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData, int depth), + void* userData, const unsigned depth); + +#define DOT_OR_DOTDOT(s) ((s)[0] == '.' && (!(s)[1] || ((s)[1] == '.' && !(s)[2]))) + +/* concatenate path and file name to new allocation buffer, + * not adding '/' if path name already has '/' + */ +char *concat_path_file(const char *path, const char *filename) +{ + char *lc, *str; + + if (!path) + path = ""; + lc = last_char_is(path, '/'); + while (*filename == '/') + filename++; + + str = xmalloc(strlen(path) + (lc==0 ? 1 : 0) + strlen(filename) + 1); + sprintf(str, "%s%s%s", path, (lc==NULL ? "/" : ""), filename); + + return str; +} + +/* + * This function make special for recursive actions with usage + * concat_path_file(path, filename) + * and skipping "." and ".." directory entries + */ + +char *concat_subpath_file(const char *path, const char *f) +{ + if (f && DOT_OR_DOTDOT(f)) + return NULL; + return concat_path_file(path, f); +} + +#include "../lib/recursive_action.c" +#include "../include/envfs.h" +#include "../lib/crc32.c" +#include "../lib/make_directory.c" +#include "../include/environment.h" +#include "../common/environment.c" + +void usage(char *prgname) +{ + printf( "Usage : %s [OPTION] DIRECTORY FILE\n" + "Load an barebox environment sector into a directory or\n" + "save a directory into an barebox environment sector\n" + "\n" + "options:\n" + " -s save (directory -> environment sector)\n" + " -l load (environment sector -> directory)\n" + " -p pad output file to given size\n", + prgname); +} + +int main(int argc, char *argv[]) +{ + int opt; + int save = 0, load = 0, pad = 0, fd; + char *filename = NULL, *dirname = NULL; + + while((opt = getopt(argc, argv, "slp:")) != -1) { + switch (opt) { + case 's': + save = 1; + break; + case 'l': + load = 1; + break; + case 'p': + pad = strtoul(optarg, NULL, 0); + break; + } + } + + if (optind + 1 >= argc) { + usage(argv[0]); + exit(1); + } + + dirname = argv[optind]; + filename = argv[optind + 1]; + + if ((!load && !save) || (load && save) || !filename || !dirname) { + usage(argv[0]); + exit(1); + } + + if (save) { + fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644); + if (fd < 0) { + perror("open"); + exit(1); + } + close(fd); + } + + if (save && pad) { + if (truncate(filename, pad)) { + perror("truncate"); + exit(1); + } + } + + if (load) { + printf("loading env from file %s to %s\n", filename, dirname); + envfs_load(filename, dirname); + } + if (save) { + printf("saving contents of %s to file %s\n", dirname, filename); + envfs_save(filename, dirname); + } + exit(0); +} diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index a0c0189fbe..4f284df33b 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile @@ -3,7 +3,7 @@ # The programs listed herein is what is needed to do the basic stuff, # such as fix dependency file. # This initial step is needed to avoid files to be recompiled -# when uboot configuration changes (which is what happens when +# when barebox configuration changes (which is what happens when # .config is included by main Makefile. # --------------------------------------------------------------------------- # fixdep: Used to generate dependency information during build process diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index f71e106206..0d4f5e7d74 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c @@ -1,6 +1,6 @@ /* * docproc is a simple preprocessor for the template files - * used as placeholders for the uboot internal documentation. + * used as placeholders for the barebox internal documentation. * docproc is used for documentation-frontend and * dependency-generator. * The two usages have in common that they require diff --git a/scripts/gen_netx_image.c b/scripts/gen_netx_image.c index 364900b0f3..af279d5485 100644 --- a/scripts/gen_netx_image.c +++ b/scripts/gen_netx_image.c @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) struct stat s; int opt; unsigned char *buf; - int bytes, err, uboot_size, ofs, i; + int bytes, err, barebox_size, ofs, i; uint32_t *ptr; uint32_t checksum = 0; uint32_t memctrl = 0, sdramctrl = 0, sdramtimctrl = 0, entrypoint = 0, cookie = 0; @@ -158,22 +158,22 @@ int main(int argc, char *argv[]) exit(1); } - uboot_size = s.st_size; - printf("found u-boot image. size: %d bytes. Using entrypoint 0x%08x\n",uboot_size,entrypoint); + barebox_size = s.st_size; + printf("found barebox image. size: %d bytes. Using entrypoint 0x%08x\n",barebox_size,entrypoint); - buf = malloc(uboot_size + sizeof(struct netx_bootblock) + 4); + buf = malloc(barebox_size + sizeof(struct netx_bootblock) + 4); if(!buf) { perror("malloc"); exit(1); } - memset(buf, 0, uboot_size + sizeof(struct netx_bootblock) + 4); + memset(buf, 0, barebox_size + sizeof(struct netx_bootblock) + 4); nb = (struct netx_bootblock *)buf; nb->cookie = cookie; nb->ctrl.mem_ctrl = memctrl; nb->appl_entrypoint = entrypoint; - nb->appl_size = (uboot_size >> 2); + nb->appl_size = (barebox_size >> 2); nb->appl_start_addr = entrypoint; nb->signature = NETX_IDENTIFICATION; @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) nb->config.normal.sdram_timing_ctrl = sdramtimctrl; ofs = sizeof(struct netx_bootblock); - bytes = uboot_size; + bytes = barebox_size; while(bytes) { err = read(fd, buf + ofs, bytes); @@ -220,7 +220,7 @@ int main(int argc, char *argv[]) exit(1); } - bytes = uboot_size + sizeof(struct netx_bootblock); + bytes = barebox_size + sizeof(struct netx_bootblock); ofs = 0; while(bytes) { err = write(fd, buf + ofs, bytes); diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index b82d01af4e..3ce2996d20 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -559,7 +559,7 @@ int main(int ac, char **av) case ask_silent: if (stat(".config", &tmpstat)) { printf(_("***\n" - "*** You have not yet configured u-boot!\n" + "*** You have not yet configured barebox!\n" "*** (missing .config file)\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index aff5339681..2b8f140635 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -440,7 +440,7 @@ int conf_write(const char *name) fprintf(out, _("#\n" "# Automatically generated make config: don't edit\n" - "# U-Boot version: %s\n" + "# barebox version: %s\n" "%s%s" "#\n"), sym_get_string_value(sym), @@ -692,13 +692,13 @@ int conf_write_autoconf(void) time(&now); fprintf(out, "#\n" "# Automatically generated make config: don't edit\n" - "# U-Boot version: %s\n" + "# barebox version: %s\n" "# %s" "#\n", sym_get_string_value(sym), ctime(&now)); fprintf(out_h, "/*\n" " * Automatically generated C config: don't edit\n" - " * U-Boot version: %s\n" + " * barebox version: %s\n" " * %s" " */\n" "#define AUTOCONF_INCLUDED\n", diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 4eca540281..4f99c380fe 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -29,10 +29,10 @@ static const char mconf_readme[] = N_( "Overview\n" "--------\n" -"Some U-Boot features may be built directly into U-Boot.\n" +"Some barebox features may be built directly into barebox.\n" "Some may be made into loadable runtime modules. Some features\n" "may be completely removed altogether. There are also certain\n" -"U-Boot parameters which are not really features, but must be\n" +"barebox parameters which are not really features, but must be\n" "entered in as decimal or hexadecimal numbers or possibly text.\n" "\n" "Menu items beginning with [*], or [ ] represent features\n" @@ -115,7 +115,7 @@ static const char mconf_readme[] = N_( "-----------------------------\n" "Menuconfig supports the use of alternate configuration files for\n" "those who, for various reasons, find it necessary to switch\n" -"between different U-Boot configurations.\n" +"between different barebox configurations.\n" "\n" "At the end of the main menu you will find two options. One is\n" "for saving the current configuration to a file of your choosing.\n" @@ -148,7 +148,7 @@ static const char mconf_readme[] = N_( "\n" "Optional personality available\n" "------------------------------\n" -"If you prefer to have all of the U-Boot options listed in a single\n" +"If you prefer to have all of the barebox options listed in a single\n" "menu, rather than the default multimenu hierarchy, run the menuconfig\n" "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" "\n" @@ -200,18 +200,18 @@ setmod_text[] = N_( "This feature depends on another which has been configured as a module.\n" "As a result, this feature will be built as a module."), nohelp_text[] = N_( - "There is no help available for this U-Boot option.\n"), + "There is no help available for this barebox option.\n"), load_config_text[] = N_( "Enter the name of the configuration file you wish to load. " "Accept the name shown to restore the configuration you " "last retrieved. Leave blank to abort."), load_config_help[] = N_( "\n" - "For various reasons, one may wish to keep several different U-Boot\n" + "For various reasons, one may wish to keep several different barebox\n" "configurations available on a single machine.\n" "\n" "If you have saved a previous configuration in a file other than the\n" - "U-Boot's default, entering the name of the file here will allow you\n" + "barebox's default, entering the name of the file here will allow you\n" "to modify that configuration.\n" "\n" "If you are uncertain, then you have probably never used alternate\n" @@ -221,7 +221,7 @@ save_config_text[] = N_( "as an alternate. Leave blank to abort."), save_config_help[] = N_( "\n" - "For various reasons, one may wish to keep different U-Boot\n" + "For various reasons, one may wish to keep different barebox\n" "configurations available on a single machine.\n" "\n" "Entering a file name here will allow you to later retrieve, modify\n" @@ -403,7 +403,7 @@ static void set_config_filename(const char *config_filename) sym = sym_lookup("KERNELVERSION", 0); sym_calc_value(sym); size = snprintf(menu_backtitle, sizeof(menu_backtitle), - _("%s - U-Boot v%s Configuration"), + _("%s - barebox v%s Configuration"), config_filename, sym_get_string_value(sym)); if (size >= sizeof(menu_backtitle)) menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; @@ -919,7 +919,7 @@ int main(int ac, char **av) if (conf_get_changed()) res = dialog_yesno(NULL, _("Do you wish to save your " - "new U-Boot configuration?\n" + "new barebox configuration?\n" " to continue."), 6, 60); else @@ -931,20 +931,20 @@ int main(int ac, char **av) case 0: if (conf_write(filename)) { fprintf(stderr, _("\n\n" - "Error during writing of the U-Boot configuration.\n" - "Your U-Boot configuration changes were NOT saved." + "Error during writing of the barebox configuration.\n" + "Your barebox configuration changes were NOT saved." "\n\n")); return 1; } case -1: printf(_("\n\n" - "*** End of U-Boot configuration.\n" - "*** Execute 'make' to build U-Boot or try 'make help'." + "*** End of barebox configuration.\n" + "*** Execute 'make' to build barebox or try 'make help'." "\n\n")); break; default: fprintf(stderr, _("\n\n" - "Your U-Boot configuration changes were NOT saved." + "Your barebox configuration changes were NOT saved." "\n\n")); } diff --git a/scripts/mkimage.c b/scripts/mkimage.c index ab7d55dc41..240c5cf5d5 100644 --- a/scripts/mkimage.c +++ b/scripts/mkimage.c @@ -118,7 +118,7 @@ table_entry_t os_name[] = { { IH_OS_SCO, "sco", "SCO", }, { IH_OS_SOLARIS, "solaris", "Solaris", }, { IH_OS_SVR4, "svr4", "SVR4", }, - { IH_OS_U_BOOT, "u-boot", "U-Boot", }, + { IH_OS_BAREBOX, "barebox", "barebox", }, { IH_OS_VXWORKS, "vxworks", "VxWorks", }, { -1, "", "", }, }; @@ -269,14 +269,14 @@ NXTARG: ; if (!eflag) { ep = addr; - /* If XIP, entry point must be after the U-Boot header */ + /* If XIP, entry point must be after the barebox header */ if (xflag) ep += sizeof(image_header_t); } /* * If XIP, ensure the entry point is equal to the load address plus - * the size of the U-Boot header. + * the size of the barebox header. */ if (xflag) { if (ep != addr + sizeof(image_header_t)) { diff --git a/scripts/mksysmap b/scripts/mksysmap index 67f0947021..bacef6a4bb 100644 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -1,10 +1,10 @@ #!/bin/sh -x -# Based on the uboot file create the System.map file +# Based on the barebox file create the System.map file # System.map is used by module-init tools and some debugging # tools to retrieve the actual addresses of symbols in the kernel. # # Usage -# mksysmap uboot System.map +# mksysmap barebox System.map ##### diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 76e61042e3..4075c35d37 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -91,8 +91,8 @@ static int is_vmlinux(const char *modname) else myname = modname; - return (strcmp(myname, "uboot") == 0) || - (strcmp(myname, "uboot.o") == 0); + return (strcmp(myname, "barebox") == 0) || + (strcmp(myname, "barebox.o") == 0); } void *do_nofail(void *ptr, const char *expr) diff --git a/scripts/ubootenv.c b/scripts/ubootenv.c deleted file mode 100644 index 32da113b56..0000000000 --- a/scripts/ubootenv.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * ubootenv.c - generate or read a U-Boot environment archive - * - * Copyright (c) 2007 Sascha Hauer , Pengutronix - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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 - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define debug(...) - -void *xmalloc(size_t size) -{ - void *p = NULL; - - if (!(p = malloc(size))) { - printf("ERROR: out of memory\n"); - exit(1); - } - - return p; -} - -void *xzalloc(size_t size) -{ - void *p = xmalloc(size); - memset(p, 0, size); - return p; -} - -/* Find out if the last character of a string matches the one given. - * Don't underrun the buffer if the string length is 0. - */ -char* last_char_is(const char *s, int c) -{ - if (s && *s) { - size_t sz = strlen(s) - 1; - s += sz; - if ( (unsigned char)*s == c) - return (char*)s; - } - return NULL; -} - -enum { - ACTION_RECURSE = (1 << 0), - /* ACTION_FOLLOWLINKS = (1 << 1), - unused */ - ACTION_DEPTHFIRST = (1 << 2), - /*ACTION_REVERSE = (1 << 3), - unused */ -}; - -int recursive_action(const char *fileName, unsigned flags, - int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData, int depth), - int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData, int depth), - void* userData, const unsigned depth); - -#define DOT_OR_DOTDOT(s) ((s)[0] == '.' && (!(s)[1] || ((s)[1] == '.' && !(s)[2]))) - -/* concatenate path and file name to new allocation buffer, - * not adding '/' if path name already has '/' - */ -char *concat_path_file(const char *path, const char *filename) -{ - char *lc, *str; - - if (!path) - path = ""; - lc = last_char_is(path, '/'); - while (*filename == '/') - filename++; - - str = xmalloc(strlen(path) + (lc==0 ? 1 : 0) + strlen(filename) + 1); - sprintf(str, "%s%s%s", path, (lc==NULL ? "/" : ""), filename); - - return str; -} - -/* - * This function make special for recursive actions with usage - * concat_path_file(path, filename) - * and skipping "." and ".." directory entries - */ - -char *concat_subpath_file(const char *path, const char *f) -{ - if (f && DOT_OR_DOTDOT(f)) - return NULL; - return concat_path_file(path, f); -} - -#include "../lib/recursive_action.c" -#include "../include/envfs.h" -#include "../lib/crc32.c" -#include "../lib/make_directory.c" -#include "../include/environment.h" -#include "../common/environment.c" - -void usage(char *prgname) -{ - printf( "Usage : %s [OPTION] DIRECTORY FILE\n" - "Load an u-boot environment sector into a directory or\n" - "save a directory into an u-boot environment sector\n" - "\n" - "options:\n" - " -s save (directory -> environment sector)\n" - " -l load (environment sector -> directory)\n" - " -p pad output file to given size\n", - prgname); -} - -int main(int argc, char *argv[]) -{ - int opt; - int save = 0, load = 0, pad = 0, fd; - char *filename = NULL, *dirname = NULL; - - while((opt = getopt(argc, argv, "slp:")) != -1) { - switch (opt) { - case 's': - save = 1; - break; - case 'l': - load = 1; - break; - case 'p': - pad = strtoul(optarg, NULL, 0); - break; - } - } - - if (optind + 1 >= argc) { - usage(argv[0]); - exit(1); - } - - dirname = argv[optind]; - filename = argv[optind + 1]; - - if ((!load && !save) || (load && save) || !filename || !dirname) { - usage(argv[0]); - exit(1); - } - - if (save) { - fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644); - if (fd < 0) { - perror("open"); - exit(1); - } - close(fd); - } - - if (save && pad) { - if (truncate(filename, pad)) { - perror("truncate"); - exit(1); - } - } - - if (load) { - printf("loading env from file %s to %s\n", filename, dirname); - envfs_load(filename, dirname); - } - if (save) { - printf("saving contents of %s to file %s\n", dirname, filename); - envfs_save(filename, dirname); - } - exit(0); -} -- cgit v1.2.3