iPXE
Defines | Functions
unistd.h File Reference
#include <stddef.h>
#include <stdarg.h>
#include <ipxe/timer.h>

Go to the source code of this file.

Defines

#define execl(command, arg,...)
 Execute command.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
int execv (const char *command, char *const argv[])
 Execute command.
static __always_inline void usleep (unsigned long usecs)

Define Documentation

#define execl (   command,
  arg,
  ... 
)
Value:
( {                                     \
                char * const argv[] = { (arg), ## __VA_ARGS__ };        \
                int rc = execv ( (command), argv );                     \
                rc;                                                     \
        } )

Execute command.

Parameters:
commandCommand name
arg... Argument list (starting with argv[0])
Return values:
rcCommand exit status

This is a front end to execv().

Definition at line 20 of file unistd.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
int execv ( const char *  command,
char *const  argv[] 
)

Execute command.

Parameters:
commandCommand name
argvArgument list
Return values:
rcReturn status code

Execute the named command. Unlike a traditional POSIX execv(), this function returns the exit status of the command.

Definition at line 60 of file exec.c.

References cmd, COMMANDS, DBG, done, EINVAL, ENOEXEC, errno, command::exec, for_each_table_entry, command::name, NULL, printf(), rc, reset_getopt(), and strcmp().

Referenced by system(), and time_exec().

                                                       {
        struct command *cmd;
        int argc;
        int rc;

        /* Count number of arguments */
        for ( argc = 0 ; argv[argc] ; argc++ ) {}

        /* An empty command is deemed to do nothing, successfully */
        if ( command == NULL ) {
                rc = 0;
                goto done;
        }

        /* Sanity checks */
        if ( argc == 0 ) {
                DBG ( "%s: empty argument list\n", command );
                rc = -EINVAL;
                goto done;
        }

        /* Reset getopt() library ready for use by the command.  This
         * is an artefact of the POSIX getopt() API within the context
         * of Etherboot; see the documentation for reset_getopt() for
         * details.
         */
        reset_getopt();

        /* Hand off to command implementation */
        for_each_table_entry ( cmd, COMMANDS ) {
                if ( strcmp ( command, cmd->name ) == 0 ) {
                        rc = cmd->exec ( argc, ( char ** ) argv );
                        goto done;
                }
        }

        printf ( "%s: command not found\n", command );
        rc = -ENOEXEC;

 done:
        /* Store error number, if an error occurred */
        if ( rc ) {
                errno = rc;
                if ( errno < 0 )
                        errno = -errno;
        }

        return rc;
}
static __always_inline void usleep ( unsigned long  usecs) [inline, static]

Definition at line 29 of file unistd.h.

References udelay().

                                                                  {
        udelay ( usecs );
}