diff --git a/commands/Kconfig b/commands/Kconfig index 0853ffd..1743670 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -1493,9 +1493,9 @@ config CMD_READLINE tristate - prompt "Readline" + prompt "readline" help - rompt for user input + Prompt for user input Usage: readline PROMPT VAR diff --git a/commands/ls.c b/commands/ls.c index 09437af..ce02f16 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -124,7 +124,7 @@ static int do_ls(int argc, char *argv[]) { - int ret, opt, o; + int ret, opt, o, exitcode = 0; struct stat s; ulong flags = LS_COLUMN; struct string_list sl; @@ -165,6 +165,7 @@ printf("%s: %s: %s\n", argv[0], argv[o], errno_str()); o++; + exitcode = COMMAND_ERROR; continue; } @@ -190,6 +191,7 @@ ret = lstat(argv[o], &s); if (ret) { o++; + exitcode = COMMAND_ERROR; continue; } @@ -197,6 +199,7 @@ ret = ls(argv[o], flags); if (ret) { perror("ls"); + exitcode = COMMAND_ERROR; o++; continue; } @@ -205,7 +208,7 @@ o++; } - return 0; + return exitcode; } BAREBOX_CMD_HELP_START(ls) diff --git a/common/bootm.c b/common/bootm.c index 447c9b6..08125e7 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -245,25 +245,19 @@ return 0; } -static int bootm_open_oftree(struct image_data *data, const char *oftree, int num) +static int bootm_open_oftree_uimage(struct image_data *data) { - enum filetype ft; struct fdt_header *fdt; + enum filetype ft; + const char *oftree = data->oftree_file; + int num = data->oftree_num; + struct uimage_handle *of_handle; + int release = 0; size_t size; - printf("Loading devicetree from '%s'\n", oftree); + printf("Loading devicetree from '%s'@%d\n", oftree, num); - ft = file_name_detect_type(oftree); - if ((int)ft < 0) { - printf("failed to open %s: %s\n", oftree, strerror(-(int)ft)); - return ft; - } - - if (ft == filetype_uimage) { -#ifdef CONFIG_CMD_BOOTM_OFTREE_UIMAGE - struct uimage_handle *of_handle; - int release = 0; - + if (IS_ENABLED(CONFIG_CMD_BOOTM_OFTREE_UIMAGE)) { if (!strcmp(data->os_file, oftree)) { of_handle = data->os; } else if (!strcmp(data->initrd_file, oftree)) { @@ -280,23 +274,42 @@ if (release) uimage_close(of_handle); -#else - return -EINVAL; -#endif - } else { - fdt = read_file(oftree, &size); - if (!fdt) { - perror("open"); - return -ENODEV; - } - } - ft = file_detect_type(fdt, size); - if (ft != filetype_oftree) { - printf("%s is not an oftree but %s\n", oftree, - file_type_to_string(ft)); + ft = file_detect_type(fdt, size); + if (ft != filetype_oftree) { + printf("%s is not an oftree but %s\n", + data->oftree_file, file_type_to_string(ft)); + return -EINVAL; + } + + data->of_root_node = of_unflatten_dtb(fdt); + if (!data->of_root_node) { + pr_err("unable to unflatten devicetree\n"); + free(fdt); + return -EINVAL; + } + + free(fdt); + + return 0; + } else { return -EINVAL; } +} + +static int bootm_open_oftree(struct image_data *data) +{ + struct fdt_header *fdt; + const char *oftree = data->oftree_file; + size_t size; + + printf("Loading devicetree from '%s'\n", oftree); + + fdt = read_file(oftree, &size); + if (!fdt) { + perror("open"); + return -ENODEV; + } data->of_root_node = of_unflatten_dtb(fdt); if (!data->of_root_node) { @@ -368,6 +381,7 @@ struct image_handler *handler; int ret; enum filetype os_type, initrd_type = filetype_unknown; + enum filetype oftree_type = filetype_unknown; if (!bootm_data->os_file) { printf("no image given\n"); @@ -401,6 +415,28 @@ goto err_out; } + if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD) && data->initrd_file) { + initrd_type = file_name_detect_type(data->initrd_file); + + if ((int)initrd_type < 0) { + printf("could not open %s: %s\n", data->initrd_file, + strerror(-initrd_type)); + ret = (int)initrd_type; + goto err_out; + } + } + + if (IS_ENABLED(CONFIG_OFTREE) && data->oftree_file) { + oftree_type = file_name_detect_type(data->oftree_file); + + if ((int)oftree_type < 0) { + printf("could not open %s: %s\n", data->oftree_file, + strerror(-oftree_type)); + ret = (int) oftree_type; + goto err_out; + } + } + if (os_type == filetype_uimage) { ret = bootm_open_os_uimage(data); if (ret) { @@ -411,14 +447,6 @@ } if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD) && data->initrd_file) { - - initrd_type = file_name_detect_type(data->initrd_file); - if ((int)initrd_type < 0) { - printf("could not open %s: %s\n", data->initrd_file, - strerror(-initrd_type)); - ret = (int)initrd_type; - goto err_out; - } if (initrd_type == filetype_uimage) { ret = bootm_open_initrd_uimage(data); if (ret) { @@ -438,7 +466,10 @@ if (IS_ENABLED(CONFIG_OFTREE)) { if (data->oftree_file) { - ret = bootm_open_oftree(data, data->oftree_file, data->oftree_num); + if (oftree_type == filetype_uimage) + ret = bootm_open_oftree_uimage(data); + if (oftree_type == filetype_oftree) + ret = bootm_open_oftree(data); if (ret) goto err_out; } else { diff --git a/common/environment.c b/common/environment.c index f6fd781..f412e62 100644 --- a/common/environment.c +++ b/common/environment.c @@ -324,16 +324,16 @@ ret = protect(envfd, ~0, 0, 0); - /* ENOSYS is no error here, many devices do not need it */ - if (ret && errno != ENOSYS) { + /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ + if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { printf("could not unprotect %s: %s\n", filename, errno_str()); goto out; } ret = erase(envfd, ~0, 0); - /* ENOSYS is no error here, many devices do not need it */ - if (ret && errno != ENOSYS) { + /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ + if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { printf("could not erase %s: %s\n", filename, errno_str()); goto out; } @@ -355,8 +355,8 @@ ret = protect(envfd, ~0, 0, 1); - /* ENOSYS is no error here, many devices do not need it */ - if (ret && errno != ENOSYS) { + /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ + if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { printf("could not protect %s: %s\n", filename, errno_str()); goto out; } diff --git a/common/state.c b/common/state.c index 117a686..a161b94 100644 --- a/common/state.c +++ b/common/state.c @@ -716,6 +716,8 @@ vtype = state_find_type_by_name(type_name); if (!vtype) { + dev_err(&state->dev, "unkown type: %s in %s\n", type_name, + node->full_name); ret = -ENOENT; goto out_free; } diff --git a/crypto/crc32.c b/crypto/crc32.c index e7b1bd7..58637bd 100644 --- a/crypto/crc32.c +++ b/crypto/crc32.c @@ -16,6 +16,9 @@ #include #include #include +#define STATIC +#else +#define STATIC static inline #endif #ifdef CONFIG_DYNAMIC_CRC_TABLE @@ -138,7 +141,7 @@ #define DO8(buf) DO4(buf); DO4(buf); /* ========================================================================= */ -uint32_t crc32(uint32_t crc, const void *_buf, unsigned int len) +STATIC uint32_t crc32(uint32_t crc, const void *_buf, unsigned int len) { const unsigned char *buf = _buf; @@ -164,7 +167,7 @@ /* No ones complement version. JFFS2 (and other things ?) * don't use ones compliment in their CRC calculations. */ -uint32_t crc32_no_comp(uint32_t crc, const void *_buf, unsigned int len) +STATIC uint32_t crc32_no_comp(uint32_t crc, const void *_buf, unsigned int len) { const unsigned char *buf = _buf; @@ -184,7 +187,7 @@ return crc; } -int file_crc(char *filename, ulong start, ulong size, ulong *crc, +STATIC int file_crc(char *filename, ulong start, ulong size, ulong *crc, ulong *total) { int fd, now; diff --git a/defaultenv/defaultenv-2-base/boot/net b/defaultenv/defaultenv-2-base/boot/net index ced2fad..af09641 100644 --- a/defaultenv/defaultenv-2-base/boot/net +++ b/defaultenv/defaultenv-2-base/boot/net @@ -11,4 +11,10 @@ nfsroot="/home/${global.user}/nfsroot/${global.hostname}" bootargs-ip -global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" + +initramfs="${path}/${global.user}-initramfs-${global.hostname}" +if [ -f "${initramfs}" ]; then + global.bootm.initrd="$initramfs" +else + global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" +fi diff --git a/lib/make_directory.c b/lib/make_directory.c index c14c86d..7432efc 100644 --- a/lib/make_directory.c +++ b/lib/make_directory.c @@ -5,9 +5,12 @@ #include #include #include +#define STATIC +#else +#define STATIC static inline #endif -int make_directory(const char *dir) +STATIC int make_directory(const char *dir) { char *s = strdup(dir); char *path = s; diff --git a/lib/readline.c b/lib/readline.c index 14dd311..c007e10 100644 --- a/lib/readline.c +++ b/lib/readline.c @@ -262,6 +262,14 @@ eol_num--; } break; + case CTL_CH('l'): + printf(ANSI_CLEAR_SCREEN); + buf[eol_num] = 0; + printf("%s%s", prompt, buf); + wlen = eol_num - num; + while (wlen--) + getcmd_putch(CTL_BACKSPACE); + break; case BB_KEY_ERASE_TO_EOL: ERASE_TO_EOL(); break; diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore index dc24f5f..a776371 100644 --- a/scripts/basic/.gitignore +++ b/scripts/basic/.gitignore @@ -1,2 +1 @@ -docproc fixdep diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index 4f284df..9e92d89 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile @@ -7,9 +7,8 @@ # .config is included by main Makefile. # --------------------------------------------------------------------------- # fixdep: Used to generate dependency information during build process -# docproc: Used in Documentation/docbook -hostprogs-y := fixdep docproc +hostprogs-y := fixdep always := $(hostprogs-y) # fixdep is needed to compile other host programs diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c deleted file mode 100644 index 9f6535d..0000000 --- a/scripts/basic/docproc.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - * docproc is a simple preprocessor for the template files - * 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 - * some knowledge of the .tmpl syntax, therefore they - * are kept together. - * - * documentation-frontend - * Scans the template file and call kernel-doc for - * all occurrences of ![EIF]file - * Beforehand each referenced file are scanned for - * any exported sympols "EXPORT_SYMBOL()" statements. - * This is used to create proper -function and - * -nofunction arguments in calls to kernel-doc. - * Usage: docproc doc file.tmpl - * - * dependency-generator: - * Scans the template file and list all files - * referenced in a format recognized by make. - * Usage: docproc depend file.tmpl - * Writes dependency information to stdout - * in the following format: - * file.tmpl src.c src2.c - * The filenames are obtained from the following constructs: - * !Efilename - * !Ifilename - * !Dfilename - * !Ffilename - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* exitstatus is used to keep track of any failing calls to kernel-doc, - * but execution continues. */ -int exitstatus = 0; - -typedef void DFL(char *); -DFL *defaultline; - -typedef void FILEONLY(char * file); -FILEONLY *internalfunctions; -FILEONLY *externalfunctions; -FILEONLY *symbolsonly; - -typedef void FILELINE(char * file, char * line); -FILELINE * singlefunctions; -FILELINE * entity_system; - -#define MAXLINESZ 2048 -#define MAXFILES 250 -#define KERNELDOCPATH "scripts/" -#define KERNELDOC "kernel-doc" -#define DOCBOOK "-docbook" -#define FUNCTION "-function" -#define NOFUNCTION "-nofunction" - -void usage (void) -{ - fprintf(stderr, "Usage: docproc {doc|depend} file\n"); - fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); - fprintf(stderr, "doc: frontend when generating kernel documentation\n"); - fprintf(stderr, "depend: generate list of files referenced within file\n"); -} - -/* - * Execute kernel-doc with parameters givin in svec - */ -void exec_kernel_doc(char **svec) -{ - pid_t pid; - int ret; - char real_filename[PATH_MAX + 1]; - /* Make sure output generated so far are flushed */ - fflush(stdout); - switch(pid=fork()) { - case -1: - perror("fork"); - exit(1); - case 0: - memset(real_filename, 0, sizeof(real_filename)); - strncat(real_filename, getenv("SRCTREE"), PATH_MAX); - strncat(real_filename, KERNELDOCPATH KERNELDOC, - PATH_MAX - strlen(real_filename)); - execvp(real_filename, svec); - fprintf(stderr, "exec "); - perror(real_filename); - exit(1); - default: - waitpid(pid, &ret ,0); - } - if (WIFEXITED(ret)) - exitstatus |= WEXITSTATUS(ret); - else - exitstatus = 0xff; -} - -/* Types used to create list of all exported symbols in a number of files */ -struct symbols -{ - char *name; -}; - -struct symfile -{ - char *filename; - struct symbols *symbollist; - int symbolcnt; -}; - -struct symfile symfilelist[MAXFILES]; -int symfilecnt = 0; - -void add_new_symbol(struct symfile *sym, char * symname) -{ - sym->symbollist = realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *)); - if (!sym->symbollist) { - fprintf(stderr, "docproc: out of memory\n"); - exit(1); - } - sym->symbollist[sym->symbolcnt++].name = strdup(symname); -} - -/* Add a filename to the list */ -struct symfile * add_new_file(char * filename) -{ - symfilelist[symfilecnt++].filename = strdup(filename); - return &symfilelist[symfilecnt - 1]; -} -/* Check if file already are present in the list */ -struct symfile * filename_exist(char * filename) -{ - int i; - for (i=0; i < symfilecnt; i++) - if (strcmp(symfilelist[i].filename, filename) == 0) - return &symfilelist[i]; - return NULL; -} - -/* - * List all files referenced within the template file. - * Files are separated by tabs. - */ -void adddep(char * file) { printf("\t%s", file); } -void adddep2(char * file, char * line) { line = line; adddep(file); } -void noaction(char * line) { line = line; } -void noaction2(char * file, char * line) { file = file; line = line; } - -/* Echo the line without further action */ -void printline(char * line) { printf("%s", line); } - -/* - * Find all symbols exported with EXPORT_SYMBOL and EXPORT_SYMBOL_GPL - * in filename. - * All symbols located are stored in symfilelist. - */ -void find_export_symbols(char * filename) -{ - FILE * fp; - struct symfile *sym; - char line[MAXLINESZ]; - if (filename_exist(filename) == NULL) { - char real_filename[PATH_MAX + 1]; - memset(real_filename, 0, sizeof(real_filename)); - strncat(real_filename, getenv("SRCTREE"), PATH_MAX); - strncat(real_filename, filename, - PATH_MAX - strlen(real_filename)); - sym = add_new_file(filename); - fp = fopen(real_filename, "r"); - if (fp == NULL) - { - fprintf(stderr, "docproc: "); - perror(real_filename); - exit(1); - } - while(fgets(line, MAXLINESZ, fp)) { - char *p; - char *e; - if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != 0) || - ((p = strstr(line, "EXPORT_SYMBOL")) != 0)) { - /* Skip EXPORT_SYMBOL{_GPL} */ - while (isalnum(*p) || *p == '_') - p++; - /* Remove paranteses and additional ws */ - while (isspace(*p)) - p++; - if (*p != '(') - continue; /* Syntax error? */ - else - p++; - while (isspace(*p)) - p++; - e = p; - while (isalnum(*e) || *e == '_') - e++; - *e = '\0'; - add_new_symbol(sym, p); - } - } - fclose(fp); - } -} - -/* - * Document all external or internal functions in a file. - * Call kernel-doc with following parameters: - * kernel-doc -docbook -nofunction function_name1 filename - * function names are obtained from all the the src files - * by find_export_symbols. - * intfunc uses -nofunction - * extfunc uses -function - */ -void docfunctions(char * filename, char * type) -{ - int i,j; - int symcnt = 0; - int idx = 0; - char **vec; - - for (i=0; i <= symfilecnt; i++) - symcnt += symfilelist[i].symbolcnt; - vec = malloc((2 + 2 * symcnt + 2) * sizeof(char*)); - if (vec == NULL) { - perror("docproc: "); - exit(1); - } - vec[idx++] = KERNELDOC; - vec[idx++] = DOCBOOK; - for (i=0; i < symfilecnt; i++) { - struct symfile * sym = &symfilelist[i]; - for (j=0; j < sym->symbolcnt; j++) { - vec[idx++] = type; - vec[idx++] = sym->symbollist[j].name; - } - } - vec[idx++] = filename; - vec[idx] = NULL; - printf("\n", filename); - exec_kernel_doc(vec); - fflush(stdout); - free(vec); -} -void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); } -void extfunc(char * filename) { docfunctions(filename, FUNCTION); } - -/* - * Document specific function(s) in a file. - * Call kernel-doc with the following parameters: - * kernel-doc -docbook -function function1 [-function function2] - */ -void singfunc(char * filename, char * line) -{ - char *vec[200]; /* Enough for specific functions */ - int i, idx = 0; - int startofsym = 1; - vec[idx++] = KERNELDOC; - vec[idx++] = DOCBOOK; - - /* Split line up in individual parameters preceeded by FUNCTION */ - for (i=0; line[i]; i++) { - if (isspace(line[i])) { - line[i] = '\0'; - startofsym = 1; - continue; - } - if (startofsym) { - startofsym = 0; - vec[idx++] = FUNCTION; - vec[idx++] = &line[i]; - } - } - vec[idx++] = filename; - vec[idx] = NULL; - exec_kernel_doc(vec); -} - -/* - * Parse file, calling action specific functions for: - * 1) Lines containing !E - * 2) Lines containing !I - * 3) Lines containing !D - * 4) Lines containing !F - * 5) Default lines - lines not matching the above - */ -void parse_file(FILE *infile) -{ - char line[MAXLINESZ]; - char * s; - while(fgets(line, MAXLINESZ, infile)) { - if (line[0] == '!') { - s = line + 2; - switch (line[1]) { - case 'E': - while (*s && !isspace(*s)) s++; - *s = '\0'; - externalfunctions(line+2); - break; - case 'I': - while (*s && !isspace(*s)) s++; - *s = '\0'; - internalfunctions(line+2); - break; - case 'D': - while (*s && !isspace(*s)) s++; - *s = '\0'; - symbolsonly(line+2); - break; - case 'F': - /* filename */ - while (*s && !isspace(*s)) s++; - *s++ = '\0'; - /* function names */ - while (isspace(*s)) - s++; - singlefunctions(line +2, s); - break; - default: - defaultline(line); - } - } - else { - defaultline(line); - } - } - fflush(stdout); -} - - -int main(int argc, char *argv[]) -{ - FILE * infile; - if (argc != 3) { - usage(); - exit(1); - } - /* Open file, exit on error */ - infile = fopen(argv[2], "r"); - if (infile == NULL) { - fprintf(stderr, "docproc: "); - perror(argv[2]); - exit(2); - } - - if (strcmp("doc", argv[1]) == 0) - { - /* Need to do this in two passes. - * First pass is used to collect all symbols exported - * in the various files. - * Second pass generate the documentation. - * This is required because function are declared - * and exported in different files :-(( - */ - /* Collect symbols */ - defaultline = noaction; - internalfunctions = find_export_symbols; - externalfunctions = find_export_symbols; - symbolsonly = find_export_symbols; - singlefunctions = noaction2; - parse_file(infile); - - /* Rewind to start from beginning of file again */ - fseek(infile, 0, SEEK_SET); - defaultline = printline; - internalfunctions = intfunc; - externalfunctions = extfunc; - symbolsonly = printline; - singlefunctions = singfunc; - - parse_file(infile); - } - else if (strcmp("depend", argv[1]) == 0) - { - /* Create first part of dependency chain - * file.tmpl */ - printf("%s\t", argv[2]); - defaultline = noaction; - internalfunctions = adddep; - externalfunctions = adddep; - symbolsonly = adddep; - singlefunctions = adddep2; - parse_file(infile); - printf("\n"); - } - else - { - fprintf(stderr, "Unknown option: %s\n", argv[1]); - exit(1); - } - fclose(infile); - fflush(stdout); - return exitstatus; -} - diff --git a/scripts/mk-omap-image.c b/scripts/mk-omap-image.c index 1d61a34..234b7e3 100644 --- a/scripts/mk-omap-image.c +++ b/scripts/mk-omap-image.c @@ -49,7 +49,7 @@ #include #include -void usage(char *prgname) +static void usage(char *prgname) { printf("usage: %s [OPTION] FILE > IMAGE\n" "\n"