develooper Front page | perl.perl5.porters | Postings from February 2011

[perl #84590] Inconsistent stat() implementation wrt inode numbers

Thread Next
From:
Peter Rabbitson
Date:
February 22, 2011 01:53
Subject:
[perl #84590] Inconsistent stat() implementation wrt inode numbers
Message ID:
rt-3.6.HEAD-24085-1298308746-1193.84590-75-0@perl.org
# New Ticket Created by  Peter Rabbitson 
# Please include the string:  [perl #84590]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=84590 >



This is a bug report for perl from ribasushi@cpan.org,
generated with the help of perlbug 1.39 running under perl 5.13.10.


-----------------------------------------------------------------
[Please describe your issue here]

This is from an XFS filesystem on a 32bit workstation:

rabbit@Thesaurus:~$ perl -E 'my $fn = "xxx"; my $sys = `stat -c%i "$fn"`; chomp $sys; my $perl = (stat($fn))[1]; die "$fn\tP:$perl\tS:$sys\n" unless $sys == $perl'
xxx   P:-2086220941   S:2208746355

It appears that perl treats ino_t as signed whereas it is overwhelmingly
defined as unsigned:

rabbit@Thesaurus:~$ perl -E 'say unpack("L", pack( "l", -2086220941) )'
2208746355

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html

#p5p backlog:
=================
<Nicholas> the inode has a value so large that it's being treated by perl as a negative number?
<ribasushi> Nicholas: it looks like signed/unsigned problem
<ribasushi> Nicholas: note this is my workstation, not some crazy server
<ribasushi> I just... like to keep things around :)
<ribasushi> also this is a 32bit machine
<Nicholas> I don't *know* if it's a "bug" because I can't find anything via google that says whether ino_t in POSIX is defined to be unsigned
<Zefram> de facto, inode numbers are always interpreted as unsigned
<ilmari>         * fsblkcnt_t, fsfilcnt_t,   and ino_t shall be defined as unsigned integer types.
<ilmari> sys_types.h(7posix)
<ilmari> de jure as well
<ilmari> Nicholas: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html
<Nicholas> ilmari: aha. you win
<ilmari> Nicholas: linked from stat(3posix) via sys/stat.h(7posix)
<ilmari> http://www.opengroup.org/onlinepubs/000095399/functions/stat.html

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl 5.13.10:

Configured by rabbit at Mon Feb 21 14:02:25 CET 2011.

Summary of my perl5 (revision 5 version 13 subversion 10) configuration:
   
  Platform:
    osname=linux, osvers=2.6.32-5-686, archname=i686-linux-thread-multi-64int
    uname='linux thesaurus 2.6.32-5-686 #1 smp wed jan 12 04:01:41 utc 2011 i686 gnulinux '
    config_args='-de -Dprefix=/home/rabbit/perl5/perlbrew/perls/5.13.10 -Dusethreads -Duse64bitint -Dusedevel'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.5', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.11.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.11.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.13.10:
    /home/rabbit/devel/utils/perl
    /home/rabbit/perl5/perlbrew/perls/5.13.10/lib/site_perl/5.13.10/i686-linux-thread-multi-64int
    /home/rabbit/perl5/perlbrew/perls/5.13.10/lib/site_perl/5.13.10
    /home/rabbit/perl5/perlbrew/perls/5.13.10/lib/5.13.10/i686-linux-thread-multi-64int
    /home/rabbit/perl5/perlbrew/perls/5.13.10/lib/5.13.10
    .

---
Environment for perl 5.13.10:
    HOME=/home/rabbit
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_ADDRESS=en_US.UTF-8
    LC_COLLATE=en_US.UTF-8
    LC_CTYPE=en_US.UTF-8
    LC_IDENTIFICATION=en_US.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LC_MONETARY=en_US.UTF-8
    LC_NAME=en_US.UTF-8
    LC_NUMERIC=en_US.UTF-8
    LC_TELEPHONE=en_US.UTF-8
    LC_TIME=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/rabbit/devel/utils:/home/rabbit/perl5/perlbrew/bin:/home/rabbit/perl5/perlbrew/perls/current/bin:/home/rabbit/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
    PERL5LIB=/home/rabbit/devel/utils/perl:
    PERL_AUTOINSTALL_PREFER_CPAN=1
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About