e2fsprogs/lib/e2p
Andreas Dilger 1e3f5c889d lsattr: treat inode generation as an unsigned int
The EXT2_GETVERSION ioctl is defined to take a "long" parameter, but
fgetversion() calls ioctl() with an "int" parameter instead.  This is
handled in the kernel correctly, but the generation is sign-extended
in fgetversion() before return on 64-bit systems and lsattr prints
it as a huge positive number for inode generation above 0x80000000:

        1635574212 -------------e-- /mnt/ost0/O/0/d0/12928
        18446744073045131735 -------------e-- /mnt/ost0/O/0/d0/166240
        782808861 -------------e-- /mnt/ost0/O/0/d0/31744
        18446744072181134840 -------------e-- /mnt/ost0/O/0/d0/135008

Correctly assign the returned generation number as an unsigned value,
and print it with a 10-character field width.  The version is printed
left-aligned for consistency with the old code and to ensure it is
always printed in the first column for use with tools like "cut":

        1635574212 -------------e-- /mnt/ost0/O/0/d0/12928
        3630547415 -------------e-- /mnt/ost0/O/0/d0/166240
        782808861  -------------e-- /mnt/ost0/O/0/d0/31744
        2766550520 -------------e-- /mnt/ost0/O/0/d0/135008

Do not return a random value from the stack as the version on error.
Clean up some style issues and consolidate some duplicate code.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 18:12:57 -05:00
..
e2p.h libe2p: allow libe2p.h to be used in C++ programs 2014-02-07 17:25:28 -05:00
e2p.pc.in Change pkg-config files so that both <et/com_err.h> and <com_err.h> work 2012-05-14 12:45:54 -04:00
feature.c Add support for new compat feature "sparse_super2" 2014-01-30 13:58:18 -05:00
fgetflags.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
fgetversion.c lsattr: treat inode generation as an unsigned int 2016-03-06 18:12:57 -05:00
fsetflags.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
fsetversion.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
getflags.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
getversion.c Fix gcc -Wall nits 2013-01-01 13:28:27 -05:00
hashstr.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
iod.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
ls.c Add support for new compat feature "sparse_super2" 2014-01-30 13:58:18 -05:00
Makefile.in e2fsprogs: remove checker infrastructure 2014-07-04 23:59:30 -04:00
mntopts.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
ostype.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
parse_num.c e2p: Fix 's' handling in parse_num_blocks2() 2013-02-28 20:12:30 -05:00
pe.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
percent.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
pf.c lsattr, chattr: add support for btrfs's No_COW flag 2012-06-12 17:30:10 -04:00
ps.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
setflags.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
setversion.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00
uuid.c Shorten compile commands run by the build system 2011-09-18 17:34:37 -04:00