#!/usr/bin/env perl use warnings; use strict; use Cwd; use File::Spec; use Data::Dumper; use Fcntl; use Convert::Binary::C; use constant BUF_SIZE => 4096; use lib '/home/myself/perl5/perls/perl-5.20.1/lib/site_perl/5.20.3/i686-linux/sys'; require 'syscall.ph'; my $dir = File::Spec->catdir( getcwd(), 'test' ); sysopen( my $fd, $dir, O_RDONLY | O_DIRECTORY ); my $buf = "\0" x 128; $! = 0; my $converter = Convert::Binary::C->new(); my $struct = <parse($struct); my $read = syscall( &SYS_getdents, fileno($fd), $buf, BUF_SIZE ); if ( ( $read == -1 ) and ( $! != 0 ) ) { die "failed to syscal getdents: $!"; } #print Dumper($read), "\n"; #print Dumper($buf), "\n"; close($fd); my $data = $converter->unpack( 'foo', $buf ); print Dumper($data);