• R/O
  • SSH
  • HTTPS

perl-fuse-fv: Commit


Commit MetaInfo

Revision80 (tree)
Zeit2011-12-18 19:26:38
Autortofjw

Log Message

Documentation completed.

Ändern Zusammenfassung

Diff

--- Fuse-Class/trunk/test/fuse28.pm (revision 79)
+++ Fuse-Class/trunk/test/fuse28.pm (revision 80)
@@ -7,6 +7,7 @@
77 use warnings;
88
99 use Fcntl;
10+use Errno;
1011
1112 package test::fuse28;
1213
@@ -75,7 +76,7 @@
7576 }
7677
7778 sub init {
78- print STDERR "perl28.pm is started\n";
79+ # print STDERR "perl28.pm is started\n";
7980 return "perl28";
8081 }
8182
@@ -85,6 +86,17 @@
8586 print STDERR "$param is ended\n";
8687 }
8788
89+sub fgetattr {
90+ my $self = shift;
91+ my ($path, $fh) = @_;
92+
93+ my $entity = $self->{handle}->{$fh};
94+ return (-2) unless ($entity);
95+ return (-1) unless ($entity->can('attr'));
96+
97+ $entity->attr;
98+}
99+
88100 sub getattr {
89101 my $self = shift;
90102 my ($path) = @_;
@@ -396,6 +408,38 @@
396408 return $entity->utimens($atime, $mtime);
397409 }
398410
411+sub access {
412+ my $self = shift;
413+ my ($path, $mode) = @_;
414+
415+ if ($path eq '/test/access_no_perm') {
416+ # if exsits, it's not accesible!!
417+ return -Errno::EPERM() if $self->pickup($path);
418+ }
419+
420+ return 0;
421+}
422+
423+sub create {
424+ my $self = shift;
425+ my ($path, $mask, $mode) = @_;
426+ my ($dirname, $name) = ($path =~ m/^(.*)\/([^\/]+)$/);
427+ return -2 unless (defined($dirname) && defined($name)); # badname ?
428+
429+ my $dir = $self->pickup($dirname);
430+ return -2 unless ($dir);
431+
432+ return Errno::EXISTS if ($self->pickup($path));
433+
434+ my $ret = $dir->mknod($name, $mask, 0);
435+ return ($ret) if ($ret != 0);
436+
437+ my $entity = $self->pickup($path);
438+ return (-2) unless ($entity);
439+
440+ return (0, $self->issue_handle($entity));
441+}
442+
399443 package test::fuse28::Entity;
400444
401445 my $last_ino = 0;
--- Fuse-Class/trunk/test/test-run.pl (revision 79)
+++ Fuse-Class/trunk/test/test-run.pl (revision 80)
@@ -6,9 +6,12 @@
66
77 use strict;
88 use lib '..';
9+use lib '../blib/lib';
10+use lib '../blib/arch/auto';
911
1012 use Cwd qw(abs_path);
1113
14+use Fuse;
1215 use test::fuse28;
1316
1417 my $mount_point = abs_path('mnt');
@@ -19,6 +22,8 @@
1922
2023 -d $mount_point || mkdir $mount_point, 0777;
2124
25+print "fuse version: ", Fuse::fuse_version, "\n";
2226 print "To umount, run:\n fusermount -u $mount_point\nfrom other terminal.\n";
2327 my $fs = new test::fuse28;
24-$fs->main(mountpoint => $mount_point);
28+$fs->main(mountpoint => $mount_point,
29+ debug=>1);
--- Fuse-Class/trunk/t/80fuse28.t (revision 79)
+++ Fuse-Class/trunk/t/80fuse28.t (revision 80)
@@ -19,8 +19,8 @@
1919 # Fuse version must be 2.8 or later for this test.
2020 #
2121 my $version = Fuse::fuse_version;
22- if ($version < 2.8) {
23- $reason = "Fuse version is lower than 2.8.";
22+ if ($version < 2.6) {
23+ $reason = "Fuse version is lower than 2.6.";
2424 return 0;
2525 }
2626
@@ -82,7 +82,7 @@
8282 my $child_pid = -1;
8383
8484 eval {
85- plan tests => 161;
85+ plan tests => 165;
8686
8787 $child_pid = fork();
8888 die $! if ($child_pid < 0);
@@ -186,6 +186,44 @@
186186 is(scalar(grep { $_ eq '..' } @entries), 1);
187187 is(scalar(grep { $_ eq '.' } @entries), 1);
188188 }
189+
190+ # access
191+ {
192+ use POSIX;
193+
194+ my $test_dir = "$mount_point/test";
195+ mkdir $test_dir, 0777;
196+
197+ my $test_dir_bad = "$test_dir/access_no_perm";
198+ mkdir $test_dir_bad, 0777;
199+ my $test_dir_ok = "$test_dir/access_with_perm";
200+ mkdir $test_dir_ok, 0777;
201+
202+ ok(!POSIX::access($test_dir_bad, &POSIX::R_OK));
203+ ok(POSIX::access($test_dir_ok, &POSIX::R_OK));
204+ }
205+
206+ # ftruncate & fgetattr
207+ {
208+ my $test_dir = "$mount_point/test";
209+ mkdir $test_dir, 0777;
210+
211+ my $file = "$test_dir/ftruncate_test";
212+ open(my $fh1, ">", $file);
213+ print $fh1 "hello world\n";
214+ close($fh1);
215+
216+ open(my $fh2, "+<", $file);
217+ truncate($fh2, 3);
218+
219+ my @st = stat($fh2);
220+ is($st[7], 3);
221+
222+ close($fh2);
223+
224+ @st = stat($file);
225+ is($st[7], 3);
226+ }
189227 };
190228
191229 my $err = $@;
--- Fuse-Class/trunk/lib/Fuse/Class.pm (revision 79)
+++ Fuse-Class/trunk/lib/Fuse/Class.pm (revision 80)
@@ -49,7 +49,9 @@
4949 my $fuse = SampleFS->new("your", "parameters", "here");
5050 $fuse->main(mountpoint => '/mnt/sample', mountopts => "allow_other");
5151
52-When file on your filesystem is opened it will be seen that method
52+ # control will be not returned until file system is unmouted...
53+
54+When file on your filesystem is opened, it will be seen that method
5355 is called like this:
5456
5557 $fuse->open($path_name, $flags, $file_info);
@@ -57,7 +59,7 @@
5759 =head1 DESCRIPTION
5860
5961 This module supports writing Fuse callback as method.
60-Method name is same as Fuse callback, but first argment is object.
62+Method name is same as Fuse callback, but first argment is an object (it's named '$self' usually).
6163
6264 This is a small change for Fuse, but you can use power of OO like
6365 inheritance, encapsulation, ...
@@ -208,7 +210,7 @@
208210 }
209211 }
210212
211-=head1 METHODS MAY OVERRIDDEN
213+=head1 METHODS MAY BE OVERRIDDEN
212214
213215 =cut
214216
@@ -250,27 +252,27 @@
250252
251253 =head2 mkdir(DIRECTORY_NAME, MODE)
252254
253-Returns an errno (0 if success).
255+Return an errno (0 if success).
254256 This method is called to create a directory.
255257
256258 =head2 unlink(PATH_NAME)
257259
258-Returns an errno (0 if success).
260+Return an errno (0 if success).
259261 This method is called to remove an entity (device, file or symlink).
260262
261263 =head2 rmdir(PATH_NAME)
262264
263-Returns an errno (0 if success).
265+Return an errno (0 if success).
264266 This method is called to remove a directory.
265267
266268 =head2 symlink(EXISTING_PATH_NAME, SYMLINK_NAME)
267269
268-Returns an errno (0 if success).
270+Return an errno (0 if success).
269271 This method is called to create a symbolic link.
270272
271273 =head2 rename(OLD_NAME, NEW_NAME)
272274
273-Returns an errno (0 if success).
275+Return an errno (0 if success).
274276 This method is called to rename/move a entity.
275277
276278 =head2 link(EXISTING_PATH_NAME, HADLINK_NAME)
@@ -300,7 +302,7 @@
300302
301303 =head2 open(PATH_NAME, FLAGS, FILE_INFO)
302304
303-Returns an errno, and a file handle (optional)
305+Return an errno, and a file handle (optional)
304306
305307 First style means like this:
306308
@@ -318,7 +320,7 @@
318320
319321 =head2 read(PATH_NAME, SIZE, OFFSET, FILE_HANDLE)
320322
321-Returns an errno, or string scalar of read data.
323+Return an errno, or string scalar of read data.
322324
323325 This method is called to read data (SIZE bytes)
324326 at the given offset of opened file.
@@ -325,7 +327,7 @@
325327
326328 =head2 write(PATH_NAME, BUFFER, OFFSET, FILE_HANDLE)
327329
328-Returns a written byte size or an errno.
330+Return a written byte size or an errno.
329331
330332 This method is called to write data (BUFFER)
331333 at the given offset of opened file.
@@ -332,7 +334,7 @@
332334
333335 =head2 statfs
334336
335-Returns status of filesystem in one of follwing style:
337+Return status of filesystem in one of follwing style:
336338
337339 =over
338340
@@ -356,7 +358,7 @@
356358
357359 =head2 flush(PATH_NAME, FILE_HANDLE)
358360
359-Returns an errno (0 if success).
361+Return an errno (0 if success).
360362 This method is called to synchronize any cached data.
361363
362364 =cut
@@ -435,7 +437,7 @@
435437
436438 =head2 listxattr(PATH_NAME)
437439
438-Returns a list of attribute names and an errno (0 if success).
440+Return a list of attribute names and an errno (0 if success).
439441 ex: ('attr1', 'attr2', 'attr3', 0)
440442
441443 By default implementation, returns 0.
@@ -464,7 +466,7 @@
464466
465467 =head2 opendir(DIRECTORY_NAME)
466468
467-Returns an errno, and a directory handle (optional).
469+Return an errno, and a directory handle (optional).
468470
469471 This method is called to open a directory for reading.
470472 If special handling is required to open a directory, this method
@@ -482,7 +484,7 @@
482484
483485 (HANDLE is optional. see opendir)
484486
485-Returns list consists of entries and an errno. Most simple style is
487+Return list consists of entries and an errno. Most simple style is
486488 same as getdir(). ex: ('..', '.', 'a', 'b', 0)
487489
488490 Entry can be array ref containing offset and attributes in following way:
@@ -505,7 +507,7 @@
505507
506508 (HANDLE is optional. see opendir)
507509
508-Returns an errno (0 if success).
510+Return an errno (0 if success).
509511
510512 Called to indicate that there are no more references to the opened directory.
511513
@@ -517,7 +519,7 @@
517519
518520 (HANDLE is optional. see opendir)
519521
520-Returns an errno (0 if success).
522+Return an errno (0 if success).
521523 This method is called to synchronize user data (FLAG is non-zero value)
522524 or user data and meta data in directory.
523525
@@ -543,12 +545,23 @@
543545
544546 =head2 access(PATH_NAME, ACCESS_MODE_FLAG)
545547
548+Return an errno (0 if success).
549+
550+This method is called to determine if user can access the file.
551+For more information, see Fuse document and manual for access(2).
552+
546553 Supported by Fuse version 2.5 or later.
547554
548555 =cut
549556
550-=head2 create(PATH_NAME, FLAGS, FILE_HANDLE)
557+=head2 create(PATH_NAME, MASK, MODE)
551558
559+Return an errno, and a file handle (optional)
560+
561+This method is called to create a file with MASK (like mknod)
562+and open it with MODE atomically.
563+If this method is not implemented, mknod() and open() will be used.
564+
552565 Supported by Fuse version 2.5 or later.
553566
554567 =cut
@@ -555,6 +568,11 @@
555568
556569 =head2 ftruncate(PATH_NAME, OFFSET, FILE_HANDLE)
557570
571+(HANDLE is optional. see open)
572+
573+Return an errno (0 if success).
574+This method is called to truncate an opened file at the given offset.
575+
558576 Supported by Fuse version 2.5 or later.
559577
560578 =cut
@@ -561,6 +579,11 @@
561579
562580 =head2 fgetattr(PATH_NAME, FILE_HANDLE)
563581
582+(HANDLE is optional. see open)
583+
584+Return a list of file attributes like getattr().
585+This method is called to get attributes for opened file.
586+
564587 Supported by Fuse version 2.5 or later.
565588
566589 =cut
@@ -567,6 +590,15 @@
567590
568591 =head2 lock(PATH_NAME, COMMAND_CODE, LOCK_PARAMS, FILE_HANDLE)
569592
593+(HANDLE is optional. see open)
594+
595+Return an errno (0 if success).
596+
597+This method is called to lock or unlock regions of file. Parameters
598+for locking is passed in LOCK_PARAMS as hashref.
599+
600+For more information, see the documentation of Fuse.
601+
570602 Supported by Fuse version 2.6 or later.
571603
572604 =cut
@@ -573,6 +605,10 @@
573605
574606 =head2 utimens(PATH_NAME, ACCESS_TIME, MODIFIED_TIME)
575607
608+Return an errno (0 if success).
609+This method is called to change atime/mtime on a entity.
610+(Time has a resolution in nanosecond.)
611+
576612 Supported by Fuse version 2.6 or later.
577613
578614 =cut
@@ -579,6 +615,12 @@
579615
580616 =head2 bmap(PATH_NAME, BLOCK_SIZE, BLOCK_NUMBER)
581617
618+Return 0 and physical block numeber on success, otherwise errno.
619+
620+This method is called to get physical block offset on block device.
621+
622+For more information, see the documentation of Fuse.
623+
582624 Supported by Fuse version 2.6 or later.
583625
584626 =cut
Show on old repository browser