Asking about execv() in os_exec()

최현우 hyeonu.choi at samsung.com
Thu Aug 6 01:14:12 EDT 2015


The commands are like below.
=>
           : 
Executing wpa_cli -ip2p0 -g at android:wpa_wlan0 -p/data/misc/wifi/sockets -a/data/sbin/cli-action.sh &
Executing wpa_cli -ip2p0 -g at android:wpa_wlan0 -p/data/misc/wifi/sockets p2p_connect 02:03:7f:10:4e:fd 12345670 display freq=2442 > /data/misc/wifi/cli_status
execv: Exec format error

Chip vendor put the "cli-action.sh" file into /data/sbin before testing (adb push cli-action.sh /data/sbin/) and run it by using above command.
They said the 'path' , the 1st argument of execv(), is just path without file name
and the action file name should be inputted in 'argv[0]' , the 2nd argument, if we use execv().
And they said the execvp() , execve() can search the action file from PATH variable and run it if the path is not in the arguments.

Thanks,



------- Original Message -------
Sender : Jouni Malinen<j at w1.fi> 
Date   : 2015-08-06 00:45 (GMT+09:00)
Title  : Re: Asking about execv() in os_exec()

On Wed, Aug 05, 2015 at 11:23:40AM +0000, 최현우 wrote:
> <P>The os_exec() added with below patch last year, and the execv(program, argv) has been using in the os_exec() to run external programs.</P>
> <P>However, we met 'execv:Exec format error'&nbsp;with this change&nbsp;when we used '-a' option.</P>

What is the exact value you provide to the -a option as the file path?
Have you tried giving a full path (absolute path starting with '/')?

> <P>Our Wi-Fi chip vendor said the execv() is not proper function, because the first argument of execv()&nbsp;is 'path' , not 'filename'.</P>
> <P>And, they recommended we use execvp() or execve() instead.</P>

execv() is used here on purpose, i.e., the expectation is that absolute
path to the program to be executed is provided.

Could you please describe why there would be need to do searching of the
action script from the path (which is the main difference between
execv() and execvp())?

wpa_cli does actually use environment variables, so there might be other
justification for moving to using execve().

-- 
Jouni Malinen                                            PGP id EFC895FA
<p>&nbsp;</p>


More information about the HostAP mailing list