Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/libbb/execable.c

    r1765 r2725  
    55 * Copyright (C) 2006 Gabriel Somlo <somlo at cmu.edu>
    66 *
    7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
    99
     
    1414 * return 0 otherwise;
    1515 */
    16 int execable_file(const char *name)
     16int FAST_FUNC execable_file(const char *name)
    1717{
    1818    struct stat s;
     
    2020}
    2121
    22 /* search $PATH for an executable file;
     22/* search (*PATHp) for an executable file;
    2323 * return allocated string containing full path if found;
    24  * return NULL otherwise;
     24 *  PATHp points to the component after the one where it was found
     25 *  (or NULL),
     26 *  you may call find_execable again with this PATHp to continue
     27 *  (if it's not NULL).
     28 * return NULL otherwise; (PATHp is undefined)
     29 * in all cases (*PATHp) contents will be trashed (s/:/NUL/).
    2530 */
    26 char *find_execable(const char *filename)
     31char* FAST_FUNC find_execable(const char *filename, char **PATHp)
    2732{
    28     char *path, *p, *n;
     33    char *p, *n;
    2934
    30     p = path = xstrdup(getenv("PATH"));
     35    p = *PATHp;
    3136    while (p) {
    3237        n = strchr(p, ':');
     
    3641            p = concat_path_file(p, filename);
    3742            if (execable_file(p)) {
    38                 free(path);
     43                *PATHp = n;
    3944                return p;
    4045            }
     
    4247        }
    4348        p = n;
    44     }
    45     free(path);
    46     return NULL;
     49    } /* on loop exit p == NULL */
     50    return p;
    4751}
    4852
     
    5155 * return 0 otherwise;
    5256 */
    53 int exists_execable(const char *filename)
     57int FAST_FUNC exists_execable(const char *filename)
    5458{
    55     char *ret = find_execable(filename);
     59    char *path = xstrdup(getenv("PATH"));
     60    char *tmp = path;
     61    char *ret = find_execable(filename, &tmp);
     62    free(path);
    5663    if (ret) {
    5764        free(ret);
     
    6471/* just like the real execvp, but try to launch an applet named 'file' first
    6572 */
    66 int bb_execvp(const char *file, char *const argv[])
     73int FAST_FUNC bb_execvp(const char *file, char *const argv[])
    6774{
    68     return execvp(find_applet_by_name(file) ? bb_busybox_exec_path : file,
     75    return execvp(find_applet_by_name(file) >= 0 ? bb_busybox_exec_path : file,
    6976                    argv);
    7077}
    7178#endif
     79
     80int FAST_FUNC BB_EXECVP_or_die(char **argv)
     81{
     82    BB_EXECVP(argv[0], argv);
     83    /* SUSv3-mandated exit codes */
     84    xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
     85    bb_perror_msg_and_die("can't execute '%s'", argv[0]);
     86}
Note: See TracChangeset for help on using the changeset viewer.