in reply to Re^2: failing to use getdents system call on Linux
in thread failing to use getdents system call on Linux

Aye, sorry, scratch my hasty that. The syscall() must return a good value. OP problem seems to be in the unpack template. Should try native types instead: "L!L!SZ*". Perl L is 4 bytes...

Replies are listed 'Best First'.
Re^4: failing to use getdents system call on Linux
by glasswalk3r (Friar) on Nov 07, 2016 at 19:07 UTC

    Yup, the problem was with unpack indeed... I changed the line below from:

    my ( $ino, $off, $len, $name ) = unpack( "LLSZ*", $buf );

    To:

    my ( $ino, $off, $len, $name ) = unpack( "L!L!SZ*", $buf );

    And the program finally worked as expected:

    [me@localhost ~]$ ./test2.pl -d sample/ | head sample/xaaaaaaaaff sample/xaaaaaaabdu sample/xaaaaaaabjw sample/xaaaaaaaaos sample/xaaaaaaaalu sample/xaaaaaaaags sample/xaaaaaaabci sample/xaaaaaaabhy sample/xaaaaaaabjv sample/xaaaaaaaaxa

    All good, but some questions remains:

    1. What could have happened that cause this change in the system? Originally I didn't need to worry about that. Maybe some change related going from 32 to 64 bits platforms?
    2. How can I double check if I need to use "native" sizes with the unpack template? Besides the program malfunctions, of course. :-)
    Alceu Rodrigues de Freitas Junior
    ---------------------------------
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill