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

Go to the source code of this file.

Macros

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

Functions

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

Macro Definition Documentation

◆ execl

#define execl (   command,
  arg,
  ... 
)
Value:
( { \
char * const argv[] = { (arg), ## __VA_ARGS__ }; \
int rc = execv ( (command), argv ); \
rc; \
} )
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A command-line command.
Definition: command.h:9
int execv(const char *command, char *const argv[])
Execute command.
Definition: exec.c:60

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()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ execv()

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.

60  {
61  struct command *cmd;
62  int argc;
63  int rc;
64 
65  /* Count number of arguments */
66  for ( argc = 0 ; argv[argc] ; argc++ ) {}
67 
68  /* An empty command is deemed to do nothing, successfully */
69  if ( command == NULL ) {
70  rc = 0;
71  goto done;
72  }
73 
74  /* Sanity checks */
75  if ( argc == 0 ) {
76  DBG ( "%s: empty argument list\n", command );
77  rc = -EINVAL;
78  goto done;
79  }
80 
81  /* Reset getopt() library ready for use by the command. This
82  * is an artefact of the POSIX getopt() API within the context
83  * of Etherboot; see the documentation for reset_getopt() for
84  * details.
85  */
86  reset_getopt();
87 
88  /* Hand off to command implementation */
90  if ( strcmp ( command, cmd->name ) == 0 ) {
91  rc = cmd->exec ( argc, ( char ** ) argv );
92  goto done;
93  }
94  }
95 
96  printf ( "%s: command not found\n", command );
97  rc = -ENOEXEC;
98 
99  done:
100  /* Store error number, if an error occurred */
101  if ( rc ) {
102  errno = rc;
103  if ( errno < 0 )
104  errno = -errno;
105  }
106 
107  return rc;
108 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
A command-line command.
Definition: command.h:9
#define ENOEXEC
Exec format error.
Definition: errno.h:519
int errno
Global "last error" number.
Definition: errno.c:20
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
static void reset_getopt(void)
Reset getopt() internal state.
Definition: getopt.h:89
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:157
#define COMMANDS
Definition: command.h:22
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
struct bofm_section_header done
Definition: bofm_test.c:46

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

Referenced by system(), and time_exec().

◆ usleep()

static __always_inline void usleep ( unsigned long  usecs)
inlinestatic

Definition at line 29 of file unistd.h.

29  {
30  udelay ( usecs );
31 }
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60

References udelay().