34
34
35
35
public class NfsServerV3READDIRPLUS_3Test {
36
36
private Inode dirInode ;
37
+ private Inode dirInodePseudoFS ;
37
38
private Stat dirStat ;
38
39
private VirtualFileSystem vfs ;
39
40
private NfsServerV3 nfsServer ;
40
41
41
42
@ Before
42
43
public void setup () throws Exception {
43
- dirInode = new Inode (0 , 1 , 0 , new byte [] {0 , 0 , 0 , 1 }); // the dir we want to read;
44
+ dirInode = Inode .forFile (new byte [] {0 , 0 , 0 , 1 }); // the dir we want to read;
45
+ dirInodePseudoFS = new Inode (0 , 1 , 0 , new byte [] {0 , 0 , 0 , 1 }); // the handle as seen from the outside
44
46
dirStat = new Stat (); // the stat marking it as a dir
45
47
// noinspection OctalInteger
46
48
dirStat .setMode (Stat .S_IFDIR | 0755 );
@@ -72,7 +74,7 @@ public void testReadDirWithNoResults() throws Exception {
72
74
73
75
// set up and execute the call
74
76
RpcCall call = new RpcCallBuilder ().from ("1.2.3.4" , "someHost.acme.com" , 42 ).nfs3 ().noAuth ().build ();
75
- READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInode );
77
+ READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInodePseudoFS );
76
78
READDIRPLUS3res result = nfsServer .NFSPROC3_READDIRPLUS_3 (call , args );
77
79
78
80
Assert .assertEquals (nfsstat .NFS_OK , result .status );
@@ -94,7 +96,7 @@ public void testReadDirWithTinyLimit() throws Exception {
94
96
95
97
// set up and execute the 1st call - no cookie, but very tight size limit
96
98
RpcCall call = new RpcCallBuilder ().from ("1.2.3.4" , "someHost.acme.com" , 42 ).nfs3 ().noAuth ().build ();
97
- READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInode , 10 ); // 10 bytes - not enough for anything
99
+ READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInodePseudoFS , 10 ); // 10 bytes - not enough for anything
98
100
READDIRPLUS3res result = nfsServer .NFSPROC3_READDIRPLUS_3 (call , args );
99
101
100
102
Assert .assertEquals (nfsstat .NFSERR_TOOSMALL , result .status ); // error response
@@ -113,7 +115,7 @@ public void testContinueReadingAfterEOF() throws Exception {
113
115
114
116
// set up and execute the 1st call - no cookie, but very tight size limit
115
117
RpcCall call = new RpcCallBuilder ().from ("1.2.3.4" , "someHost.acme.com" , 42 ).nfs3 ().noAuth ().build ();
116
- READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInode );
118
+ READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInodePseudoFS );
117
119
READDIRPLUS3res result = nfsServer .NFSPROC3_READDIRPLUS_3 (call , args );
118
120
119
121
Assert .assertEquals (nfsstat .NFS_OK , result .status ); // response ok
@@ -123,7 +125,7 @@ public void testContinueReadingAfterEOF() throws Exception {
123
125
// re-read after EOF
124
126
long cookie = result .resok .reply .entries .nextentry .cookie .value .value ;
125
127
cookieVerifier = result .resok .cookieverf .value ;
126
- args = NfsV3Ops .readDirPlus (dirInode , cookie , cookieVerifier );
128
+ args = NfsV3Ops .readDirPlus (dirInodePseudoFS , cookie , cookieVerifier );
127
129
result = nfsServer .NFSPROC3_READDIRPLUS_3 (call , args );
128
130
129
131
Assert .assertEquals (nfsstat .NFS_OK , result .status ); // response ok
@@ -146,7 +148,7 @@ public void testSemiValidVerifier() throws Exception {
146
148
long cookie = 1 ;
147
149
148
150
RpcCall call = new RpcCallBuilder ().from ("1.2.3.4" , "someHost.acme.com" , 42 ).nfs3 ().noAuth ().build ();
149
- READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInode , cookie , cookieVerifier );
151
+ READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInodePseudoFS , cookie , cookieVerifier );
150
152
READDIRPLUS3res result = nfsServer .NFSPROC3_READDIRPLUS_3 (call , args );
151
153
152
154
Assert .assertEquals (nfsstat .NFS_OK , result .status ); // error response
@@ -170,7 +172,7 @@ public void testEofIfLastEntryDoesNotFit() throws Exception {
170
172
when (vfs .list (eq (dirInode ), any (), anyLong ())).thenReturn (new DirectoryStream (cookieVerifier , dirContents ));
171
173
172
174
RpcCall call = new RpcCallBuilder ().from ("1.2.3.4" , "someHost.acme.com" , 42 ).nfs3 ().noAuth ().build ();
173
- READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInode , 0 , cookieVerifier , 3480 , 1024 ); // only 22 entries will
175
+ READDIRPLUS3args args = NfsV3Ops .readDirPlus (dirInodePseudoFS , 0 , cookieVerifier , 3480 , 1024 ); // only 22 entries will
174
176
// fit
175
177
READDIRPLUS3res result = nfsServer .NFSPROC3_READDIRPLUS_3 (call , args );
176
178
0 commit comments