Documentation cleanups.
[perl-fuse.git] / examples / fselclient.pl
1 #!/usr/bin/env perl
2
3 use strict;
4 no strict qw(refs);
5
6 use Carp;
7 local $SIG{'__WARN__'} = \&Carp::cluck;
8
9 use IO::Poll qw(POLLIN);
10 use Fcntl;
11 use constant FSEL_FILES => 16;
12
13 my @fds;
14
15 foreach my $i (0 .. (FSEL_FILES - 1)) {
16     sysopen($fds[$i], $ARGV[0] . '/' . sprintf('%X', $i), O_RDONLY)
17         or croak($!);
18 }
19
20 my $poll = new IO::Poll;
21 foreach my $fd (@fds) {
22     $poll->mask($fd, POLLIN);
23 }
24 while (1) {
25     my $rc = $poll->poll();
26
27     croak($!) if $rc < 0;
28
29     foreach my $i (0 .. (FSEL_FILES - 1)) {
30         if (!$poll->events($fds[$i])) {
31             print '_:   ';
32             next;
33         }
34         printf('%X:', $i);
35         $rc = sysread($fds[$i], my $buf, 4096);
36         croak($!) if !defined($rc);
37
38         printf('%02d ', $rc);
39     }
40     print "\n";
41 }