• Andrew Morton's avatar
    [PATCH] struct stat - support larger dev_t · e95b2065
    Andrew Morton authored
    From: Andries.Brouwer@cwi.nl
    
    Below a patch that changes struct stat for a number of
    architectures. Maintainers, please watch carefully.
    
    Struct stat is used to transfer information from kernel
    to user space on a stat() system call.
    It has fields st_dev, st_rdev.
    
    The size of these fields is in principle unrelated to
    the size of a dev_t in user space or the size of a
    dev_t or kdev_t in kernel space.
    
    It is just the "capacity" of the channel.
    The actual amount of useful information is the minimum
    of the four sizes (kernel dev_t, kernel kdev_t,
    user dev_t, width of stat st_dev, st_rdev fields).
    
    The goal of this patch is to make sure that the stat() and stat64()
    system calls transmit at least 32 and 64 bits, respectively.
    This is achieved by using the padding that was present already.
    We fail when no padding was present, or when the padding is on
    the wrong side (after the field, while the machine is big-endian).
    
    alpha:	stat: uses unsigned int, 32 bits
    arm:	stat: uses unsigned short - bad.
    	The padding is on one side, which means that this can
    	be made into unsigned long only on little endian systems.
    	FIXED - unless __ARMEB__.
    	stat64: used unsigned short - FIXED, now unsigned long long.
    cris:	stat: used unsigned short - FIXED, now unsigned long
    	stat64: used unsigned short - FIXED, now unsigned long long.
    i386:	stat: used unsigned short - FIXED, now unsigned long
    	stat64: used unsigned short - FIXED, now unsigned long long.
    ia64:	stat: uses unsigned long, 64 bits
    m68k:	stat: used unsigned short - bad, but this cannot be fixed
    	since m68k is big-endian, and the available padding is on
    	the wrong side. NOT FIXED.
    	stat64: used unsigned short - FIXED, now unsigned long long.
    mips:	stat: uses dev_t which is unsigned int, 32 bits
    	stat64: used unsigned long, 32 bits. NOT FIXED.
    	(There is padding on one side, so this can be fixed if __MIPSEL__.)
    mips64:	stat: uses dev_t which is unsigned int, 32 bits
    parisc:	stat: uses dev_t, 32 bits
    	stat64: uses unsigned long long, 64 bits
    ppc:	stat: uses dev_t which is unsigned int, 32 bits
    	stat64: unsigned long long, 64 bits
    ppc64:	stat: uses dev_t which is unsigned long, 64 bits
    	stat64: uses unsigned long, 64 bits
    sparc:	stat: uses unsigned short, no padding. NOT FIXED.
    	stat64: used unsigned short - FIXED, now unsigned long long.
    sparc64:stat: uses dev_t which is unsigned int, 32 bits
    	stat64: used unsigned short - FIXED, now unsigned long long.
    s390:	stat: used unsigned short, big-endian, padding on the wrong side,
    	NOT FIXED.
    	stat64: used unsigned short - FIXED, now unsigned long long.
    s390x:	stat: uses unsigned long, 64 bits
    sh:	stat: used unsigned short, but padding maybe on wrong side.
    	NOT FIXED.
    	stat64: used unsigned short - FIXED, now unsigned long long.
    v850:	stat: used __kernel_dev_t.
    	BUG: NEVER use __kernel types in a user space interface.
    	Replaced the types. FIXED - now unsigned int - 32 bits.
    	stat64: FIXED - now unsigned long long - 64 bits.
    x86_64:	stat: uses unsigned long, 64 bits
    
    So, on most architectures we achieve the aim of 32 bits for stat,
    64 bits for stat64. On all architectures we achieve at least
    16 bits for stat, 32 bits for stat64.
    e95b2065
stat.h 1.38 KB