How to get current working directory from Android Linux to help debug a file not found issue?

299 views
Skip to first unread message

Dave McLaughlin

unread,
Apr 1, 2020, 12:58:45 PM4/1/20
to android-porting
I am trying to track down a file not found error in a Realtek WiFi driver and I am trying to get the current working directory and print this to the debug output.

I can't find which header file getcwd() is located in. Most website searches indicate to use <linux/unistd.g> but this doesn't work and I get a compiler error when I try to use getcwd()

A search of the Linux source finds many references to this function.

Glenn Kasten

unread,
Apr 1, 2020, 1:00:48 PM4/1/20
to android-porting
Did you try <unistd.h>  ?  Note the "h" not "g" at end, and no leading "linux/"

Dave McLaughlin

unread,
Apr 2, 2020, 11:27:58 AM4/2/20
to android-porting
Yes, tried that and I get a file not found for that header file.

With the leading linux/ it finds the file but the header file does not contain a reference to that function.

There are over 50 files called unistd.h in the source.

I am trying to compile drivers/base/firmware_class.c to add some diagnostics to see why the wifi driver gives file not found.

Martin Brabham

unread,
Apr 6, 2020, 12:05:34 PM4/6/20
to davemcla...@gmail.com, android-porting
Do you have your includes setup to target bionic/libc/include?

bionic/libc/include/unistd.h

Line 229: char* getcwd(char* __buf, size_t __size);

--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/da43688c-e590-423f-8d10-ffc1ad9ee3aa%40googlegroups.com.


--


  •  Martin Brabham

  •  Software Engineer
  •  Android Bluetooth
  •  352.327.8280


Dave McLaughlin

unread,
Apr 7, 2020, 1:19:54 PM4/7/20
to android-porting
Those files are in the Android source but not in the Linux kernel. 

The driver is at the kernel level and I need some way to display the current working directory that the driver is attempting to load the BIN file from. 

There is a load of unistd.h files in the kernel source tree but none of them contain the getcwd() function.


On Monday, 6 April 2020 23:05:34 UTC+7, Martin Brabham wrote:
Do you have your includes setup to target bionic/libc/include?

bionic/libc/include/unistd.h

Line 229: char* getcwd(char* __buf, size_t __size);

On Thu, Apr 2, 2020 at 8:27 AM Dave McLaughlin <davemcla...@gmail.com> wrote:
Yes, tried that and I get a file not found for that header file.

With the leading linux/ it finds the file but the header file does not contain a reference to that function.

There are over 50 files called unistd.h in the source.

I am trying to compile drivers/base/firmware_class.c to add some diagnostics to see why the wifi driver gives file not found.

On Thursday, 2 April 2020 00:00:48 UTC+7, Glenn Kasten wrote:
Did you try <unistd.h>  ?  Note the "h" not "g" at end, and no leading "linux/"


--
--

website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages