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)
 
 FILE_SECBOOT (PERMITTED)
 
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:10
int execv(const char *command, char *const argv[])
Execute command.
Definition: exec.c:61

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 21 of file unistd.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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 61 of file exec.c.

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

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

References udelay().