[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Inconsistency about struct stat and dev_t on mips and mipsel


On Mon, 2015-09-14 at 15:53 +0200, Thomas Schmitt wrote:
> Since quite a while the buildd logs of libisoburn on mips and
> mipsel show a riddling warning, which may actually indicate a
> serious bug in the resulting binaries:
>   https://buildd.debian.org/status/fetch.php?pkg=libisoburn&arch=mips&ver=1.4.0-3&stamp=1442236259
>   xorriso/iso_tree.c: In function 'Xorriso_fake_stbuf':
>   xorriso/iso_tree.c:282:47: warning: passing argument 4 of 'Xorriso_node_get_dev' from incompatible pointer type [-Wincompatible-pointer-types]
>       Xorriso_node_get_dev(xorriso, *node, path, &(stbuf->st_rdev), 0);
>                                                ^
>   xorriso/iso_tree.c:229:5: note: expected 'dev_t * {aka long long unsigned int *}' but argument is of type 'long unsigned int *'
>    int Xorriso_node_get_dev(struct XorrisO *xorriso, IsoNode *node,
> The inconsistency is that "stbuf" is declared as
>   struct stat *stbuf
> and POSIX compliant man 2 stat declares 
>   struct stat {
>       ...
>       dev_t     st_rdev;        /* device ID (if special file) */
>       ...
>   };

Yes, for historical reasons mips (o32) defines struct stat with a 32
-bit dev_t even though it defines dev_t to be 64-bits. It's been
defined this way since at least 1997 when mips was added to glibc (I
expect the structure was copied from old SGI libc). This means that
what you are doing really is undefined behaviour on mips :(

There is an upstream bug about it here:

Changing it in glibc isn't too hard except it will break the ABI of any
shared libraries which use 'struct stat *' in their interface (glibc
itself will use symbol versions).


Attachment: signature.asc
Description: This is a digitally signed message part

Reply to: