projects
/
perl-fuse.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7f982ef
)
Use a few more Perl-isms.
author
Derrik Pates
<demon@now.ai>
Wed, 3 Aug 2011 00:07:10 +0000
(18:07 -0600)
committer
Derrik Pates
<demon@now.ai>
Wed, 3 Aug 2011 00:07:10 +0000
(18:07 -0600)
examples/fioc.pl
patch
|
blob
|
history
diff --git
a/examples/fioc.pl
b/examples/fioc.pl
index
811cb80
..
1b5282a
100755
(executable)
--- a/
examples/fioc.pl
+++ b/
examples/fioc.pl
@@
-25,6
+25,7
@@
require 'asm/ioctl.ph';
our %sizeof = ('int' => 4);
sub FIOC_GET_SIZE { _IOR(ord 'E', 0, 'int'); }
sub FIOC_SET_SIZE { _IOW(ord 'E', 1, 'int'); }
our %sizeof = ('int' => 4);
sub FIOC_GET_SIZE { _IOR(ord 'E', 0, 'int'); }
sub FIOC_SET_SIZE { _IOW(ord 'E', 1, 'int'); }
+sub TCGETS { 0x5401; }
sub fioc_resize {
my ($size) = @_;
sub fioc_resize {
my ($size) = @_;
@@
-87,9
+88,7
@@
sub fioc_open {
my ($path, $flags, $info) = @_;
print 'called ', (caller(0))[3], "\n";
my ($path, $flags, $info) = @_;
print 'called ', (caller(0))[3], "\n";
- if (fioc_file_type($path) != FIOC_NONE) {
- return 0;
- }
+ return 0 if fioc_file_type($path) != FIOC_NONE;
return -&ENOENT;
}
return -&ENOENT;
}
@@
-98,10
+97,7
@@
sub fioc_read {
print 'called ', (caller(0))[3], "\n";
return -&EINVAL if fioc_file_type($path) != FIOC_FILE;
print 'called ', (caller(0))[3], "\n";
return -&EINVAL if fioc_file_type($path) != FIOC_FILE;
-
- if ($offset > $fioc_size) {
- return q{};
- }
+ return q{} if $offset > $fioc_size;
if ($size > $fioc_size - $offset) {
$size - $fioc_size - $offset;
if ($size > $fioc_size - $offset) {
$size - $fioc_size - $offset;
@@
-116,10
+112,7
@@
sub fioc_write {
lock($fioc_buf);
return -&EINVAL if fioc_file_type($path) != FIOC_FILE;
lock($fioc_buf);
return -&EINVAL if fioc_file_type($path) != FIOC_FILE;
-
- if (fioc_expand($offset + length($data))) {
- return -&ENOMEM;
- }
+ return -&ENOMEM if fioc_expand($offset + length($data));
substr($fioc_buf, $offset, length($data), $data);
return length($data);
substr($fioc_buf, $offset, length($data), $data);
return length($data);
@@
-149,7
+142,6
@@
sub fioc_ioctl {
print 'called ', (caller(0))[3], "\n";
return -&EINVAL if fioc_file_type($path) != FIOC_FILE;
print 'called ', (caller(0))[3], "\n";
return -&EINVAL if fioc_file_type($path) != FIOC_FILE;
-
return -&ENOSYS if $flags & 0x1;
if ($cmd == FIOC_GET_SIZE) {
return -&ENOSYS if $flags & 0x1;
if ($cmd == FIOC_GET_SIZE) {
@@
-160,6
+152,11
@@
sub fioc_ioctl {
fioc_resize(unpack('L', $data));
return 0;
}
fioc_resize(unpack('L', $data));
return 0;
}
+ elsif ($cmd == TCGETS) {
+ # perl sends TCGETS as part of calling isatty() on opening a file;
+ # this appears to be a more canonical answer
+ return -&ENOTTY;
+ }
return -&EINVAL;
}
return -&EINVAL;
}