23
23
import java .nio .ByteBuffer ;
24
24
25
25
import org .dcache .nfs .nfsstat ;
26
- import org .dcache .nfs .status .InvalException ;
27
- import org .dcache .nfs .status .IsDirException ;
28
- import org .dcache .nfs .status .NfsIoException ;
29
26
import org .dcache .nfs .status .OpenModeException ;
30
27
import org .dcache .nfs .v4 .xdr .READ4res ;
31
28
import org .dcache .nfs .v4 .xdr .READ4resok ;
34
31
import org .dcache .nfs .v4 .xdr .nfs_opnum4 ;
35
32
import org .dcache .nfs .v4 .xdr .nfs_resop4 ;
36
33
import org .dcache .nfs .v4 .xdr .stateid4 ;
37
- import org .dcache .nfs .vfs .Stat ;
38
34
import org .slf4j .Logger ;
39
35
import org .slf4j .LoggerFactory ;
40
36
@@ -50,17 +46,8 @@ public OperationREAD(nfs_argop4 args) {
50
46
public void process (CompoundContext context , nfs_resop4 result ) throws IOException {
51
47
final READ4res res = result .opread ;
52
48
53
- Stat inodeStat = context .getFs ().getattr (context .currentInode ());
54
49
stateid4 stateid = Stateids .getCurrentStateidIfNeeded (context , _args .opread .stateid );
55
50
56
- if (inodeStat .type () == Stat .Type .DIRECTORY ) {
57
- throw new IsDirException ();
58
- }
59
-
60
- if (inodeStat .type () == Stat .Type .SYMLINK ) {
61
- throw new InvalException ();
62
- }
63
-
64
51
NFS4Client client ;
65
52
if (context .getMinorversion () == 0 ) {
66
53
/*
@@ -85,19 +72,17 @@ public void process(CompoundContext context, nfs_resop4 result) throws IOExcepti
85
72
86
73
ByteBuffer buf = ByteBuffer .allocate (count );
87
74
88
- int bytesReaded = context .getFs ().read (inode , buf , offset );
89
- if (bytesReaded < 0 ) {
90
- throw new NfsIoException ("IO not allowed" );
91
- }
92
-
93
- buf .flip ();
94
- res .status = nfsstat .NFS_OK ;
95
75
res .resok4 = new READ4resok ();
76
+ int bytesRead = context .getFs ().read (inode , buf , offset , res .resok4 ::setEOF );
96
77
97
- res .resok4 .data = buf ;
98
-
99
- if (offset + bytesReaded >= inodeStat .getSize ()) {
78
+ if (bytesRead < 0 ) {
79
+ buf .clear ();
100
80
res .resok4 .eof = true ;
81
+ } else {
82
+ buf .flip ();
101
83
}
84
+
85
+ res .status = nfsstat .NFS_OK ;
86
+ res .resok4 .data = buf ;
102
87
}
103
88
}
0 commit comments