Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat() returns bad value for ino on Windows for Active Perl #9719

Closed
p5pRT opened this issue Apr 23, 2009 · 10 comments
Closed

stat() returns bad value for ino on Windows for Active Perl #9719

p5pRT opened this issue Apr 23, 2009 · 10 comments
Labels
Win32 This is a meta-ticket to tag issues in the perl core which need attention on Win32. See #11925

Comments

@p5pRT
Copy link

p5pRT commented Apr 23, 2009

Migrated from rt.perl.org#65052 (status was 'rejected')

Searchable as RT65052$

@p5pRT
Copy link
Author

p5pRT commented Apr 23, 2009

From vassili.gorshkov@associates.dhs.gov

Problem​: stat function return incorrect value for 'ino' field on
Windows.

This works fine with cygwin perl.

#######################################

# Start the test case

#######################################

my $filename = "myfile.txt";

my @​fs = stat($filename);

open $fh, "< " . $filename or die "create a file \"$filename\" to
reproduce";

my $ino = $fs[1];

$ino != 0 or die "bad ino value from stat, this works OK with cygwin
perl";

print "Got a good ino value $ino\n";

#######################################

# End the test case

#######################################


Flags​:

  category=

  severity=


Site configuration information for perl 5.10.0​:

Configured by SYSTEM at Wed Sep 3 13​:16​:08 2008.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:

  Platform​:

  osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread

  uname=''

  config_args='undef'

  hint=recommended, useposix=true, d_sigaction=undef

  useithreads=define, usemultiplicity=define

  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef

  use64bitint=undef, use64bitall=undef, uselongdouble=undef

  usemymalloc=n, bincompat5005=undef

  Compiler​:

  cc='gcc', ccflags ='-DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT
-DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-DPERL_MSVCRT_READFIX -DHASATTRIBUTE -fno-strict-aliasing
-mms-bitfields',

  optimize='-O2',

  cppflags='-DWIN32'

  ccversion='', gccversion='undef', gccosandvers=''

  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234

  d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10

  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
lseeksize=8

  alignbytes=8, prototype=define

  Linker and Libraries​:

  ld='g++', ldflags ='-L"C​:\Perl\lib\CORE"'

  libpth=\lib

  libs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm
-lversion -lodbc32 -lodbccp32 -lmsvcrt

  perllibs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lmsvcrt

  libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl510.lib

  gnulibc_version=''

  Dynamic Linking​:

  dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '

  cccdlflags=' ', lddlflags='-mdll -L"C​:\Perl\lib\CORE"'

Locally applied patches​:

  ACTIVEPERL_LOCAL_PATCHES_ENTRY

  33741 avoids segfaults invoking S_raise_signal() (on Linux)

  33763 Win32 process ids can have more than 16 bits

  32809 Load 'loadable object' with non-default file extension

  32728 64-bit fix for Time​::Local


@​INC for perl 5.10.0​:

  c​:/perl/site/lib

  c​:/perl/lib

  .


Environment for perl 5.10.0​:

  HOME (unset)

  LANG (unset)

  LANGUAGE (unset)

  LD_LIBRARY_PATH (unset)

  LOGDIR (unset)

  PATH=c​:\perl\bin;C​:\Program Files\IBM\GSK5\lib;C​:\Program
Files\IBM\tivoli\MA\bin\w32-ix86;C​:\Serena\Dimensions
10.1\CM\prog;C​:\Program
Files\Java\jre1.5.0_11\bin;C​:\oracle\ora92\bin;C​:\Program
Files\Oracle\jre\1.3.1\bin;C​:\Program
Files\Oracle\jre\1.1.8\bin;C​:\WINDOWS\system32;C​:\WINDOWS;C​:\PVCS\Dimens
ions\7.2\prog;C​:\Serena\CHANGE1\DIMENS1\9.1\PROG;C​:\WINDOWS\System32\W
bem;C​:\WINDOWS\system32\nls;C​:\WINDOWS\system32\nls\ENGLISH;C​:\mq53\bin;
C​:\mq53\tools\c\samples\bin;C​:\Program Files\maven-2.0.4\bin;C​:\Program
Files\ATI Technologies\ATI.ACE" /f;c​:\cygwin\bin;

  PERL_BADLANG (unset)

  SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Aug 13, 2012

From @jkeenan

On Thu Apr 23 10​:40​:15 2009, vassili.gorshkov@​associates.dhs.gov wrote​:

Problem​: stat function return incorrect value for 'ino' field on
Windows.

This works fine with cygwin perl.

#######################################

# Start the test case

#######################################
my $filename = "myfile.txt";
my @​fs = stat($filename);
open $fh, "< " . $filename or die "create a file \"$filename\" to
reproduce";

my $ino = $fs[1];
$ino != 0 or die "bad ino value from stat, this works OK with cygwin
perl";

print "Got a good ino value $ino\n";
#######################################

# End the test case

#######################################

Is there anyone on win32, particularly Active Perl, who could confirm
this problem, particularly on supported versions of Windows and Perl?

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Aug 13, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 14, 2012

From @bulk88

On Mon Aug 13 16​:58​:57 2012, jkeenan wrote​:

Is there anyone on win32, particularly Active Perl, who could confirm
this problem, particularly on supported versions of Windows and Perl?

Thank you very much.
Jim Keenan

Using Perl 5.17 VS 2003 DEBUGGING build, NTFS C​: disk. WinXP.
__________________________________________________
C​:\Documents and Settings\Owner\Desktop>perl ino.pl
bad ino value from stat, this works OK with cygwin
perl at ino.pl line 22.

C​:\Documents and Settings\Owner\Desktop>
__________________________________________________
in MS's CRT in _stati64
__________________________________________________
  buf->st_uid = buf->st_gid = buf->st_ino = 0;
__________________________________________________
so MS CRT doesn't support inode numbers
__________________________________________________
C​:\Documents and Settings\Owner\Desktop>perl ino2.pl
$VAR1 = [
  2,
  0,
  33206,
  1,
  0,
  0,
  2,
  '0',
  1344913976,
  1344913976,
  1344913976,
  '',
  ''
  ];
bad ino value from stat, this works OK with cygwin
perl at ino2.pl line 23.

C​:\Documents and Settings\Owner\Desktop>
_____________________________________________
I think this is a wont fix. Windows NT native inodes, are available
through
http​://msdn.microsoft.com/en-us/library/windows/hardware/ff540318%28v=vs.85%29.aspx
. Cygwin uses a combination of the previous, along with a fallback to
path name hashing on "broken" filing systems (local and remote). I dont
think there is a demand to implement this feature in VC/Strawberry MS
CRT Perl.

@p5pRT
Copy link
Author

p5pRT commented Aug 14, 2012

From @bulk88

ino2.pl

@p5pRT
Copy link
Author

p5pRT commented Aug 14, 2012

From @bulk88

ino.pl

@p5pRT
Copy link
Author

p5pRT commented Oct 7, 2015

From @jkeenan

On Mon Aug 13 21​:04​:46 2012, bulk88 wrote​:

On Mon Aug 13 16​:58​:57 2012, jkeenan wrote​:

Is there anyone on win32, particularly Active Perl, who could confirm
this problem, particularly on supported versions of Windows and Perl?

Thank you very much.
Jim Keenan

Using Perl 5.17 VS 2003 DEBUGGING build, NTFS C​: disk. WinXP.
__________________________________________________
C​:\Documents and Settings\Owner\Desktop>perl ino.pl
bad ino value from stat, this works OK with cygwin
perl at ino.pl line 22.

C​:\Documents and Settings\Owner\Desktop>
__________________________________________________
in MS's CRT in _stati64
__________________________________________________
buf->st_uid = buf->st_gid = buf->st_ino = 0;
__________________________________________________
so MS CRT doesn't support inode numbers
__________________________________________________
C​:\Documents and Settings\Owner\Desktop>perl ino2.pl
$VAR1 = [
2,
0,
33206,
1,
0,
0,
2,
'0',
1344913976,
1344913976,
1344913976,
'',
''
];
bad ino value from stat, this works OK with cygwin
perl at ino2.pl line 23.

C​:\Documents and Settings\Owner\Desktop>
_____________________________________________
I think this is a wont fix. Windows NT native inodes, are available
through
http​://msdn.microsoft.com/en-
us/library/windows/hardware/ff540318%28v=vs.85%29.aspx
. Cygwin uses a combination of the previous, along with a fallback to
path name hashing on "broken" filing systems (local and remote). I
dont
think there is a demand to implement this feature in VC/Strawberry MS
CRT Perl.

On IRC #p5p, bulk88 indicated that he thought this ticket should be closed. Am taking it for the purpose of closing it within 7 days unless there is compelling reason to keep it open.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2015

From @jkeenan

On Tue Oct 06 18​:42​:04 2015, jkeenan wrote​:

On Mon Aug 13 21​:04​:46 2012, bulk88 wrote​:

On Mon Aug 13 16​:58​:57 2012, jkeenan wrote​:

Is there anyone on win32, particularly Active Perl, who could
confirm
this problem, particularly on supported versions of Windows and
Perl?

Thank you very much.
Jim Keenan

Using Perl 5.17 VS 2003 DEBUGGING build, NTFS C​: disk. WinXP.
__________________________________________________
C​:\Documents and Settings\Owner\Desktop>perl ino.pl
bad ino value from stat, this works OK with cygwin
perl at ino.pl line 22.

C​:\Documents and Settings\Owner\Desktop>
__________________________________________________
in MS's CRT in _stati64
__________________________________________________
buf->st_uid = buf->st_gid = buf->st_ino = 0;
__________________________________________________
so MS CRT doesn't support inode numbers
__________________________________________________
C​:\Documents and Settings\Owner\Desktop>perl ino2.pl
$VAR1 = [
2,
0,
33206,
1,
0,
0,
2,
'0',
1344913976,
1344913976,
1344913976,
'',
''
];
bad ino value from stat, this works OK with cygwin
perl at ino2.pl line 23.

C​:\Documents and Settings\Owner\Desktop>
_____________________________________________
I think this is a wont fix. Windows NT native inodes, are available
through
http​://msdn.microsoft.com/en-
us/library/windows/hardware/ff540318%28v=vs.85%29.aspx
. Cygwin uses a combination of the previous, along with a fallback to
path name hashing on "broken" filing systems (local and remote). I
dont
think there is a demand to implement this feature in VC/Strawberry MS
CRT Perl.

On IRC #p5p, bulk88 indicated that he thought this ticket should be
closed. Am taking it for the purpose of closing it within 7 days
unless there is compelling reason to keep it open.

No one spoke up in favor of keeping this ticket open; closing.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2015

@jkeenan - Status changed from 'open' to 'rejected'

@p5pRT p5pRT closed this as completed Oct 14, 2015
@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2015

From @bulk88

On Tue Oct 06 18​:42​:04 2015, jkeenan wrote​:

On IRC #p5p, bulk88 indicated that he thought this ticket should be
closed. Am taking it for the purpose of closing it within 7 days
unless there is compelling reason to keep it open.

Thank you very much.

I'll add my IRC comments to this ticket. Perl's Win32 stat is already 6-10 IO calls http​://perl5.git.perl.org/perl.git/blob/HEAD​:/win32/win32.c#l1457 . Too many of them. Getting the inode will be another 1 or 3 IO calls (open handle, query handle (FileInternalInformation), close handle). AFAIK there are 2 purposes to knowing the inode. Detecting links (same file) and undeleting files. Since hardlinks are rare on Win32, and AFAIK you can't undelete a file, there isn't much use in knowing the inode. Since it hasn't been known for 15 years on Win32 Perl to Perl code, it can continue to be unknown. I'd only support the idea of more IO calls for win32 stat if it is turned on with hints hash/"use feature" which has a fast execution path for "no feature" branch if I am reading FEATURE_IS_ENABLED macro correctly.

Ignoring my IRC comments, actually, maybe inode is already being fetched by win32_stat, https://msdn.microsoft.com/en-us/library/windows/desktop/aa363788%28v=vs.85%29.aspx win32 API (not Native API) GetFileInformationByHandle has a nFileIndexHigh and a nFileIndexLow member which are the inode number. win32_stat already has a GetFileInformationByHandle call in perl c code. It would be trivial to copy the inode number over, but the MS stat_t struct has st_ino as a 16 bit short. Not enough space to store a 64 bit kernel inode. Changing perl's Stat_t type to a custom perl type and not MS libc type would be required. Also Perl already ***ROUNDS*** the inode number if inode type > UV type. http​://perl5.git.perl.org/perl.git/commitdiff/8d8cba88681398d40004e97bcb93f7f8b88ae05e I think that is questionable. Perhaps a die if > 2^53 is appropriate than rounding inodes, which I say is the same thing and as dangerous as stuffing C pointers into FPs and rounding them, then derefing/comparing them.

Final opinion, it could be done, but no demand for it, so keep the ticket closed. If I ever get the itch I'll implement it with a custom Stat_t type, along with a fix for https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121448 .

--
bulk88 ~ bulk88 at hotmail.com

@toddr toddr added the Win32 This is a meta-ticket to tag issues in the perl core which need attention on Win32. See #11925 label Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Win32 This is a meta-ticket to tag issues in the perl core which need attention on Win32. See #11925
Projects
None yet
Development

No branches or pull requests

2 participants