Skip to content

Commit

Permalink
Added 2 new time64 wrapped libc functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Jul 16, 2024
1 parent f6a5322 commit a187c7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/wrapped/wrappedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,34 @@ EXPORT int32_t my_fcntl(x86emu_t* emu, int32_t a, int32_t b, uint32_t d1, uint32
}
EXPORT int32_t my___fcntl(x86emu_t* emu, int32_t a, int32_t b, uint32_t d1, uint32_t d2, uint32_t d3, uint32_t d4, uint32_t d5, uint32_t d6) __attribute__((alias("my_fcntl")));

EXPORT int32_t my_fcntl_time64(x86emu_t* emu, int32_t a, int32_t b, uint32_t d1, uint32_t d2, uint32_t d3, uint32_t d4, uint32_t d5, uint32_t d6)
{
(void)emu; (void)d2; (void)d3; (void)d4; (void)d5; (void)d6;
// Implemented starting glibc 2.14+
library_t* lib = my_lib;
if(!lib) return 0;
iFiiV_t f = dlsym(lib->w.lib, "fcntl_time64");
if(b==F_SETFL)
d1 = of_convert(d1);
if(b==F_GETLK64 || b==F_SETLK64 || b==F_SETLKW64)
{
my_flock64_t fl;
AlignFlock64(&fl, (void*)d1);
int ret = f?f(a, b, &fl):fcntl(a, b, &fl);
UnalignFlock64((void*)d1, &fl);
return ret;
}
//TODO: check if better to use the syscall or regular fcntl?
//return syscall(__NR_fcntl64, a, b, d1); // should be enough
int ret = f?f(a, b, d1):fcntl(a, b, d1);

if(b==F_GETFL && ret!=-1)
ret = of_unconvert(ret);

return ret;
}


EXPORT int32_t my_preadv64(x86emu_t* emu, int32_t fd, void* v, int32_t c, int64_t o)
{
(void)emu;
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped/wrappedlibc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2241,9 +2241,11 @@ GO(asctime64_r, pFpp)
GO(ctime64, pFp)
GO(ctime64_r, pFpp)
GO(gmtime64, pFp)
GOM(fcntl_time64, iFEiiN) //%%
GO(gmtime64_r, pFpp)
GO(localtime64, pFpp)
GO(localtime64_r, pFpp)
GO(ppoll64, iFpupp)
GO(__clock_gettime64, iFpp)
GO(__stat_time64, iFpp) //needs alignement?
GO(__fstat_time64, iFip)
Expand Down

0 comments on commit a187c7c

Please sign in to comment.