libc icon indicating copy to clipboard operation
libc copied to clipboard

android: Can we use proper `libc` typedefs in `stat` definition?

Open danielocfb opened this issue 2 years ago • 1 comments

If we look at the stat type's definition for different platforms, we see:

st_dev: dev_t
st_ino: ino_t
[...]

But for arm-linux-androideabi we stop using libc typedefs and instead have:

st_dev: c_ulonglong
st_mode: c_uint
[...]
st_ino: c_ulonglong

Is there a (good) reason for this divergence? If I look at ino_t it's actually defined to be a c_ulong, not c_ulonglong, so that will lead to mismatches all over the place when the typedefs are used. Is this mandated somewhere, a bug in the platform definition that we need to support? This is a nightmare to support in user code.

danielocfb avatar Jun 27 '23 22:06 danielocfb

Please reference the bionic definition when updating Android libc structures - this is the canonical definition.

Beyond the canonicity, the reason this structure is different is the same reason it's different in e.g. musl - the kernel actually has a differently shaped structure, fills out fewer bits of the inode, etc.

maurer avatar Nov 21 '24 00:11 maurer