• R/O
  • SSH
  • HTTPS

perl-fuse-fv: Commit


Commit MetaInfo

Revision79 (tree)
Zeit2011-12-17 23:22:04
Autortofjw

Log Message

Add test-run.pl to run fuse28.pm manually.
Documentation reached to fsyncdir.

Ändern Zusammenfassung

Diff

--- Fuse-Class/trunk/test/fuse28.pm (revision 78)
+++ Fuse-Class/trunk/test/fuse28.pm (revision 79)
@@ -74,6 +74,17 @@
7474 return $ret;
7575 }
7676
77+sub init {
78+ print STDERR "perl28.pm is started\n";
79+ return "perl28";
80+}
81+
82+# I don't know when this method is called...?
83+sub destroy {
84+ my $param = shift;
85+ print STDERR "$param is ended\n";
86+}
87+
7788 sub getattr {
7889 my $self = shift;
7990 my ($path) = @_;
@@ -207,12 +218,19 @@
207218 my $self = shift;
208219 my ($path, $offset, $dh) = @_;
209220
221+ if ($path eq '/test/readdir-type-1') {
222+ return $self->readdir_test_type_1(@_);
223+ }
224+ elsif ($path eq '/test/readdir-type-2') {
225+ return $self->readdir_test_type_2(@_);
226+ }
227+
210228 my $dir = $self->{handle}->{$dh};
211229 return (-2) unless ($dir);
212230
213231 my @names = $dir->readdir;
214232
215- if ($offset < @names) {
233+ if ($offset < $#names) {
216234 return (@names[$offset..$#names], 0);
217235 }
218236
@@ -219,6 +237,55 @@
219237 return (0);
220238 }
221239
240+sub readdir_test_type_1 {
241+ my $self = shift;
242+ my ($path, $offset, $dh) = @_;
243+
244+ my $dir = $self->{handle}->{$dh};
245+ return (-2) unless ($dir);
246+
247+ # print STDERR "readdir_test_type_1, path=$path, offset=$offset\n";
248+
249+ my $i = 1;
250+ my @list;
251+
252+ foreach my $name ($dir->readdir) {
253+ push(@list, [$i++, $name]);
254+ }
255+
256+ if ($offset < $#list) {
257+ return (@list[$offset..$#list], 0);
258+ }
259+
260+ return (0);
261+}
262+
263+sub readdir_test_type_2 {
264+ my $self = shift;
265+ my ($path, $offset, $dh) = @_;
266+
267+ my $dir = $self->{handle}->{$dh};
268+ return (-2) unless ($dir);
269+
270+ # print STDERR "readdir_test_type_2, path=$path, offset=$offset\n";
271+
272+ my $i = 1;
273+ my @list;
274+
275+ foreach my $name ($dir->readdir) {
276+ my $entity = $self->pickup("$path/$name");
277+ next unless ($entity);
278+
279+ push(@list, [$i++, $name, [$entity->attr]]);
280+ }
281+
282+ if ($offset < $#list) {
283+ return (@list[$offset..$#list], 0);
284+ }
285+
286+ return (0);
287+}
288+
222289 sub releasedir {
223290 my $self = shift;
224291 my ($path, $dh) = @_;
--- Fuse-Class/trunk/test/test-run.pl (nonexistent)
+++ Fuse-Class/trunk/test/test-run.pl (revision 79)
@@ -0,0 +1,24 @@
1+#!/usr/local/bin/perl
2+
3+#
4+# You can mount 'fuse28.pm' filesystem by running this script.
5+#
6+
7+use strict;
8+use lib '..';
9+
10+use Cwd qw(abs_path);
11+
12+use test::fuse28;
13+
14+my $mount_point = abs_path('mnt');
15+
16+#
17+# make mount point if not exists
18+#
19+
20+-d $mount_point || mkdir $mount_point, 0777;
21+
22+print "To umount, run:\n fusermount -u $mount_point\nfrom other terminal.\n";
23+my $fs = new test::fuse28;
24+$fs->main(mountpoint => $mount_point);
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
--- Fuse-Class/trunk/t/80fuse28.t (revision 78)
+++ Fuse-Class/trunk/t/80fuse28.t (revision 79)
@@ -82,7 +82,7 @@
8282 my $child_pid = -1;
8383
8484 eval {
85- plan tests => 155;
85+ plan tests => 161;
8686
8787 $child_pid = fork();
8888 die $! if ($child_pid < 0);
@@ -149,6 +149,43 @@
149149 my $size = (stat $fname)[7];
150150 ok($size == 3);
151151 }
152+
153+ # readdir (1)
154+ {
155+ my $test_dir = "$mount_point/test";
156+ my $test_dir_1 = "$test_dir/readdir-type-1";
157+ mkdir $test_dir, 0777;
158+ mkdir $test_dir_1, 0777;
159+
160+ opendir(my $dh, $test_dir_1);
161+
162+ my @entries;
163+ while(readdir $dh) {
164+ push(@entries, $_);
165+ }
166+ is(scalar @entries, 2);
167+ is(scalar(grep { $_ eq '..' } @entries), 1);
168+ is(scalar(grep { $_ eq '.' } @entries), 1);
169+ }
170+
171+ # readdir (2)
172+ {
173+ my $test_dir = "$mount_point/test";
174+ my $test_dir_2 = "$test_dir/readdir-type-2";
175+ mkdir $test_dir, 0777;
176+ mkdir $test_dir_2, 0777;
177+
178+ opendir(my $dh, $test_dir_2);
179+
180+ my @entries;
181+ while(readdir $dh) {
182+ push(@entries, $_);
183+ }
184+
185+ is(scalar @entries, 2);
186+ is(scalar(grep { $_ eq '..' } @entries), 1);
187+ is(scalar(grep { $_ eq '.' } @entries), 1);
188+ }
152189 };
153190
154191 my $err = $@;
--- Fuse-Class/trunk/lib/Fuse/Class.pm (revision 78)
+++ Fuse-Class/trunk/lib/Fuse/Class.pm (revision 79)
@@ -293,7 +293,7 @@
293293 Return an errno (0 if success).
294294 This method is called to truncate a file at the given offset.
295295
296-=head2 utime(PATH_NAME, ACCESS_TIME, MODIF_TIME).
296+=head2 utime(PATH_NAME, ACCESS_TIME, MODIFIED_TIME).
297297
298298 Return an errno (0 if success).
299299 This method is called to change atime/mtime on a entity.
@@ -482,9 +482,17 @@
482482
483483 (HANDLE is optional. see opendir)
484484
485-Returns ...
486-ex: ('..', '.', 'a', 'b', 0)
485+Returns list consists of entries and an errno. Most simple style is
486+same as getdir(). ex: ('..', '.', 'a', 'b', 0)
487487
488+Entry can be array ref containing offset and attributes in following way:
489+
490+ ([1, '..'], [2, '.'], [3, 'a'], [4, 'b', ], 0)
491+
492+or
493+ ([1, '..', [array_like_getattr]], [2, '.', [array_like_getattr]], 0)
494+
495+
488496 Supported by Fuse version 2.3 or later.
489497
490498 =cut
@@ -493,6 +501,88 @@
493501 # return -Errno::EOPNOTSUPP();
494502 # }
495503
504+=head2 releasedir(DIRECTORY_NAME, HANDLE)
505+
506+(HANDLE is optional. see opendir)
507+
508+Returns an errno (0 if success).
509+
510+Called to indicate that there are no more references to the opened directory.
511+
512+Supported by Fuse version 2.3 or later.
513+
514+=cut
515+
516+=head2 fsyncdir(DIRECTORY_NAME, FLAGS, HANDLE)
517+
518+(HANDLE is optional. see opendir)
519+
520+Returns an errno (0 if success).
521+This method is called to synchronize user data (FLAG is non-zero value)
522+or user data and meta data in directory.
523+
524+Supported by Fuse version 2.3 or later.
525+
526+=cut
527+
528+=head2 init
529+
530+You can return scalar. It can be accessed using fuse_get_context().
531+
532+Supported by Fuse version 2.3 or later.
533+
534+=cut
535+
536+=head2 destroy(SCALAR_VALUE)
537+
538+(SCALAR_VALUE is returned value by init method)
539+
540+Supported by Fuse version 2.3 or later.
541+
542+=cut
543+
544+=head2 access(PATH_NAME, ACCESS_MODE_FLAG)
545+
546+Supported by Fuse version 2.5 or later.
547+
548+=cut
549+
550+=head2 create(PATH_NAME, FLAGS, FILE_HANDLE)
551+
552+Supported by Fuse version 2.5 or later.
553+
554+=cut
555+
556+=head2 ftruncate(PATH_NAME, OFFSET, FILE_HANDLE)
557+
558+Supported by Fuse version 2.5 or later.
559+
560+=cut
561+
562+=head2 fgetattr(PATH_NAME, FILE_HANDLE)
563+
564+Supported by Fuse version 2.5 or later.
565+
566+=cut
567+
568+=head2 lock(PATH_NAME, COMMAND_CODE, LOCK_PARAMS, FILE_HANDLE)
569+
570+Supported by Fuse version 2.6 or later.
571+
572+=cut
573+
574+=head2 utimens(PATH_NAME, ACCESS_TIME, MODIFIED_TIME)
575+
576+Supported by Fuse version 2.6 or later.
577+
578+=cut
579+
580+=head2 bmap(PATH_NAME, BLOCK_SIZE, BLOCK_NUMBER)
581+
582+Supported by Fuse version 2.6 or later.
583+
584+=cut
585+
496586 =head1 AUTHOR
497587
498588 Toshimitsu FUJIWARA, C<< <tttfjw at gmail.com> >>
Show on old repository browser