diff --git a/libnozzle/internals.c b/libnozzle/internals.c index 24d988d8e..b2ed26aab 100644 --- a/libnozzle/internals.c +++ b/libnozzle/internals.c @@ -22,7 +22,7 @@ #include "libnozzle.h" #include "internals.h" -static int _read_pipe(int fd, char **file, size_t *length) +static int read_pipe(int fd, char **file, size_t *length) { char buf[4096]; int n; @@ -71,7 +71,7 @@ static int _read_pipe(int fd, char **file, size_t *length) return 0; } -int _execute_shell(const char *command, char **error_string) +int execute_shell_command(const char *command, char **error_string) { pid_t pid; int status, err = 0; @@ -98,7 +98,7 @@ int _execute_shell(const char *command, char **error_string) if (pid) { /* parent */ close(fd[1]); - err = _read_pipe(fd[0], error_string, &size); + err = read_pipe(fd[0], error_string, &size); if (err) goto out_clean0; @@ -134,7 +134,7 @@ int _execute_shell(const char *command, char **error_string) return err; } -int _exec_updown(const nozzle_t nozzle, const char *action, char **error_string) +int run_updown(const nozzle_t nozzle, const char *action, char **error_string) { char command[PATH_MAX]; struct stat sb; @@ -151,7 +151,7 @@ int _exec_updown(const nozzle_t nozzle, const char *action, char **error_string) if ((err < 0) && (errno == ENOENT)) return 0; - err = _execute_shell(command, error_string); + err = execute_shell_command(command, error_string); if ((!err) && (*error_string)) { free(*error_string); *error_string = NULL; diff --git a/libnozzle/internals.h b/libnozzle/internals.h index 166f87006..de7214ee1 100644 --- a/libnozzle/internals.h +++ b/libnozzle/internals.h @@ -60,7 +60,7 @@ struct nozzle_iface { #define ifname ifr.ifr_name -int _execute_shell(const char *command, char **error_string); -int _exec_updown(const nozzle_t nozzle, const char *action, char **error_string); +int execute_shell_command(const char *command, char **error_string); +int run_updown(const nozzle_t nozzle, const char *action, char **error_string); #endif diff --git a/libnozzle/libnozzle.c b/libnozzle/libnozzle.c index 6d4efb303..009816d4a 100644 --- a/libnozzle/libnozzle.c +++ b/libnozzle/libnozzle.c @@ -691,7 +691,7 @@ int nozzle_set_up(nozzle_t nozzle, char **error_preup, char **error_up) goto out_clean; } - _exec_updown(nozzle, "pre-up.d", error_preup); + run_updown(nozzle, "pre-up.d", error_preup); ifr.ifr_flags |= IFF_UP | IFF_RUNNING; err = ioctl(lib_cfg.ioctlfd, SIOCSIFFLAGS, &ifr); @@ -700,7 +700,7 @@ int nozzle_set_up(nozzle_t nozzle, char **error_preup, char **error_up) goto out_clean; } - _exec_updown(nozzle, "up.d", error_up); + run_updown(nozzle, "up.d", error_up); nozzle->up = 1; @@ -728,7 +728,7 @@ static int _set_down(nozzle_t nozzle, char **error_down, char **error_postdown) goto out_clean; } - _exec_updown(nozzle, "down.d", error_down); + run_updown(nozzle, "down.d", error_down); ifr.ifr_flags &= ~IFF_UP; @@ -738,7 +738,7 @@ static int _set_down(nozzle_t nozzle, char **error_down, char **error_postdown) goto out_clean; } - _exec_updown(nozzle, "post-down.d", error_postdown); + run_updown(nozzle, "post-down.d", error_postdown); nozzle->up = 0; @@ -872,7 +872,7 @@ static int _set_ip(nozzle_t nozzle, const char *command, if (broadcast) { free(broadcast); } - return _execute_shell(cmdline, error_string); + return execute_shell_command(cmdline, error_string); } static int _find_ip(nozzle_t nozzle, diff --git a/libnozzle/tests/nozzle_test.c b/libnozzle/tests/nozzle_test.c index f8683b635..e892d351b 100644 --- a/libnozzle/tests/nozzle_test.c +++ b/libnozzle/tests/nozzle_test.c @@ -448,7 +448,7 @@ static int check_knet_mtu_ipv6(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv6_1); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -471,7 +471,7 @@ static int check_knet_mtu_ipv6(void) goto out_clean; } - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -509,7 +509,7 @@ static int check_knet_mtu_ipv6(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv6_2); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -540,7 +540,7 @@ static int check_knet_mtu_ipv6(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv6_1); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -560,7 +560,7 @@ static int check_knet_mtu_ipv6(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv6_2); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -705,7 +705,7 @@ static int check_knet_mac(void) return err; } -static int check_nozzle_execute_shell(void) +static int check_nozzle_execute_shell_command(void) { int err = 0; char command[4096]; @@ -713,11 +713,11 @@ static int check_nozzle_execute_shell(void) memset(command, 0, sizeof(command)); - printf("Testing _execute_shell\n"); + printf("Testing execute_shell_command\n"); printf("command true\n"); - err = _execute_shell("true", &error_string); + err = execute_shell_command("true", &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -732,7 +732,7 @@ static int check_nozzle_execute_shell(void) printf("command false\n"); - err = _execute_shell("false", &error_string); + err = execute_shell_command("false", &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -746,7 +746,7 @@ static int check_nozzle_execute_shell(void) printf("command that outputs to stdout (enforcing redirect)\n"); - err = _execute_shell("grep -h 2>&1", &error_string); + err = execute_shell_command("grep -h 2>&1", &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -759,7 +759,7 @@ static int check_nozzle_execute_shell(void) } printf("command that outputs to stderr\n"); - err = _execute_shell("grep -h", &error_string); + err = execute_shell_command("grep -h", &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -772,7 +772,7 @@ static int check_nozzle_execute_shell(void) } printf("empty command\n"); - err = _execute_shell(NULL, &error_string); + err = execute_shell_command(NULL, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -785,7 +785,7 @@ static int check_nozzle_execute_shell(void) } printf("empty error\n"); - err = _execute_shell("true", NULL); + err = execute_shell_command("true", NULL); if (!err) { printf("Check EINVAL filter for no error_string!\n"); err = -1; @@ -846,7 +846,7 @@ static int check_knet_up_down(void) #ifdef KNET_BSD "ifconfig %s | grep -q UP", nozzle->name); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -885,7 +885,7 @@ static int check_knet_up_down(void) #ifdef KNET_BSD "ifconfig %s | grep -q UP", nozzle->name); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -1231,7 +1231,7 @@ static int check_knet_set_del_ip(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv4_1); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -1315,7 +1315,7 @@ static int check_knet_set_del_ip(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv4_1); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -1349,7 +1349,7 @@ static int check_knet_set_del_ip(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv6_1); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -1383,7 +1383,7 @@ static int check_knet_set_del_ip(void) #ifdef KNET_BSD "ifconfig %s | grep -q %s", nozzle->name, testipv6_1); #endif - err = _execute_shell(verifycmd, &error_string); + err = execute_shell_command(verifycmd, &error_string); if (error_string) { printf("Error string: %s\n", error_string); free(error_string); @@ -1491,7 +1491,7 @@ int main(void) if (check_knet_mac() < 0) return -1; - if (check_nozzle_execute_shell() < 0) + if (check_nozzle_execute_shell_command() < 0) return -1; if (check_knet_up_down() < 0)