where is fdatasync(int) implemented?

235 views
Skip to first unread message

Kenny Yu

unread,
Jul 2, 2009, 8:16:29 AM7/2/09
to android-porting
I am porting a C program. Very simple - it refers to a C function
declared in BIONIC libc:

device/bionic/libc/include/unistd.h
at line 142 (CUPCAKE version) as
extern int fdatasync(int);

Link failure is seen because libc.so doesn't have the implementation:
external/sysstat/sadc.c:901: undefined reference to `fdatasync'
collect2: ld returned 1 exit status

Can anyone figure out where the function fdatasync() is implemented?

It should call syscall fdatasync eventually.

Kenny

Michael Trimarchi

unread,
Jul 2, 2009, 8:16:17 AM7/2/09
to android...@googlegroups.com
Kenny Yu wrote:
> I am porting a C program. Very simple - it refers to a C function
> declared in BIONIC libc:
>
> device/bionic/libc/include/unistd.h
> at line 142 (CUPCAKE version) as
> extern int fdatasync(int);
>
> Link failure is seen because libc.so doesn't have the implementation:
> external/sysstat/sadc.c:901: undefined reference to `fdatasync'
> collect2: ld returned 1 exit status
>
> Can anyone figure out where the function fdatasync() is implemented?
>
I think that is a syscall so just add to the syscall list.
Michael

Kenny

unread,
Jul 2, 2009, 8:25:59 AM7/2/09
to android-porting
Yes, it is. The linker "ld" fails to find the symbol fdatasync. How to
get it found? And trick in Android.mk?
Kenny

On Jul 2, 8:16 pm, Michael Trimarchi <trimar...@gandalf.sssup.it>
wrote:
> > Kenny- Hide quoted text -
>
> - Show quoted text -

Michael Trimarchi

unread,
Jul 2, 2009, 8:29:05 AM7/2/09
to android...@googlegroups.com

Hi,

Kenny wrote:
> Yes, it is. The linker "ld" fails to find the symbol fdatasync. How to
> get it found? And trick in Android.mk?
> Kenny
>
Add to the bionic SYSCALL.txt and call the python script gensyscall.py.
I hope
that it fix your issue

Michael

Kenny

unread,
Jul 2, 2009, 8:38:39 AM7/2/09
to android-porting
Thank you, Mike. You show great skill:)
I won't touch Google code here. I just fixed it this way (learn from
external/sqlite/dist/sqlite3.c):
/*
** Use the fdatasync() API only if the HAVE_FDATASYNC macro is
defined.
** Otherwise use fsync() in its place.
*/
#ifndef HAVE_FDATASYNC
# define fdatasync fsync
#endif

Reading bionic/libc/include/sys/linux-unistd.h (generated by Google as
you mentioned), I found only fsync() was implemented.

Kenny

On Jul 2, 8:29 pm, Michael Trimarchi <trimar...@gandalf.sssup.it>
> >> - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages