* More MIPS stat.h breakage...?
@ 2014-07-16 4:15 Rich Felker
2014-07-16 11:40 ` Isaac Dunham
0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2014-07-16 4:15 UTC (permalink / raw)
To: musl
I thought all of these issues were addressed a long time ago, but I
think we still may have at least one bits-header bug on MIPS big
endian: stat.h. The kernel version of this structure has:
struct stat64 {
unsigned long st_dev;
unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
...
whereas st_dev needs to be dev_t, which is 64-bit.
We're handling this now simply by using the following definition:
struct stat
{
dev_t st_dev;
long __st_padding1[2];
...
i.e. incorporating one of the padding slots into st_dev. But this only
yields the correct value for little endian. For big endian, I think
device numbers are appearing in the upper 32 bits rather than the
lower ones. This renders the major, minor, etc. macros incorrect.
I think the cleanest fix for this is probably to add an arch-specific,
nop-by-default function __stat_fixup or similar that gets called
whenever any stat-family syscall succeeds in order to patch up the
results as needed. Alternatively, we clould do the patchup at the
syscall level for mips' syscall_arch.h, much like how x32 works.
Anyone have strong opinions on how this should be handled?
Rich
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: More MIPS stat.h breakage...?
2014-07-16 4:15 More MIPS stat.h breakage...? Rich Felker
@ 2014-07-16 11:40 ` Isaac Dunham
2014-07-16 14:41 ` Rich Felker
0 siblings, 1 reply; 3+ messages in thread
From: Isaac Dunham @ 2014-07-16 11:40 UTC (permalink / raw)
To: musl
On Wed, Jul 16, 2014 at 12:15:56AM -0400, Rich Felker wrote:
> I thought all of these issues were addressed a long time ago, but I
> think we still may have at least one bits-header bug on MIPS big
> endian: stat.h. The kernel version of this structure has:
>
> struct stat64 {
> unsigned long st_dev;
> unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
> ...
>
> whereas st_dev needs to be dev_t, which is 64-bit.
>
> We're handling this now simply by using the following definition:
>
> struct stat
> {
> dev_t st_dev;
> long __st_padding1[2];
> ...
>
> i.e. incorporating one of the padding slots into st_dev. But this only
> yields the correct value for little endian. For big endian, I think
> device numbers are appearing in the upper 32 bits rather than the
> lower ones. This renders the major, minor, etc. macros incorrect.
>
> I think the cleanest fix for this is probably to add an arch-specific,
> nop-by-default function __stat_fixup or similar that gets called
> whenever any stat-family syscall succeeds in order to patch up the
> results as needed. Alternatively, we clould do the patchup at the
> syscall level for mips' syscall_arch.h, much like how x32 works.
>
> Anyone have strong opinions on how this should be handled?
I seem to remember some comment about trying to work on kernels that predate
stat64(). __stat_fixup would be a logical way to handle that, should that
still be intended.
The most precise information I can find is that stat64() dates to 2.4.18;
I'm not sure about the accuracy of that.
But I don't have a strong opinion; I just noticed a similarity to an idea
that was mentioned some time back.
Also, I'm not aware of any reasons 2.4.1x might be a major target
for musl. ;-)
Thanks,
Isaac Dunham
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: More MIPS stat.h breakage...?
2014-07-16 11:40 ` Isaac Dunham
@ 2014-07-16 14:41 ` Rich Felker
0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2014-07-16 14:41 UTC (permalink / raw)
To: musl
On Wed, Jul 16, 2014 at 04:40:06AM -0700, Isaac Dunham wrote:
> I seem to remember some comment about trying to work on kernels that predate
> stat64(). __stat_fixup would be a logical way to handle that, should that
> still be intended.
The idea of __stat_fixup is that it would patch a broken struct layout
after a successful stat-family call, not make a new syscall. For a new
syscall it would have to be separate workaround code in each variant
(stat, lstat, fstat, fstatat) to do the appropriate workaround for
each. This is a completely different scope.
> The most precise information I can find is that stat64() dates to 2.4.18;
> I'm not sure about the accuracy of that.
>
> But I don't have a strong opinion; I just noticed a similarity to an idea
> that was mentioned some time back.
> Also, I'm not aware of any reasons 2.4.1x might be a major target
> for musl. ;-)
I don't think there's any viable way to support kernels that old even
partially without backporting some essential features.
Rich
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-16 14:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-16 4:15 More MIPS stat.h breakage...? Rich Felker
2014-07-16 11:40 ` Isaac Dunham
2014-07-16 14:41 ` Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).