Thread (4 messages) flat view 4 messages, 3 authors, 2014-03-19

Re: [PATCH 1/1] Work around architectures having statfs.f_type defined as long

From: Arnd Bergmann <arnd@arndb.de>
Date: 2014-03-19 20:43:37

On Wednesday 19 March 2014, Jes.Sorensen@redhat.com wrote:
quoted hunk ↗ jump to hunk
@@ -1946,9 +1946,13 @@ int in_initrd(void)
 {
        /* This is based on similar function in systemd. */
        struct statfs s;
+       /* statfs.f_type is signed long on s390x and MIPS, causing all
+          sorts of sign extension problems with RAMFS_MAGIC being
+          defined as 0x858458f6 */
        return  statfs("/", &s) >= 0 &&
                ((unsigned long)s.f_type == TMPFS_MAGIC ||
-                (unsigned long)s.f_type == RAMFS_MAGIC);
+                ((unsigned long)s.f_type & 0xFFFFFFFFUL) ==
+                ((unsigned long)RAMFS_MAGIC & 0xFFFFFFFFUL));
The comment is wrong: on s390x the type is actually 'unsigned int'.
The fix however works on all variants as far as I can tell.

Thinking about it a bit more, I guess we can also cast both
sides to 'unsigned int' for the same effect and get rid of
the mask.

	Arnd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help