├── tools ├── .gitignore ├── src │ └── test │ │ ├── resources │ │ └── test.properties │ │ └── java │ │ └── com │ │ └── emc │ │ └── ecs │ │ └── nfsclient │ │ └── nfs │ │ └── io │ │ └── Test_LoadTest.java └── build.gradle ├── readingTools ├── .gitignore └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── license.ij.vm ├── settings.gradle ├── src ├── test │ ├── resources │ │ └── test.properties.template │ └── java │ │ └── com │ │ └── emc │ │ └── ecs │ │ └── nfsclient │ │ ├── nfs │ │ └── io │ │ │ └── Test_NfsFileBase.java │ │ └── rpc │ │ └── Test_Xdr.java └── main │ └── java │ └── com │ └── emc │ └── ecs │ └── nfsclient │ ├── rpc │ ├── CredentialNone.java │ ├── Credential.java │ ├── RpcStatus.java │ ├── RpcException.java │ ├── CredentialBase.java │ ├── RpcResponseHandler.java │ ├── RejectStatus.java │ ├── ReplyStatus.java │ └── AcceptStatus.java │ ├── nfs │ ├── NfsResponse.java │ ├── NfsRequest.java │ ├── nfs3 │ │ ├── Nfs3CreateResponse.java │ │ ├── Nfs3WriteResponse.java │ │ ├── Nfs3MkdirResponse.java │ │ ├── Nfs3SymlinkResponse.java │ │ ├── Nfs3FsStatResponse.java │ │ ├── Nfs3SetAttrResponse.java │ │ ├── Nfs3LookupResponse.java │ │ ├── Nfs3MknodResponse.java │ │ ├── Nfs3ReadResponse.java │ │ ├── Nfs3FsInfoResponse.java │ │ ├── Nfs3CommitResponse.java │ │ ├── Nfs3RemoveResponse.java │ │ ├── Nfs3RmdirResponse.java │ │ ├── Nfs3LinkResponse.java │ │ ├── Nfs3PathconfResponse.java │ │ ├── Nfs3GetAttrResponse.java │ │ ├── Nfs3FsStatRequest.java │ │ ├── Nfs3RenameResponse.java │ │ ├── Nfs3LookupRequest.java │ │ ├── Nfs3FsInfoRequest.java │ │ ├── Nfs3MkdirRequest.java │ │ ├── Nfs3RemoveRequest.java │ │ ├── Nfs3RmdirRequest.java │ │ ├── Nfs3PathconfRequest.java │ │ ├── Nfs3SymlinkRequest.java │ │ ├── Nfs3GetAttrRequest.java │ │ ├── Nfs3CommitRequest.java │ │ ├── Nfs3SetAttrRequest.java │ │ ├── Nfs3ReaddirResponse.java │ │ ├── Nfs3LinkRequest.java │ │ ├── Nfs3WriteRequest.java │ │ ├── Nfs3AccessResponse.java │ │ ├── Nfs3RenameRequest.java │ │ ├── Nfs3MknodRequest.java │ │ ├── Nfs3ReadRequest.java │ │ ├── Nfs3ReadlinkResponse.java │ │ ├── Nfs3ReaddirRequest.java │ │ └── Nfs3ReaddirplusResponse.java │ ├── io │ │ ├── NfsFileFilter.java │ │ ├── NfsFilenameFilter.java │ │ └── Nfs3File.java │ ├── NfsException.java │ ├── NfsDirectoryPlusEntry.java │ ├── NfsResponseHandler.java │ ├── NfsFsStatRequest.java │ ├── NfsDirectoryEntry.java │ ├── NfsFsStatResponse.java │ ├── NfsCreateResponse.java │ ├── NfsMkdirResponse.java │ ├── NfsSetAttrResponse.java │ ├── NfsSymlinkResponse.java │ ├── NfsFsInfoRequest.java │ ├── NfsGetAttrResponse.java │ ├── NfsPathconfRequest.java │ ├── NfsRemoveResponse.java │ ├── NfsRmdirResponse.java │ ├── NfsMknodResponse.java │ ├── NfsGetAttrRequest.java │ ├── NfsLookupResponse.java │ ├── NfsFsInfoResponse.java │ ├── NfsLookupRequest.java │ ├── NfsPreOpAttributes.java │ ├── NfsWccData.java │ ├── NfsPathconfResponse.java │ ├── NfsLinkResponse.java │ ├── NfsRemoveRequest.java │ ├── NfsRmdirRequest.java │ ├── NfsMkdirRequest.java │ └── NfsRenameResponse.java │ ├── portmap │ └── GetPortResponse.java │ ├── mount │ ├── MountException.java │ ├── MountRequest.java │ └── UnmountRequest.java │ └── network │ └── RPCRecordDecoder.java ├── 3rd-party-licenses └── LICENSE-slf4j-api.txt └── gradlew.bat /tools/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /readingTools/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EMCECS/nfs-client-java/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | bin 3 | *.class 4 | # Package Files # 5 | *.jar 6 | *.war 7 | *.ear 8 | # Local files 9 | .DS_Store 10 | .classpath 11 | .project 12 | .settings 13 | .idea 14 | *.iml 15 | *.ipr 16 | *.iws 17 | dependency-reduced-pom.xml 18 | esu.log 19 | .gradle 20 | *.user 21 | *.csuser 22 | Debug/ 23 | Release/ 24 | packages/ 25 | .vs/ 26 | *.bak 27 | id_rsa 28 | /build/ 29 | -------------------------------------------------------------------------------- /license.ij.vm: -------------------------------------------------------------------------------- 1 | Copyright 2016#if($today.year > 2016)-$today.year#end, Dell Inc. or its subsidiaries. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"). 4 | You may not use these files except in compliance with the License. 5 | A copy of the License is located at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0.txt 8 | 9 | or in the "license" file accompanying these files. These files are 10 | distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 11 | ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the 13 | License. 14 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | rootProject.name = 'nfs-client' 16 | include 'tools' 17 | include 'readingTools' 18 | -------------------------------------------------------------------------------- /tools/src/test/resources/test.properties: -------------------------------------------------------------------------------- 1 | # Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0.txt 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | ############################################################# 14 | nfs.server= 15 | nfs.export= 16 | -------------------------------------------------------------------------------- /src/test/resources/test.properties.template: -------------------------------------------------------------------------------- 1 | # Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"). 4 | # You may not use this file except in compliance with the License. 5 | # A copy of the License is located at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0.txt 8 | # 9 | # or in the "license" file accompanying this file. This file is distributed 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | # express or implied. See the License for the specific language governing 12 | # permissions and limitations under the License. 13 | ############################################################# 14 | # NOTE: copy this file to your home directory, rename it to test.properties, 15 | # and set appropriate values for your test configuration 16 | nfs.server= 17 | nfs.export= 18 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/rpc/CredentialNone.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.rpc; 16 | 17 | /** 18 | * implement AUTH_NONE for rpc, as specified by RFC 1831 19 | * (https://tools.ietf.org/html/rfc1831). 20 | */ 21 | public class CredentialNone extends CredentialBase { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.Xdr; 18 | 19 | /** 20 | * The lowest-level response interface specified by RFC 1813 21 | * (https://tools.ietf.org/html/rfc1813). 22 | * 23 | * @author seibed 24 | */ 25 | public interface NfsResponse { 26 | 27 | /** 28 | * Transfer data from an Xdr object after RPC use. Specified by RFC 1813 29 | * (https://tools.ietf.org/html/rfc1813). 30 | * 31 | * @param xdr 32 | * the returned Xdr. 33 | */ 34 | void unmarshalling(Xdr xdr); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.Xdr; 18 | 19 | /** 20 | * The lowest-level request interface specified by RFC 1813 21 | * (https://tools.ietf.org/html/rfc1813). 22 | * 23 | * @author seibed 24 | */ 25 | public interface NfsRequest { 26 | 27 | /** 28 | * Transfer data to an Xdr object for RPC use. The format is specified by 29 | * RFC 1813 (https://tools.ietf.org/html/rfc1813). 30 | * 31 | * @param xdr 32 | * the Xdr to be sent. 33 | */ 34 | public void marshalling(Xdr xdr); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/rpc/Credential.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.rpc; 16 | 17 | /** 18 | * Used to handle RPC Credentials, as specified by RFC 1831 19 | * (https://tools.ietf.org/html/rfc1831). 20 | * 21 | * @author seibed 22 | */ 23 | public interface Credential { 24 | 25 | /** 26 | * Discriminant for calls where the client does not know its identity or the 27 | * server does not care who the client is. Specified by RFC 1831 28 | * (https://tools.ietf.org/html/rfc1831). 29 | */ 30 | static final int AUTH_NONE = 0; 31 | 32 | /** 33 | * Put the credential into an XDR buffer. 34 | * 35 | * @param xdr 36 | */ 37 | void marshalling(Xdr xdr); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3CreateResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsCreateResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *
23 | * Procedure CREATE creates a regular file. 24 | *
25 | * 26 | * @author seibed 27 | */ 28 | public class Nfs3CreateResponse extends NfsCreateResponse { 29 | 30 | /** 31 | * The response, as specified by RFC 1813 32 | * (https://tools.ietf.org/html/rfc1813). 33 | * 34 | *35 | * Procedure CREATE creates a regular file. 36 | *
37 | */ 38 | public Nfs3CreateResponse() { 39 | super(Nfs3.VERSION); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3WriteResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsWriteResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure WRITE writes data to a file. 24 | *
25 | * 26 | * @author seibed 27 | */ 28 | public class Nfs3WriteResponse extends NfsWriteResponse { 29 | 30 | /** 31 | * Creates the response, as specified by RFC 1813 32 | * (https://tools.ietf.org/html/rfc1813). 33 | * 34 | *35 | * Procedure WRITE writes data to a file. 36 | *
37 | */ 38 | public Nfs3WriteResponse() { 39 | super(Nfs3.VERSION); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3MkdirResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsMkdirResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure MKDIR creates a new subdirectory. 24 | *
25 | * 26 | * @author seibed 27 | */ 28 | public class Nfs3MkdirResponse extends NfsMkdirResponse { 29 | 30 | /** 31 | * Creates the response, as specified by RFC 1813 32 | * (https://tools.ietf.org/html/rfc1813). 33 | * 34 | *35 | * Procedure MKDIR creates a new subdirectory. 36 | *
37 | */ 38 | public Nfs3MkdirResponse() { 39 | super(Nfs3.VERSION); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3SymlinkResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsSymlinkResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure SYMLINK creates a new symbolic link. 24 | *
25 | * 26 | * @author seibed 27 | */ 28 | public class Nfs3SymlinkResponse extends NfsSymlinkResponse { 29 | 30 | /** 31 | * Creates the response, as specified by RFC 1813 32 | * (https://tools.ietf.org/html/rfc1813). 33 | * 34 | *35 | * Procedure SYMLINK creates a new symbolic link. 36 | *
37 | */ 38 | public Nfs3SymlinkResponse() { 39 | super(Nfs3.VERSION); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3FsStatResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsFsStatResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure FSSTAT retrieves volatile file system state information. 24 | *
25 | * 26 | * @author seibed 27 | */ 28 | public class Nfs3FsStatResponse extends NfsFsStatResponse { 29 | 30 | /** 31 | * The response, as specified by RFC 1813 32 | * (https://tools.ietf.org/html/rfc1813). 33 | * 34 | *35 | * Procedure FSSTAT retrieves volatile file system state information. 36 | *
37 | */ 38 | public Nfs3FsStatResponse() { 39 | super(Nfs3.VERSION); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/io/NfsFileFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.io; 16 | 17 | /** 18 | * This interface is the NFS client equivalent of 19 | *java.io.FileFilter. A filter for abstract pathnames.
20 | *
21 | *
22 | * Instances of this interface may be passed to the listFiles
23 | * (NfsFileFilter) method of the NfsFile class.
24 | *
true if and only if pathName should be
37 | * included
38 | */
39 | boolean accept(NfsFile, ?> pathName);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3SetAttrResponse.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs.nfs3;
16 |
17 | import com.emc.ecs.nfsclient.nfs.NfsSetAttrResponse;
18 |
19 | /**
20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813).
21 | *
22 | * 23 | * Procedure SETATTR changes one or more of the attributes of a file system 24 | * object on the server. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class Nfs3SetAttrResponse extends NfsSetAttrResponse { 30 | 31 | /** 32 | * Creates the response, as specified by RFC 1813 33 | * (https://tools.ietf.org/html/rfc1813). 34 | * 35 | *36 | * Procedure SETATTR changes one or more of the attributes of a file system 37 | * object on the server. 38 | *
39 | */ 40 | public Nfs3SetAttrResponse() { 41 | super(Nfs3.VERSION); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3LookupResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsLookupResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure LOOKUP searches a directory for a specific name and returns the 24 | * file handle for the corresponding file system object. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class Nfs3LookupResponse extends NfsLookupResponse { 30 | 31 | /** 32 | * The response, as specified by RFC 1813 33 | * (https://tools.ietf.org/html/rfc1813). 34 | * 35 | *36 | * Procedure LOOKUP searches a directory for a specific name and returns the 37 | * file handle for the corresponding file system object. 38 | *
39 | */ 40 | public Nfs3LookupResponse() { 41 | super(Nfs3.VERSION); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3MknodResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsMknodResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *
23 | * Procedure MKNOD creates a new special file of the type, type .
24 | * Special files can be device files or named pipes.
25 | *
36 | * Procedure MKNOD creates a new special file of the type, type
37 | * . Special files can be device files or named pipes.
38 | *
23 | * Procedure READ reads data from a file. 24 | * 25 | * @author seibed 26 | */ 27 | public class Nfs3ReadResponse extends NfsReadResponse { 28 | 29 | /** 30 | * Creates the response, as specified by RFC 1813 31 | * (https://tools.ietf.org/html/rfc1813). 32 | * 33 | *
34 | * Procedure READ reads data from a file. 35 | *
36 | * 37 | * @param bytes 38 | * the buffer for storing bytes 39 | * @param position 40 | * the beginning position of buffer to store bytes 41 | */ 42 | public Nfs3ReadResponse(byte[] bytes, int position) { 43 | super(bytes, position, Nfs3.VERSION); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /tools/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | plugins { 16 | id 'java' 17 | id 'application' 18 | id 'com.github.johnrengelman.shadow' version '7.1.2' 19 | } 20 | 21 | description = 'nfsclient tools jar - provides utility commands to execute nfs client and server performance.' 22 | mainClassName = 'com.emc.ecs.nfsclient.nfs.io.LoadTest' 23 | 24 | defaultTasks 'shadowJar' 25 | 26 | repositories { 27 | mavenCentral() 28 | mavenLocal() 29 | } 30 | 31 | dependencies { 32 | implementation project(':') 33 | 34 | testImplementation project(':').sourceSets.test.output 35 | testImplementation "junit:junit:4.13.2" 36 | 37 | testRuntimeOnly "org.slf4j:slf4j-simple:1.7.36" 38 | } 39 | 40 | shadowJar { 41 | destinationDirectory = file("${buildDir}/shadow") 42 | classifier '' 43 | manifest { 44 | attributes 'Implementation-Version': project.version 45 | } 46 | } 47 | 48 | artifacts { 49 | tools shadowJar // tells root project to include in tools/ dir of distribution 50 | } -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/io/NfsFilenameFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.io; 16 | 17 | /** 18 | * This interface is the NFS client equivalent of 19 | *java.io.FilenameFilter. Instances of classes that implement this
20 | * interface are used to filter filenames. These instances are used to filter
21 | * directory listings in the list method of class
22 | * NfsFile.
23 | *
24 | * @author seibed
25 | */
26 | public interface NfsFilenameFilter {
27 |
28 | /**
29 | * Tests if a specified file should be included in a file list.
30 | *
31 | * @param dir
32 | * the directory in which the file was found.
33 | * @param name
34 | * the name of the file.
35 | * @return true if and only if the name should be included in
36 | * the file list; false otherwise.
37 | */
38 | boolean accept(NfsFile, ?> dir, String name);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3FsInfoResponse.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs.nfs3;
16 |
17 | import com.emc.ecs.nfsclient.nfs.NfsFsInfoResponse;
18 |
19 | /**
20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813).
21 | *
22 | * 23 | * Procedure FSINFO retrieves nonvolatile file system state information and 24 | * general information about the NFS version 3 protocol server implementation. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class Nfs3FsInfoResponse extends NfsFsInfoResponse { 30 | 31 | /** 32 | * Creates the response, as specified by RFC 1813 33 | * (https://tools.ietf.org/html/rfc1813). 34 | * 35 | *36 | * Procedure FSINFO retrieves nonvolatile file system state information and 37 | * general information about the NFS version 3 protocol server 38 | * implementation. 39 | *
40 | */ 41 | public Nfs3FsInfoResponse() { 42 | super(Nfs3.VERSION); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3CommitResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsCommitResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure COMMIT forces or flushes data to stable storage that was previously 24 | * written with a WRITE procedure call with the stable field set to UNSTABLE. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class Nfs3CommitResponse extends NfsCommitResponse { 30 | 31 | /** 32 | * The response, as specified by RFC 1813 33 | * (https://tools.ietf.org/html/rfc1813). 34 | * 35 | *36 | * Procedure COMMIT forces or flushes data to stable storage that was 37 | * previously written with a WRITE procedure call with the stable field set 38 | * to UNSTABLE. 39 | *
40 | * 41 | */ 42 | public Nfs3CommitResponse() { 43 | super(Nfs3.VERSION); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /readingTools/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | plugins { 16 | id 'java' 17 | id 'application' 18 | id 'com.github.johnrengelman.shadow' version '7.1.2' 19 | } 20 | 21 | description = 'nfsclient readingTools jar - provides utility commands to test reading performance.' 22 | mainClassName = 'com.emc.ecs.nfsclient.nfs.io.FileReadingTest' 23 | 24 | defaultTasks 'shadowJar' 25 | 26 | repositories { 27 | mavenCentral() 28 | mavenLocal() 29 | } 30 | 31 | dependencies { 32 | implementation project(':') 33 | implementation "org.apache.commons:commons-lang3:3.12.0" 34 | 35 | testImplementation project(':').sourceSets.test.output 36 | testImplementation "junit:junit:4.13.2" 37 | 38 | testRuntimeOnly "org.slf4j:slf4j-simple:1.7.36" 39 | } 40 | 41 | shadowJar { 42 | destinationDirectory = file("${buildDir}/shadow") 43 | classifier '' 44 | manifest { 45 | attributes 'Implementation-Version': project.version 46 | } 47 | } 48 | 49 | artifacts { 50 | tools shadowJar // tells root project to include in tools/ dir of distribution 51 | } -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3RemoveResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsRemoveResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure REMOVE removes (deletes) an entry from a directory. If the entry in 24 | * the directory was the last reference to the corresponding file system object, 25 | * the object may be destroyed. 26 | *
27 | * 28 | * @author seibed 29 | */ 30 | public class Nfs3RemoveResponse extends NfsRemoveResponse { 31 | 32 | /** 33 | * Creates the response, as specified by RFC 1813 34 | * (https://tools.ietf.org/html/rfc1813). 35 | * 36 | *37 | * Procedure REMOVE removes (deletes) an entry from a directory. If the 38 | * entry in the directory was the last reference to the corresponding file 39 | * system object, the object may be destroyed. 40 | *
41 | */ 42 | public Nfs3RemoveResponse() { 43 | super(Nfs3.VERSION); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3RmdirResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsRmdirResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 24 | * directory entry of the subdirectory is the last reference to the 25 | * subdirectory, the subdirectory may be destroyed. 26 | *
27 | * 28 | * @author seibed 29 | */ 30 | public class Nfs3RmdirResponse extends NfsRmdirResponse { 31 | 32 | /** 33 | * Creates the response, as specified by RFC 1813 34 | * (https://tools.ietf.org/html/rfc1813). 35 | * 36 | *37 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 38 | * directory entry of the subdirectory is the last reference to the 39 | * subdirectory, the subdirectory may be destroyed. 40 | *
41 | */ 42 | public Nfs3RmdirResponse() { 43 | super(Nfs3.VERSION); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/rpc/RpcStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.rpc; 16 | 17 | /** 18 | * @author seibed 19 | * 20 | */ 21 | public class RpcStatus { 22 | 23 | /** 24 | * Unable to bind to a privileged port as requested. NOT specified by RFC 25 | * 1831 (https://tools.ietf.org/html/rfc1831). 26 | */ 27 | public static final RpcStatus LOCAL_BINDING_ERROR = new RpcStatus(-1001); 28 | 29 | /** 30 | * Network error blocking RFC request or response. NOT specified by RFC 1831 31 | * (https://tools.ietf.org/html/rfc1831). 32 | */ 33 | public static final RpcStatus NETWORK_ERROR = new RpcStatus(-1001); 34 | 35 | /** 36 | * @return The int status value. 37 | */ 38 | public final int getValue() { 39 | return _value; 40 | } 41 | 42 | /** 43 | * The int status value. 44 | */ 45 | private final int _value; 46 | 47 | /** 48 | * Create the instance from the int status value. 49 | * 50 | * @param value 51 | */ 52 | protected RpcStatus(int value) { 53 | _value = value; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "RpcStatus:" + _value; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3LinkResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsLinkResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *
23 | * Procedure LINK creates a hard link from fileHandle to
24 | * name, in the directory, parentDirectoryFileHandle.
25 | * fileHandle and parentDirectoryFileHandle must
26 | * reside on the same file system and server.
27 | *
38 | * Procedure LINK creates a hard link from fileHandle to
39 | * name, in the directory,
40 | * parentDirectoryFileHandle. fileHandle and
41 | * parentDirectoryFileHandle must reside on the same file
42 | * system and server.
43 | *
23 | * Procedure PATHCONF retrieves the pathconf information for a file or 24 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, the 25 | * pathconf information will be the same for all files and directories in the 26 | * exported file system in which this file or directory resides. 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class Nfs3PathconfResponse extends NfsPathconfResponse { 32 | 33 | /** 34 | * Creates the response, as specified by RFC 1813 35 | * (https://tools.ietf.org/html/rfc1813). 36 | * 37 | *38 | * Procedure PATHCONF retrieves the pathconf information for a file or 39 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, 40 | * the pathconf information will be the same for all files and directories 41 | * in the exported file system in which this file or directory resides. 42 | *
43 | */ 44 | public Nfs3PathconfResponse() { 45 | super(Nfs3.VERSION); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3GetAttrResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsGetAttrResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure GETATTR retrieves the attributes for a specified file system 24 | * object. The object is identified by the file handle that the server returned 25 | * as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD, or 26 | * READDIRPLUS procedure (or from the MOUNT service, described elsewhere). 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class Nfs3GetAttrResponse extends NfsGetAttrResponse { 32 | 33 | /** 34 | * The response, as specified by RFC 1813 35 | * (https://tools.ietf.org/html/rfc1813). 36 | * 37 | *38 | * Procedure GETATTR retrieves the attributes for a specified file system 39 | * object. The object is identified by the file handle that the server 40 | * returned as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, 41 | * MKNOD, or READDIRPLUS procedure (or from the MOUNT service, described 42 | * elsewhere). 43 | *
44 | */ 45 | public Nfs3GetAttrResponse() { 46 | super(Nfs3.VERSION); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/portmap/GetPortResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.portmap; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.RpcResponse; 19 | import com.emc.ecs.nfsclient.rpc.Xdr; 20 | 21 | /** 22 | * A Portmapper GETPORT response, as specified by https://tools.ietf.org/html/rfc1833. 23 | * 24 | * @author seibed 25 | */ 26 | public class GetPortResponse extends RpcResponse { 27 | 28 | /** 29 | * The port number on which the program is awaiting call requests. A port 30 | * value of zeros means the program has not been registered. Specified by 31 | * https://tools.ietf.org/html/rfc1833. 32 | */ 33 | private int _port; 34 | 35 | /* 36 | * (non-Javadoc) 37 | * 38 | * @see 39 | * com.emc.ecs.nfsclient.rpc.RpcResponse#unmarshalling(com.emc.ecs.nfsclient 40 | * .rpc.Xdr) 41 | */ 42 | public void unmarshalling(Xdr x) throws RpcException { 43 | super.unmarshalling(x); 44 | _port = x.getInt(); 45 | } 46 | 47 | /** 48 | * @return The port number on which the program is awaiting call requests. A 49 | * port value of zeros means the program has not been registered. 50 | * Specified by https://tools.ietf.org/html/rfc1833. 51 | */ 52 | public int getPort() { 53 | return _port; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3FsStatRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsFsStatRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure FSSTAT retrieves volatile file system state information. 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class Nfs3FsStatRequest extends NfsFsStatRequest { 32 | 33 | /** 34 | * Creates the request, as specified by RFC 1813 35 | * (https://tools.ietf.org/html/rfc1813). 36 | * 37 | *38 | * Procedure FSSTAT retrieves volatile file system state information. 39 | *
40 | * 41 | * @param fileHandle 42 | * A file handle identifying a object in the file system. This is 43 | * normally a file handle for a mount point for a file system, as 44 | * originally obtained from the MOUNT service on the server. 45 | * @param credential 46 | * The credential to use for the request 47 | * @throws FileNotFoundException 48 | */ 49 | public Nfs3FsStatRequest(byte[] fileHandle, Credential credential) throws FileNotFoundException { 50 | super(fileHandle, credential, Nfs3.VERSION); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3RenameResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsRenameResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *
23 | * Procedure RENAME renames the file identified by name in the
24 | * directory, fileHandle, to toName in the directory,
25 | * toFileHandle. The operation is required to be atomic to the
26 | * client. toFileHandle and fileHandle must reside on
27 | * the same file system and server.
28 | *
39 | * Procedure RENAME renames the file identified by name in the
40 | * directory, fileHandle, to toName in the
41 | * directory, toFileHandle. The operation is required to be
42 | * atomic to the client. toFileHandle and
43 | * fileHandle must reside on the same file system and server.
44 | *
26 | * Procedure LOOKUP searches a directory for a specific name and returns the 27 | * file handle for the corresponding file system object. 28 | *
29 | * 30 | * @author seibed 31 | */ 32 | public class Nfs3LookupRequest extends NfsLookupRequest { 33 | 34 | /** 35 | * Creates the request, as specified by RFC 1813 36 | * (https://tools.ietf.org/html/rfc1813). 37 | * 38 | *39 | * Procedure LOOKUP searches a directory for a specific name and returns the 40 | * file handle for the corresponding file system object. 41 | *
42 | * 43 | * @param fileHandle 44 | * The file handle for the directory to search. 45 | * @param name 46 | * The filename to be searched for. 47 | * @param credential 48 | * The credential to use for the request 49 | * @throws FileNotFoundException 50 | */ 51 | public Nfs3LookupRequest(byte[] fileHandle, String name, Credential credential) throws FileNotFoundException { 52 | super(fileHandle, name, credential, Nfs3.VERSION); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/rpc/CredentialBase.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.rpc; 16 | 17 | /** 18 | * @author seibed 19 | * 20 | */ 21 | public class CredentialBase implements Credential { 22 | 23 | /* (non-Javadoc) 24 | * @see com.emc.ecs.nfsclient.rpc.Credential#marshalling(com.emc.ecs.nfsclient.rpc.Xdr) 25 | */ 26 | public void marshalling(Xdr xdr) { 27 | xdr.putInt(getCredentialFlavor()); // credential flavor 28 | xdr.putByteArray(getCredential()); // bytes of credentials 29 | xdr.putInt(getVerifierFlavor()); // verifier flavor 30 | xdr.putByteArray(getVerifier()); // bytes of verifier 31 | } 32 | 33 | /** 34 | * The default value is AUTH_NONE. 35 | * 36 | * @return The flavor. 37 | */ 38 | protected int getCredentialFlavor() { 39 | return AUTH_NONE; 40 | } 41 | 42 | /** 43 | * The default value is a 0-byte array. 44 | * 45 | * @return An Xdr structure with the bytes. 46 | */ 47 | protected Xdr getCredential() { 48 | return new Xdr(0); 49 | } 50 | 51 | /** 52 | * The default value is AUTH_NONE. 53 | * 54 | * @return The flavor. 55 | */ 56 | protected int getVerifierFlavor() { 57 | return AUTH_NONE; 58 | } 59 | 60 | /** 61 | * The default value is a 0-byte array. 62 | * 63 | * @return An Xdr structure with the bytes. 64 | */ 65 | protected Xdr getVerifier() { 66 | return new Xdr(0); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/mount/MountException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.mount; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Mount exception class 21 | * 22 | * @author seibed 23 | */ 24 | public class MountException extends IOException { 25 | 26 | /** 27 | * Default value 28 | */ 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** 32 | * The input status instance. 33 | */ 34 | private final MountStatus _status; 35 | 36 | /** 37 | * Construct a new Mount exception with the given status, message, and cause. 38 | * 39 | * @param status 40 | * The status instance. 41 | * @param message 42 | * The error message. 43 | * @param cause 44 | * The cause 45 | */ 46 | public MountException(MountStatus status, String message, Exception cause) { 47 | super(message, cause); 48 | _status = status; 49 | } 50 | 51 | /** 52 | * Construct a new Mount exception with the given status and message. 53 | * 54 | * @param status 55 | * The status instance. 56 | * @param message 57 | * The error message 58 | */ 59 | public MountException(MountStatus status, String message) { 60 | super(message); 61 | _status = status; 62 | } 63 | 64 | /** 65 | * @return The input status instance. 66 | */ 67 | public MountStatus getStatus() { 68 | return _status; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsDirectoryPlusEntry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.Xdr; 18 | 19 | /** 20 | * Holder for entries returned by READDIRPLUS calls, as specified by RFC 1813 21 | * (https://tools.ietf.org/html/rfc1813). 22 | * 23 | * @author seibed 24 | */ 25 | public class NfsDirectoryPlusEntry extends NfsDirectoryEntry { 26 | 27 | /** 28 | * The attributes of the file. 29 | */ 30 | private final NfsGetAttributes _attributes; 31 | 32 | /** 33 | * The file handle, for use in RPC calls. 34 | */ 35 | private final byte[] _fileHandle; 36 | 37 | /** 38 | * Create the entry. 39 | * 40 | * @param xdr 41 | * The response. 42 | */ 43 | public NfsDirectoryPlusEntry(Xdr xdr) { 44 | super(xdr); 45 | if (xdr.getBoolean()) { 46 | _attributes = new NfsGetAttributes(); 47 | _attributes.unmarshalling(xdr); 48 | } else { 49 | _attributes = null; 50 | } 51 | if (xdr.getBoolean()) { 52 | _fileHandle = xdr.getByteArray(); 53 | } else { 54 | _fileHandle = null; 55 | } 56 | } 57 | 58 | /** 59 | * @return The attributes of the file. 60 | */ 61 | public final NfsGetAttributes getAttributes() { 62 | return _attributes; 63 | } 64 | 65 | /** 66 | * @return The file handle, for use in RPC calls. 67 | */ 68 | public final byte[] getFileHandle() { 69 | return _fileHandle; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3FsInfoRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsFsInfoRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure FSINFO retrieves nonvolatile file system state information and 27 | * general information about the NFS version 3 protocol server implementation. 28 | *
29 | * 30 | * @author seibed 31 | */ 32 | public class Nfs3FsInfoRequest extends NfsFsInfoRequest { 33 | 34 | /** 35 | * Creates the request, as specified by RFC 1813 36 | * (https://tools.ietf.org/html/rfc1813). 37 | * 38 | *39 | * Procedure FSINFO retrieves nonvolatile file system state information and 40 | * general information about the NFS version 3 protocol server 41 | * implementation. 42 | *
43 | * 44 | * @param fileHandle 45 | * A file handle identifying a file object. Normal usage is to 46 | * provide a file handle for a mount point for a file system, as 47 | * originally obtained from the MOUNT service on the server. 48 | * @param credential 49 | * The credential to use for the request 50 | * @throws FileNotFoundException 51 | */ 52 | public Nfs3FsInfoRequest(byte[] fileHandle, Credential credential) throws FileNotFoundException { 53 | super(fileHandle, credential, Nfs3.VERSION); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3MkdirRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsMkdirRequest; 20 | import com.emc.ecs.nfsclient.nfs.NfsSetAttributes; 21 | import com.emc.ecs.nfsclient.rpc.Credential; 22 | 23 | /** 24 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 25 | * 26 | *27 | * Procedure MKDIR creates a new subdirectory. 28 | *
29 | * 30 | * @author seibed 31 | */ 32 | public class Nfs3MkdirRequest extends NfsMkdirRequest { 33 | 34 | /** 35 | * Creates the request, as specified by RFC 1813 36 | * (https://tools.ietf.org/html/rfc1813). 37 | * 38 | *39 | * Procedure MKDIR creates a new subdirectory. 40 | *
41 | * 42 | * @param fileHandle 43 | * The file handle for the directory in which the subdirectory is 44 | * to be created. 45 | * @param name 46 | * The name that is to be associated with the created 47 | * subdirectory. 48 | * @param attributes 49 | * The initial attributes for the subdirectory. 50 | * @param credential 51 | * The credential used for RPC authentication. 52 | * @throws FileNotFoundException 53 | */ 54 | public Nfs3MkdirRequest(byte[] fileHandle, String name, NfsSetAttributes attributes, Credential credential) 55 | throws FileNotFoundException { 56 | super(fileHandle, name, attributes, credential, Nfs3.VERSION); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3RemoveRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsRemoveRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure REMOVE removes (deletes) an entry from a directory. If the entry in 27 | * the directory was the last reference to the corresponding file system object, 28 | * the object may be destroyed. 29 | *
30 | * 31 | * @author seibed 32 | */ 33 | public class Nfs3RemoveRequest extends NfsRemoveRequest { 34 | 35 | /** 36 | * Creates the request, as specified by RFC 1813 37 | * (https://tools.ietf.org/html/rfc1813). 38 | * 39 | *40 | * Procedure REMOVE removes (deletes) an entry from a directory. If the 41 | * entry in the directory was the last reference to the corresponding file 42 | * system object, the object may be destroyed. 43 | *
44 | * 45 | * @param fileHandle 46 | * The file handle for the directory from which the entry is to 47 | * be removed. 48 | * @param name 49 | * The name of the entry to be removed. 50 | * @param credential 51 | * The credential used for RPC authentication. 52 | * @throws FileNotFoundException 53 | */ 54 | Nfs3RemoveRequest(byte[] fileHandle, String name, Credential credential) throws FileNotFoundException { 55 | super(fileHandle, name, credential, Nfs3.VERSION); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsResponseHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import java.io.FileNotFoundException; 18 | import java.io.IOException; 19 | 20 | import com.emc.ecs.nfsclient.rpc.RpcResponseHandler; 21 | import com.emc.ecs.nfsclient.rpc.RejectStatus; 22 | import com.emc.ecs.nfsclient.rpc.RpcRequest; 23 | 24 | /** 25 | * The NFS response handler, used in the wrapper class for post-response 26 | * actions, including error checking. This base class performs just basic 27 | * response correctness checking that applies to all NFS responses. 28 | * 29 | * @author seibed 30 | */ 31 | public abstract class NfsResponseHandler26 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 27 | * directory entry of the subdirectory is the last reference to the 28 | * subdirectory, the subdirectory may be destroyed. 29 | *
30 | * 31 | * @author seibed 32 | */ 33 | public class Nfs3RmdirRequest extends NfsRmdirRequest { 34 | 35 | /** 36 | * Creates the request, as specified by RFC 1813 37 | * (https://tools.ietf.org/html/rfc1813). 38 | * 39 | *40 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 41 | * directory entry of the subdirectory is the last reference to the 42 | * subdirectory, the subdirectory may be destroyed. 43 | *
44 | * 45 | * @param fileHandle 46 | * The file handle for the directory from which the subdirectory 47 | * is to be removed. 48 | * @param name 49 | * The name of the subdirectory to be removed. 50 | * @param credential 51 | * The credential used for RPC authentication. 52 | * @throws FileNotFoundException 53 | */ 54 | public Nfs3RmdirRequest(byte[] fileHandle, String name, Credential credential) throws FileNotFoundException { 55 | super(fileHandle, name, credential, Nfs3.VERSION); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsFsStatRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.rpc.Credential; 20 | 21 | /** 22 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 23 | * 24 | *25 | * Procedure FSSTAT retrieves volatile file system state information. 26 | *
27 | * 28 | * @author seibed 29 | */ 30 | public class NfsFsStatRequest extends NfsRequestBase { 31 | 32 | /** 33 | * Creates the request, as specified by RFC 1813 34 | * (https://tools.ietf.org/html/rfc1813). 35 | * 36 | *37 | * Procedure FSSTAT retrieves volatile file system state information. 38 | *
39 | * 40 | * @param fileHandle 41 | * A file handle identifying a object in the file system. This is 42 | * normally a file handle for a mount point for a file system, as 43 | * originally obtained from the MOUNT service on the server. 44 | * @param credential 45 | * The credential used for RPC authentication. 46 | * @param nfsVersion 47 | * The NFS version number 48 | * @throws FileNotFoundException 49 | */ 50 | public NfsFsStatRequest(byte[] fileHandle, Credential credential, int nfsVersion) throws FileNotFoundException { 51 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_FSSTAT, credential, fileHandle); 52 | } 53 | 54 | /* 55 | * (non-Javadoc) 56 | * 57 | * @see java.lang.Object#toString() 58 | */ 59 | public String toString() { 60 | return startToString("NfsFsStatRequest").toString(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsDirectoryEntry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.Xdr; 18 | 19 | /** 20 | * Holder for entries returned by READDIR calls, as specified by RFC 1813 21 | * (https://tools.ietf.org/html/rfc1813). 22 | * 23 | * @author seibed 24 | */ 25 | public class NfsDirectoryEntry { 26 | 27 | /** 28 | * The cookie from the server, for use in future RPC calls. 29 | */ 30 | private final long _cookie; 31 | 32 | /** 33 | * A number which uniquely identifies the file within its file system (on 34 | * UNIX this would be the inumber). 35 | */ 36 | private final long _fileId; 37 | 38 | /** 39 | * The file name from the directory listing. 40 | */ 41 | private final String _fileName; 42 | 43 | /** 44 | * Create a new entry. 45 | * 46 | * @param xdr The response. 47 | */ 48 | public NfsDirectoryEntry(Xdr xdr) { 49 | _fileId = xdr.getLong(); 50 | _fileName = xdr.getString(); 51 | _cookie = xdr.getLong(); 52 | } 53 | 54 | /** 55 | * @return The cookie from the server, for use in future RPC calls. 56 | */ 57 | public final long getCookie() { 58 | return _cookie; 59 | } 60 | 61 | /** 62 | * @return 63 | * A number which uniquely identifies the file within its file system (on 64 | * UNIX this would be the inumber). 65 | */ 66 | public final long getFileId() { 67 | return _fileId; 68 | } 69 | 70 | /** 71 | * @return The file name from the directory listing. 72 | */ 73 | public final String getFileName() { 74 | return _fileName; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3PathconfRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsPathconfRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure PATHCONF retrieves the pathconf information for a file or 27 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, the 28 | * pathconf information will be the same for all files and directories in the 29 | * exported file system in which this file or directory resides. 30 | *
31 | * 32 | * @author seibed 33 | */ 34 | public class Nfs3PathconfRequest extends NfsPathconfRequest { 35 | 36 | /** 37 | * Creates the request, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure PATHCONF retrieves the pathconf information for a file or 42 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, 43 | * the pathconf information will be the same for all files and directories 44 | * in the exported file system in which this file or directory resides. 45 | *
46 | * 47 | * @param fileHandle 48 | * The file handle for the file system object. 49 | * @param credential 50 | * The credential used for RPC authentication. 51 | * @throws FileNotFoundException 52 | */ 53 | public Nfs3PathconfRequest(byte[] fileHandle, Credential credential) throws FileNotFoundException { 54 | super(fileHandle, credential, Nfs3.VERSION); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3SymlinkRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsSetAttributes; 20 | import com.emc.ecs.nfsclient.nfs.NfsSymlinkRequest; 21 | import com.emc.ecs.nfsclient.rpc.Credential; 22 | 23 | /** 24 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 25 | * 26 | *27 | * Procedure SYMLINK creates a new symbolic link. 28 | *
29 | * 30 | * @author seibed 31 | */ 32 | public class Nfs3SymlinkRequest extends NfsSymlinkRequest { 33 | 34 | /** 35 | * Creates the request, as specified by RFC 1813 36 | * (https://tools.ietf.org/html/rfc1813). 37 | * 38 | *39 | * Procedure SYMLINK creates a new symbolic link. 40 | *
41 | * 42 | * @param symbolicLinkData 43 | * The string containing the symbolic link data. 44 | * @param fileHandle 45 | * The file handle for the directory in which the symbolic link 46 | * is to be created. 47 | * @param name 48 | * The name that is to be associated with the created symbolic 49 | * link. 50 | * @param attributes 51 | * The initial attributes for the symbolic link. 52 | * @param credential 53 | * The credential used for RPC authentication. 54 | * @throws FileNotFoundException 55 | */ 56 | public Nfs3SymlinkRequest(String symbolicLinkData, byte[] fileHandle, String name, NfsSetAttributes attributes, 57 | Credential credential) throws FileNotFoundException { 58 | super(symbolicLinkData, fileHandle, name, attributes, credential, Nfs3.VERSION); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3GetAttrRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsGetAttrRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure GETATTR retrieves the attributes for a specified file system 27 | * object. The object is identified by the file handle that the server returned 28 | * as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD, or 29 | * READDIRPLUS procedure (or from the MOUNT service, described elsewhere). 30 | *
31 | * 32 | * @author seibed 33 | */ 34 | public class Nfs3GetAttrRequest extends NfsGetAttrRequest { 35 | 36 | /** 37 | * Creates the request, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure GETATTR retrieves the attributes for a specified file system 42 | * object. The object is identified by the file handle that the server 43 | * returned as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, 44 | * MKNOD, or READDIRPLUS procedure (or from the MOUNT service, described 45 | * elsewhere). 46 | *
47 | * 48 | * @param fileHandle 49 | * The file handle of an object whose attributes are to be 50 | * retrieved. 51 | * @param credential 52 | * The credential to use for the request 53 | * @throws FileNotFoundException 54 | */ 55 | public Nfs3GetAttrRequest(byte[] fileHandle, Credential credential) throws FileNotFoundException { 56 | super(fileHandle, credential, Nfs3.VERSION); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/rpc/RpcResponseHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.rpc; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * This class allows users to specify how new response instances are created 21 | * during repeated RPC calls, and how responses are validated before their data 22 | * is used. 23 | * 24 | * @author seibed 25 | */ 26 | public abstract class RpcResponseHandler24 | * Procedure FSSTAT retrieves volatile file system state information. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class NfsFsStatResponse extends NfsResponseBase { 30 | 31 | /** 32 | * The volatile file system state information. 33 | */ 34 | private NfsFsStat _fsStat; 35 | 36 | /** 37 | * Creates the response, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure FSSTAT retrieves volatile file system state information. 42 | *
43 | * 44 | * @param nfsVersion 45 | * The NFS version number. This is ignored for now, as only NFSv3 46 | * is supported, but is included to allow future support for 47 | * other versions. 48 | */ 49 | public NfsFsStatResponse(int nfsVersion) { 50 | super(); 51 | } 52 | 53 | /* 54 | * (non-Javadoc) 55 | * 56 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 57 | * nfsclient.rpc.Xdr) 58 | */ 59 | public void unmarshalling(Xdr xdr) throws RpcException { 60 | super.unmarshalling(xdr); 61 | unmarshallingAttributes(xdr); 62 | if (stateIsOk()) { 63 | _fsStat = new NfsFsStat(xdr); 64 | } 65 | } 66 | 67 | /** 68 | * @return The volatile file system state information. 69 | */ 70 | public NfsFsStat getFsStat() { 71 | return _fsStat; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3CommitRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsCommitRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | * 26 | * @author seibed 27 | */ 28 | public class Nfs3CommitRequest extends NfsCommitRequest { 29 | 30 | /** 31 | * Creates the request, as specified by RFC 1813 32 | * (https://tools.ietf.org/html/rfc1813). 33 | * 34 | *35 | * Procedure COMMIT forces or flushes data to stable storage that was 36 | * previously written with a WRITE procedure call with the stable field set 37 | * to UNSTABLE. 38 | *
39 | * 40 | * @param fileHandle 41 | * The file handle for the file to which data is to be flushed 42 | * (committed). This must identify a file system object of type, 43 | * NF3REG. 44 | * @param offsetToCommit 45 | * The position within the file at which the flush is to begin. 46 | * An offset of 0 means to flush data starting at the beginning 47 | * of the file. 48 | * @param dataSizeToCommit 49 | * The number of bytes of data to flush. If count is 0, a flush 50 | * from offset to the end of file is done. 51 | * @param credential 52 | * The credential used for RPC authentication. 53 | * @throws FileNotFoundException 54 | */ 55 | public Nfs3CommitRequest(byte[] fileHandle, long offsetToCommit, int dataSizeToCommit, Credential credential) throws FileNotFoundException { 56 | super(fileHandle, offsetToCommit, dataSizeToCommit, credential, Nfs3.VERSION); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsCreateResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *24 | * Procedure CREATE creates a regular file. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class NfsCreateResponse extends NfsResponseBase { 30 | 31 | /** 32 | * Weak cache consistency data for the directory. 33 | */ 34 | private NfsWccData _directoryWccData = new NfsWccData(); 35 | 36 | /** 37 | * Creates the response, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure CREATE creates a regular file. 42 | *
43 | * 44 | * @param nfsVersion 45 | * The NFS version number. This is ignored for now, as only NFSv3 46 | * is supported, but is included to allow future support for 47 | * other versions. 48 | */ 49 | public NfsCreateResponse(int nfsVersion) { 50 | super(); 51 | } 52 | 53 | /* 54 | * (non-Javadoc) 55 | * 56 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 57 | * nfsclient.rpc.Xdr) 58 | */ 59 | public void unmarshalling(Xdr xdr) throws RpcException { 60 | super.unmarshalling(xdr); 61 | if (stateIsOk()) { 62 | unmarshallingFileHandle(xdr); 63 | unmarshallingAttributes(xdr); 64 | } 65 | _directoryWccData = new NfsWccData(xdr); 66 | } 67 | 68 | /** 69 | * @return Weak cache consistency data for the directory. 70 | */ 71 | public NfsWccData getDirectoryWccData() { 72 | return _directoryWccData; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsMkdirResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *24 | * Procedure MKDIR creates a new subdirectory. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class NfsMkdirResponse extends NfsResponseBase { 30 | 31 | /** 32 | * Weak cache consistency data for the parent directory. 33 | */ 34 | private NfsWccData _directoryWccData = new NfsWccData(); 35 | 36 | /** 37 | * Creates the response, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure MKDIR creates a new subdirectory. 42 | *
43 | * 44 | * @param nfsVersion 45 | * The NFS version number. This is ignored for now, as only NFSv3 46 | * is supported, but is included to allow future support for 47 | * other versions. 48 | */ 49 | public NfsMkdirResponse(int nfsVersion) { 50 | super(); 51 | } 52 | 53 | /* 54 | * (non-Javadoc) 55 | * 56 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 57 | * nfsclient.rpc.Xdr) 58 | */ 59 | public void unmarshalling(Xdr xdr) throws RpcException { 60 | super.unmarshalling(xdr); 61 | if (stateIsOk()) { 62 | unmarshallingFileHandle(xdr); 63 | unmarshallingAttributes(xdr); 64 | } 65 | _directoryWccData = new NfsWccData(xdr); 66 | } 67 | 68 | /** 69 | * @return Weak cache consistency data for the parent directory. 70 | */ 71 | public NfsWccData getDirectoryWccData() { 72 | return _directoryWccData; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsSetAttrResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *24 | * Procedure SETATTR changes one or more of the attributes of a file system 25 | * object on the server. 26 | *
27 | * 28 | * @author seibed 29 | */ 30 | public class NfsSetAttrResponse extends NfsResponseBase { 31 | 32 | /** 33 | * A structure containing the old and new attributes for the object. 34 | */ 35 | private NfsWccData _objectWccData = new NfsWccData(); 36 | 37 | /** 38 | * Creates the response, as specified by RFC 1813 39 | * (https://tools.ietf.org/html/rfc1813). 40 | * 41 | *42 | * Procedure SETATTR changes one or more of the attributes of a file system 43 | * object on the server. 44 | *
45 | * 46 | * @param nfsVersion 47 | * The NFS version number. This is ignored for now, as only NFSv3 48 | * is supported, but is included to allow future support for 49 | * other versions. 50 | */ 51 | public NfsSetAttrResponse(int nfsVersion) { 52 | super(); 53 | } 54 | 55 | /* 56 | * (non-Javadoc) 57 | * 58 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 59 | * nfsclient.rpc.Xdr) 60 | */ 61 | public void unmarshalling(Xdr xdr) throws RpcException { 62 | super.unmarshalling(xdr); 63 | _objectWccData = new NfsWccData(xdr); 64 | } 65 | 66 | /** 67 | * @return A structure containing the old and new attributes for the object. 68 | */ 69 | public NfsWccData getObjectWccData() { 70 | return _objectWccData; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsSymlinkResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *24 | * Procedure SYMLINK creates a new symbolic link. 25 | *
26 | * 27 | * @author seibed 28 | */ 29 | public class NfsSymlinkResponse extends NfsResponseBase { 30 | 31 | /** 32 | * Weak cache consistency data for the directory. 33 | */ 34 | private NfsWccData _directoryWccData = new NfsWccData(); 35 | 36 | /** 37 | * Creates the response, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure SYMLINK creates a new symbolic link. 42 | *
43 | * 44 | * @param nfsVersion 45 | * The NFS version number. This is ignored for now, as only NFSv3 46 | * is supported, but is included to allow future support for 47 | * other versions. 48 | */ 49 | public NfsSymlinkResponse(int nfsVersion) { 50 | super(); 51 | } 52 | 53 | /* 54 | * (non-Javadoc) 55 | * 56 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 57 | * nfsclient.rpc.Xdr) 58 | */ 59 | public void unmarshalling(Xdr xdr) throws RpcException { 60 | super.unmarshalling(xdr); 61 | if (stateIsOk()) { 62 | unmarshallingFileHandle(xdr); 63 | unmarshallingAttributes(xdr); 64 | } 65 | _directoryWccData = new NfsWccData(xdr); 66 | } 67 | 68 | /** 69 | * @return Weak cache consistency data for the directory. 70 | */ 71 | public NfsWccData getDirectoryWccData() { 72 | return _directoryWccData; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsFsInfoRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.rpc.Credential; 20 | 21 | /** 22 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 23 | * 24 | *25 | * Procedure FSINFO retrieves nonvolatile file system state information and 26 | * general information about the NFS version 3 protocol server implementation. 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class NfsFsInfoRequest extends NfsRequestBase { 32 | 33 | /** 34 | * Creates the request, as specified by RFC 1813 35 | * (https://tools.ietf.org/html/rfc1813). 36 | * 37 | *38 | * Procedure FSINFO retrieves nonvolatile file system state information and 39 | * general information about the NFS version 3 protocol server 40 | * implementation. 41 | *
42 | * 43 | * @param fileHandle 44 | * A file handle identifying a file object. Normal usage is to 45 | * provide a file handle for a mount point for a file system, as 46 | * originally obtained from the MOUNT service on the server. 47 | * @param credential 48 | * The credential used for RPC authentication. 49 | * @param nfsVersion 50 | * The NFS version number 51 | * @throws FileNotFoundException 52 | */ 53 | public NfsFsInfoRequest(byte[] fileHandle, Credential credential, int nfsVersion) throws FileNotFoundException { 54 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_FSINFO, credential, fileHandle); 55 | } 56 | 57 | /* 58 | * (non-Javadoc) 59 | * 60 | * @see java.lang.Object#toString() 61 | */ 62 | public String toString() { 63 | return startToString("NfsFsInfoRequest").toString(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3SetAttrRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsSetAttrRequest; 20 | import com.emc.ecs.nfsclient.nfs.NfsSetAttributes; 21 | import com.emc.ecs.nfsclient.nfs.NfsTime; 22 | import com.emc.ecs.nfsclient.rpc.Credential; 23 | 24 | /** 25 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 26 | * 27 | *28 | * Procedure SETATTR changes one or more of the attributes of a file system 29 | * object on the server. 30 | *
31 | * 32 | * @author seibed 33 | */ 34 | public class Nfs3SetAttrRequest extends NfsSetAttrRequest { 35 | 36 | /** 37 | * Creates the request, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure SETATTR changes one or more of the attributes of a file system 42 | * object on the server. 43 | *
44 | * 45 | * @param fileHandle 46 | * The file handle for the object. 47 | * @param attributes 48 | * The attributes to set. 49 | * @param guardTime 50 | * IfguardTime is not null, the server must compare
51 | * the value of guardTime to the current ctime of
52 | * the object. If the values are different, the server must
53 | * preserve the object attributes and must return a status of
54 | * NFS3ERR_NOT_SYNC.
55 | * @param credential
56 | * The credential used for RPC authentication.
57 | * @throws FileNotFoundException
58 | */
59 | public Nfs3SetAttrRequest(byte[] fileHandle, NfsSetAttributes attributes, NfsTime guardTime, Credential credential)
60 | throws FileNotFoundException {
61 | super(fileHandle, attributes, guardTime, credential, Nfs3.VERSION);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/NfsGetAttrResponse.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs;
16 |
17 | import com.emc.ecs.nfsclient.rpc.RpcException;
18 | import com.emc.ecs.nfsclient.rpc.Xdr;
19 |
20 | /**
21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813).
22 | *
23 | * 24 | * Procedure GETATTR retrieves the attributes for a specified file system 25 | * object. The object is identified by the file handle that the server returned 26 | * as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD, or 27 | * READDIRPLUS procedure (or from the MOUNT service, described elsewhere). 28 | *
29 | * 30 | * @author seibed 31 | */ 32 | public class NfsGetAttrResponse extends NfsResponseBase { 33 | 34 | /** 35 | * Creates the response, as specified by RFC 1813 36 | * (https://tools.ietf.org/html/rfc1813). 37 | * 38 | *39 | * Procedure GETATTR retrieves the attributes for a specified file system 40 | * object. The object is identified by the file handle that the server 41 | * returned as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, 42 | * MKNOD, or READDIRPLUS procedure (or from the MOUNT service, described 43 | * elsewhere). 44 | *
45 | * 46 | * @param nfsVersion 47 | * The NFS version number. This is ignored for now, as only NFSv3 48 | * is supported, but is included to allow future support for 49 | * other versions. 50 | */ 51 | public NfsGetAttrResponse(int nfsVersion) { 52 | super(); 53 | } 54 | 55 | /* 56 | * (non-Javadoc) 57 | * 58 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 59 | * nfsclient.rpc.Xdr) 60 | */ 61 | public void unmarshalling(Xdr xdr) throws RpcException { 62 | super.unmarshalling(xdr); 63 | if (stateIsOk()) { 64 | unmarshallingAttributes(xdr, true); 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsPathconfRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.rpc.Credential; 20 | 21 | /** 22 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 23 | * 24 | *25 | * Procedure PATHCONF retrieves the pathconf information for a file or 26 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, the 27 | * pathconf information will be the same for all files and directories in the 28 | * exported file system in which this file or directory resides. 29 | *
30 | * 31 | * @author seibed 32 | */ 33 | public class NfsPathconfRequest extends NfsRequestBase { 34 | 35 | /** 36 | * Creates the request, as specified by RFC 1813 37 | * (https://tools.ietf.org/html/rfc1813). 38 | * 39 | *40 | * Procedure PATHCONF retrieves the pathconf information for a file or 41 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, 42 | * the pathconf information will be the same for all files and directories 43 | * in the exported file system in which this file or directory resides. 44 | *
45 | * 46 | * @param fileHandle 47 | * The file handle for the file system object. 48 | * @param credential 49 | * The credential used for RPC authentication. 50 | * @param nfsVersion 51 | * The NFS version number 52 | * @throws FileNotFoundException 53 | */ 54 | public NfsPathconfRequest(byte[] fileHandle, Credential credential, int nfsVersion) throws FileNotFoundException { 55 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_PATHCONF, credential, fileHandle); 56 | } 57 | 58 | /* 59 | * (non-Javadoc) 60 | * 61 | * @see java.lang.Object#toString() 62 | */ 63 | public String toString() { 64 | return startToString("NfsPathconfRequest").toString(); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3ReaddirResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsDirectoryEntry; 18 | import com.emc.ecs.nfsclient.nfs.NfsReaddirResponse; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure READDIR retrieves a variable number of entries, in sequence, from a 27 | * directory and returns the name and file identifier for each, with information 28 | * to allow the client to request additional directory entries in a subsequent 29 | * READDIR request. 30 | *
31 | * 32 | * @author seibed 33 | */ 34 | public class Nfs3ReaddirResponse extends NfsReaddirResponse { 35 | 36 | /** 37 | * Creates the response, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure READDIR retrieves a variable number of entries, in sequence, 42 | * from a directory and returns the name and file identifier for each, with 43 | * information to allow the client to request additional directory entries 44 | * in a subsequent READDIR request. 45 | *
46 | */ 47 | public Nfs3ReaddirResponse() { 48 | super(Nfs3.VERSION); 49 | } 50 | 51 | /** 52 | * Creates the response, as specified by RFC 1813 53 | * (https://tools.ietf.org/html/rfc1813). 54 | * 55 | *56 | * Procedure READDIR retrieves a variable number of entries, in sequence, 57 | * from a directory and returns the name and file identifier for each, with 58 | * information to allow the client to request additional directory entries 59 | * in a subsequent READDIR request. 60 | *
61 | * 62 | * @param entries 63 | * A list in which to store the entries. 64 | */ 65 | public Nfs3ReaddirResponse(List24 | * Procedure REMOVE removes (deletes) an entry from a directory. If the entry in 25 | * the directory was the last reference to the corresponding file system object, 26 | * the object may be destroyed. 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class NfsRemoveResponse extends NfsResponseBase { 32 | 33 | /** 34 | * Weak cache consistency data for the directory. 35 | */ 36 | private NfsWccData _directoryWccData = new NfsWccData(); 37 | 38 | /** 39 | * Creates the response, as specified by RFC 1813 40 | * (https://tools.ietf.org/html/rfc1813). 41 | * 42 | *43 | * Procedure REMOVE removes (deletes) an entry from a directory. If the 44 | * entry in the directory was the last reference to the corresponding file 45 | * system object, the object may be destroyed. 46 | *
47 | * 48 | * @param nfsVersion 49 | * The NFS version number. This is ignored for now, as only NFSv3 50 | * is supported, but is included to allow future support for 51 | * other versions. 52 | */ 53 | public NfsRemoveResponse(int nfsVersion) { 54 | super(); 55 | } 56 | 57 | /* 58 | * (non-Javadoc) 59 | * 60 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 61 | * nfsclient.rpc.Xdr) 62 | */ 63 | public void unmarshalling(Xdr xdr) throws RpcException { 64 | super.unmarshalling(xdr); 65 | _directoryWccData = new NfsWccData(xdr); 66 | } 67 | 68 | /** 69 | * @return Weak cache consistency data for the directory. 70 | */ 71 | public NfsWccData getDirectoryWccData() { 72 | return _directoryWccData; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsRmdirResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *24 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 25 | * directory entry of the subdirectory is the last reference to the 26 | * subdirectory, the subdirectory may be destroyed. 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class NfsRmdirResponse extends NfsResponseBase { 32 | 33 | /** 34 | * Weak cache consistency data for the directory. 35 | */ 36 | private NfsWccData _directoryWccData = new NfsWccData(); 37 | 38 | /** 39 | * Creates the response, as specified by RFC 1813 40 | * (https://tools.ietf.org/html/rfc1813). 41 | * 42 | *43 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 44 | * directory entry of the subdirectory is the last reference to the 45 | * subdirectory, the subdirectory may be destroyed. 46 | *
47 | * 48 | * @param nfsVersion 49 | * The NFS version number. This is ignored for now, as only NFSv3 50 | * is supported, but is included to allow future support for 51 | * other versions. 52 | */ 53 | public NfsRmdirResponse(int nfsVersion) { 54 | super(); 55 | } 56 | 57 | /* 58 | * (non-Javadoc) 59 | * 60 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 61 | * nfsclient.rpc.Xdr) 62 | */ 63 | public void unmarshalling(Xdr xdr) throws RpcException { 64 | super.unmarshalling(xdr); 65 | _directoryWccData = new NfsWccData(xdr); 66 | } 67 | 68 | /** 69 | * @return Weak cache consistency data for the directory. 70 | */ 71 | public NfsWccData getDirectoryWccData() { 72 | return _directoryWccData; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3LinkRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsLinkRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *
26 | * Procedure LINK creates a hard link from fileHandle to
27 | * name, in the directory, parentDirectoryFileHandle.
28 | * fileHandle and parentDirectoryFileHandle must
29 | * reside on the same file system and server.
30 | *
41 | * Procedure LINK creates a hard link from fileHandle to
42 | * name, in the directory,
43 | * parentDirectoryFileHandle. fileHandle and
44 | * parentDirectoryFileHandle must reside on the same file
45 | * system and server.
46 | *
24 | * Procedure MKNOD creates a new special file of the type, type .
25 | * Special files can be device files or named pipes.
26 | *
42 | * Procedure MKNOD creates a new special file of the type, type
43 | * . Special files can be device files or named pipes.
44 | *
25 | * Procedure GETATTR retrieves the attributes for a specified file system 26 | * object. The object is identified by the file handle that the server returned 27 | * as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD, or 28 | * READDIRPLUS procedure (or from the MOUNT service, described elsewhere). 29 | *
30 | * 31 | * @author seibed 32 | */ 33 | public class NfsGetAttrRequest extends NfsRequestBase { 34 | 35 | /** 36 | * Creates the request, as specified by RFC 1813 37 | * (https://tools.ietf.org/html/rfc1813). 38 | * 39 | *40 | * Procedure GETATTR retrieves the attributes for a specified file system 41 | * object. The object is identified by the file handle that the server 42 | * returned as part of the response from a LOOKUP, CREATE, MKDIR, SYMLINK, 43 | * MKNOD, or READDIRPLUS procedure (or from the MOUNT service, described 44 | * elsewhere). 45 | *
46 | * 47 | * @param fileHandle 48 | * The file handle of an object whose attributes are to be 49 | * retrieved. 50 | * @param credential 51 | * The credential used for RPC authentication. 52 | * @param nfsVersion 53 | * The NFS version number 54 | * @throws FileNotFoundException 55 | */ 56 | public NfsGetAttrRequest(byte[] fileHandle, Credential credential, int nfsVersion) throws FileNotFoundException { 57 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_GETATTR, credential, fileHandle); 58 | } 59 | 60 | /* 61 | * (non-Javadoc) 62 | * 63 | * @see java.lang.Object#toString() 64 | */ 65 | public String toString() { 66 | return startToString("NfsGetAttrRequest").toString(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsLookupResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *24 | * Procedure LOOKUP searches a directory for a specific name and returns the 25 | * file handle for the corresponding file system object. 26 | *
27 | * 28 | * @author seibed 29 | */ 30 | public class NfsLookupResponse extends NfsResponseBase { 31 | 32 | /** 33 | * The post-operation attributes for the directory. 34 | */ 35 | private NfsGetAttributes _directoryAttributes; 36 | 37 | /** 38 | * Creates the response, as specified by RFC 1813 39 | * (https://tools.ietf.org/html/rfc1813). 40 | * 41 | *42 | * Procedure LOOKUP searches a directory for a specific name and returns the 43 | * file handle for the corresponding file system object. 44 | *
45 | * 46 | * @param nfsVersion 47 | * The NFS version number. This is ignored for now, as only NFSv3 48 | * is supported, but is included to allow future support for 49 | * other versions. 50 | */ 51 | public NfsLookupResponse(int nfsVersion) { 52 | super(); 53 | } 54 | 55 | /* 56 | * (non-Javadoc) 57 | * 58 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 59 | * nfsclient.rpc.Xdr) 60 | */ 61 | public void unmarshalling(Xdr xdr) throws RpcException { 62 | super.unmarshalling(xdr); 63 | if (stateIsOk()) { 64 | unmarshallingFileHandle(xdr, true); 65 | unmarshallingAttributes(xdr); 66 | } 67 | _directoryAttributes = makeNfsGetAttributes(xdr); 68 | } 69 | 70 | /** 71 | * @return The post-operation attributes for the directory. 72 | */ 73 | public NfsGetAttributes getDirectoryAttributes() { 74 | return _directoryAttributes; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsFsInfoResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *24 | * Procedure FSINFO retrieves nonvolatile file system state information and 25 | * general information about the NFS version 3 protocol server implementation. 26 | *
27 | * 28 | * @author seibed 29 | */ 30 | public class NfsFsInfoResponse extends NfsResponseBase { 31 | 32 | /** 33 | * The returned information. 34 | */ 35 | private NfsFsInfo _fsInfo; 36 | 37 | /** 38 | * Creates the response, as specified by RFC 1813 39 | * (https://tools.ietf.org/html/rfc1813). 40 | * 41 | *42 | * Procedure FSINFO retrieves nonvolatile file system state information and 43 | * general information about the NFS version 3 protocol server 44 | * implementation. 45 | *
46 | * 47 | * @param nfsVersion 48 | * The NFS version number. This is ignored for now, as only NFSv3 49 | * is supported, but is included to allow future support for 50 | * other versions. 51 | */ 52 | public NfsFsInfoResponse(int nfsVersion) { 53 | super(); 54 | } 55 | 56 | /* 57 | * (non-Javadoc) 58 | * 59 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 60 | * nfsclient.rpc.Xdr) 61 | */ 62 | public void unmarshalling(Xdr xdr) throws RpcException { 63 | super.unmarshalling(xdr); 64 | unmarshallingAttributes(xdr); 65 | if (stateIsOk()) { 66 | _fsInfo = new NfsFsInfo(xdr); 67 | } 68 | } 69 | 70 | /** 71 | * @return the nonvolatile file system state information and 72 | * general information about the NFS version 3 protocol server 73 | * implementation 74 | */ 75 | public NfsFsInfo getFsInfo() { 76 | return _fsInfo; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3WriteRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsWriteRequest; 18 | import com.emc.ecs.nfsclient.rpc.Credential; 19 | 20 | import java.io.FileNotFoundException; 21 | import java.nio.ByteBuffer; 22 | import java.util.List; 23 | 24 | /** 25 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 26 | * 27 | *28 | * Procedure WRITE writes data to a file. 29 | *
30 | * 31 | * @author seibed 32 | */ 33 | public class Nfs3WriteRequest extends NfsWriteRequest { 34 | 35 | /** 36 | * Creates the request, as specified by RFC 1813 37 | * (https://tools.ietf.org/html/rfc1813). 38 | * 39 | *40 | * Procedure WRITE writes data to a file. 41 | *
42 | * 43 | * @param fileHandle 44 | * The file handle for the file to which data is to be written. 45 | * This must identify a file system object of type, NF3REG. 46 | * @param offset 47 | * The position within the file at which the write is to begin. 48 | * An offset of 0 means to write data starting at the beginning 49 | * of the file. 50 | * @param payload 51 | * The data to be written to the file. 52 | * @param syncType 53 | * One of the values below. 54 | *26 | * Procedure LOOKUP searches a directory for a specific name and returns the 27 | * file handle for the corresponding file system object. 28 | *
29 | * 30 | * @author seibed 31 | */ 32 | public class NfsLookupRequest extends NfsRequestBase { 33 | 34 | /** 35 | * The filename to be searched for. 36 | */ 37 | private final String _name; 38 | 39 | /** 40 | * Creates the request, as specified by RFC 1813 41 | * (https://tools.ietf.org/html/rfc1813). 42 | * 43 | *44 | * Procedure LOOKUP searches a directory for a specific name and returns the 45 | * file handle for the corresponding file system object. 46 | *
47 | * 48 | * @param fileHandle 49 | * The file handle for the directory to search. 50 | * @param name 51 | * The filename to be searched for. 52 | * @param credential 53 | * The credential used for RPC authentication. 54 | * @param nfsVersion 55 | * The NFS version number 56 | * @throws FileNotFoundException 57 | */ 58 | public NfsLookupRequest(byte[] fileHandle, String name, Credential credential, int nfsVersion) 59 | throws FileNotFoundException { 60 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_LOOKUP, credential, fileHandle); 61 | _name = trimFileName(name); 62 | } 63 | 64 | /* 65 | * (non-Javadoc) 66 | * 67 | * @see com.emc.ecs.nfsclient.nfs.NfsRequestBase#marshalling(com.emc.ecs. 68 | * nfsclient.rpc.Xdr) 69 | */ 70 | public void marshalling(Xdr xdr) { 71 | super.marshalling(xdr); 72 | xdr.putString(_name); 73 | } 74 | 75 | /* 76 | * (non-Javadoc) 77 | * 78 | * @see java.lang.Object#toString() 79 | */ 80 | public String toString() { 81 | return startToString("NfsLookupRequest").append(" name:").append(_name).toString(); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3AccessResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsAccessResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * Procedure ACCESS determines the access rights that a user, as identified by 24 | * the credentials in the request, has with respect to a file system object. The 25 | * client encodes the set of permissions that are to be checked in a bit mask. 26 | * The server checks the permissions encoded in the bit mask. A status of 27 | * NFS3_OK is returned along with a bit mask encoded with the permissions that 28 | * the client is allowed. 29 | *
30 | * 31 | *32 | * The results of this procedure are necessarily advisory in nature. That is, a 33 | * return status of NFS3_OK and the appropriate bit set in the bit mask does not 34 | * imply that such access will be allowed to the file system object in the 35 | * future, as access rights can be revoked by the server at any time. 36 | *
37 | * 38 | * @author seibed 39 | */ 40 | public class Nfs3AccessResponse extends NfsAccessResponse { 41 | 42 | /** 43 | * Creates the response, as specified by RFC 1813 44 | * (https://tools.ietf.org/html/rfc1813). 45 | * 46 | *47 | * Procedure ACCESS determines the access rights that a user, as identified 48 | * by the credentials in the request, has with respect to a file system 49 | * object. The client encodes the set of permissions that are to be checked 50 | * in a bit mask. The server checks the permissions encoded in the bit mask. 51 | * A status of NFS3_OK is returned along with a bit mask encoded with the 52 | * permissions that the client is allowed. 53 | *
54 | * 55 | *56 | * The results of this procedure are necessarily advisory in nature. That 57 | * is, a return status of NFS3_OK and the appropriate bit set in the bit 58 | * mask does not imply that such access will be allowed to the file system 59 | * object in the future, as access rights can be revoked by the server at 60 | * any time. 61 | *
62 | */ 63 | public Nfs3AccessResponse() { 64 | super(Nfs3.VERSION); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3RenameRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsRenameRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *
26 | * Procedure RENAME renames the file identified by name in the
27 | * directory, fileHandle, to toName in the directory,
28 | * toFileHandle. The operation is required to be atomic to the
29 | * client. toFileHandle and fileHandle must reside on
30 | * the same file system and server.
31 | *
42 | * Procedure RENAME renames the file identified by name in the
43 | * directory, fileHandle, to toName in the
44 | * directory, toFileHandle. The operation is required to be
45 | * atomic to the client. toFileHandle and
46 | * fileHandle must reside on the same file system and server.
47 | *
28 | * Procedure MKNOD creates a new special file of the type, type .
29 | * Special files can be device files or named pipes.
30 | *
41 | * Procedure MKNOD creates a new special file of the type, type
42 | * . Special files can be device files or named pipes.
43 | *
type is
57 | * NF3CHR) or a block special file (
58 | * type is NF3BLK),
59 | * rdev[0] is the major number and
60 | * rdev[1] is the minor number.
61 | * @param credential
62 | * The credential used for RPC authentication.
63 | * @throws FileNotFoundException
64 | */
65 | public Nfs3MknodRequest(byte[] fileHandle, String name, NfsType type, NfsSetAttributes attributes, long[] rdev,
66 | Credential credential) throws FileNotFoundException {
67 | super(fileHandle, name, type, attributes, rdev, credential, Nfs3.VERSION);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/NfsPreOpAttributes.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs;
16 |
17 | import com.emc.ecs.nfsclient.rpc.Xdr;
18 |
19 | /**
20 | * These pre-operation attributes are part of weak cache consistency data, as specified by RFC
21 | * 1813 (https://tools.ietf.org/html/rfc1813).
22 | *
23 | * @author seibed
24 | */
25 | public class NfsPreOpAttributes {
26 |
27 | // for now we use long to represent uint64, it should be safe as 'signed
28 | // long' is big enough for file size
29 | /**
30 | * The number of bytes of disk space that the file actually uses (which can
31 | * be smaller than the size because the file may have holes or it may be
32 | * larger due to fragmentation).
33 | */
34 | private final long _size;
35 |
36 | /**
37 | * The time when the file data was last modified.
38 | */
39 | private final NfsTime _mtime;
40 |
41 | /**
42 | * The time when the attributes of the file were last changed. Writing to
43 | * the file changes the ctime in addition to the mtime.
44 | */
45 | private final NfsTime _ctime;
46 |
47 | /**
48 | * Creates a new structure from the Xdr response, as specified by RFC 1813
49 | * (https://tools.ietf.org/html/rfc1813).
50 | *
51 | * @param xdr
52 | */
53 | public NfsPreOpAttributes(Xdr xdr) {
54 | _size = xdr.getLong();
55 | _mtime = new NfsTime();
56 | _ctime = new NfsTime();
57 | _mtime.unmarshalling(xdr);
58 | _ctime.unmarshalling(xdr);
59 | }
60 |
61 | /**
62 | * @return
63 | * The number of bytes of disk space that the file actually uses (which can
64 | * be smaller than the size because the file may have holes or it may be
65 | * larger due to fragmentation).
66 | */
67 | public long getSize() {
68 | return _size;
69 | }
70 |
71 | /**
72 | * @return
73 | * The time when the file data was last modified.
74 | */
75 | public NfsTime getMTime() {
76 | return _mtime;
77 | }
78 |
79 | /**
80 | * @return
81 | * The time when the attributes of the file were last changed. Writing to
82 | * the file changes the ctime in addition to the mtime.
83 | */
84 | public NfsTime getCTime() {
85 | return _ctime;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/NfsWccData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs;
16 |
17 | import com.emc.ecs.nfsclient.rpc.Xdr;
18 |
19 | /**
20 | * Holder for weak cache consistency data, as specified by RFC 1813
21 | * (https://tools.ietf.org/html/rfc1813).
22 | *
23 | * @author seibed
24 | */
25 | public class NfsWccData {
26 |
27 | /**
28 | * Attributes before the operation.
29 | */
30 | private final NfsPreOpAttributes _preOpAttributes;
31 |
32 | /**
33 | * Attributes after the operation.
34 | */
35 | private final NfsGetAttributes _attributes;
36 |
37 | /**
38 | * Creates an empty structure.
39 | */
40 | public NfsWccData() {
41 | this(null);
42 | }
43 |
44 | /**
45 | * Creates a structure populated from an Xdr response, as specified by RFC
46 | * 1813 (https://tools.ietf.org/html/rfc1813).
47 | *
48 | * @param xdr
49 | * the response
50 | */
51 | public NfsWccData(Xdr xdr) {
52 | _preOpAttributes = makePreOpAttributes(xdr);
53 | _attributes = makeAttributes(xdr);
54 | }
55 |
56 | /**
57 | * @return Attributes before the operation.
58 | */
59 | public NfsPreOpAttributes getPreOpAttributes() {
60 | return _preOpAttributes;
61 | }
62 |
63 | /**
64 | * @return Attributes after the operation.
65 | */
66 | public NfsGetAttributes getAttributes() {
67 | return _attributes;
68 | }
69 |
70 | /**
71 | * Extracts the pre-operation attributes.
72 | * @param xdr
73 | * @return The attributes.
74 | */
75 | private static NfsPreOpAttributes makePreOpAttributes(Xdr xdr) {
76 | NfsPreOpAttributes preOpAttributes = null;
77 | if ((xdr != null) && xdr.getBoolean()) {
78 | preOpAttributes = new NfsPreOpAttributes(xdr);
79 | }
80 | return preOpAttributes;
81 | }
82 |
83 | /**
84 | * Extracts the post-operation attributes.
85 | * @param xdr
86 | * @return The attributes.
87 | */
88 | private static NfsGetAttributes makeAttributes(Xdr xdr) {
89 | NfsGetAttributes attributes = null;
90 | if (xdr != null) {
91 | attributes = NfsResponseBase.makeNfsGetAttributes(xdr);
92 | }
93 | return attributes;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/NfsPathconfResponse.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs;
16 |
17 | import com.emc.ecs.nfsclient.rpc.RpcException;
18 | import com.emc.ecs.nfsclient.rpc.Xdr;
19 |
20 | /**
21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813).
22 | *
23 | * 24 | * Procedure PATHCONF retrieves the pathconf information for a file or 25 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, the 26 | * pathconf information will be the same for all files and directories in the 27 | * exported file system in which this file or directory resides. 28 | *
29 | * 30 | * @author seibed 31 | */ 32 | public class NfsPathconfResponse extends NfsResponseBase { 33 | 34 | /** 35 | * The posix attributes. 36 | */ 37 | private NfsPosixAttributes _attributes; 38 | 39 | /** 40 | * Creates the response, as specified by RFC 1813 41 | * (https://tools.ietf.org/html/rfc1813). 42 | * 43 | *44 | * Procedure PATHCONF retrieves the pathconf information for a file or 45 | * directory. If the FSF_HOMOGENEOUS bit is set in FSFINFO3resok.properties, 46 | * the pathconf information will be the same for all files and directories 47 | * in the exported file system in which this file or directory resides. 48 | *
49 | * 50 | * @param nfsVersion 51 | * The NFS version number. This is ignored for now, as only NFSv3 52 | * is supported, but is included to allow future support for 53 | * other versions. 54 | */ 55 | public NfsPathconfResponse(int nfsVersion) { 56 | super(); 57 | } 58 | 59 | /* 60 | * (non-Javadoc) 61 | * 62 | * @see com.emc.ecs.nfsclient.nfs.NfsResponseBase#unmarshalling(com.emc.ecs. 63 | * nfsclient.rpc.Xdr) 64 | */ 65 | public void unmarshalling(Xdr xdr) throws RpcException { 66 | super.unmarshalling(xdr); 67 | unmarshallingAttributes(xdr); 68 | if (stateIsOk()) { 69 | _attributes = new NfsPosixAttributes(); 70 | _attributes.unmarshalling(xdr); 71 | } 72 | } 73 | 74 | /** 75 | * @return The posix attributes. 76 | */ 77 | public NfsPosixAttributes getPosixAttributes() { 78 | return _attributes; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsLinkResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | link * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *
24 | * Procedure LINK creates a hard link from fileHandle to
25 | * name, in the directory, parentDirectoryFileHandle.
26 | * fileHandle and parentDirectoryFileHandle must
27 | * reside on the same file system and server.
28 | *
parentDirectoryFileHandle.
37 | */
38 | private NfsWccData _directoryWccData = new NfsWccData();
39 |
40 | /**
41 | * Creates the response, as specified by RFC 1813
42 | * (https://tools.ietf.org/html/rfc1813).
43 | *
44 | *
45 | * Procedure LINK creates a hard link from fileHandle to
46 | * name, in the directory,
47 | * parentDirectoryFileHandle. fileHandle and
48 | * parentDirectoryFileHandle must reside on the same file
49 | * system and server.
50 | *
parentDirectoryFileHandle.
76 | */
77 | public NfsWccData getDirectoryWccData() {
78 | return _directoryWccData;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/3rd-party-licenses/LICENSE-slf4j-api.txt:
--------------------------------------------------------------------------------
1 | Library: slf4j-api
2 | Source code: http://repo2.maven.org/maven2/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5-sources.jar
3 | Copyright 2004-2013 QOS.ch
4 | Full copyright text:
5 | -----------------------------------------------------------------------------------------------------------------------
6 | Copyright (c) 2004-2013 QOS.ch
7 | All rights reserved.
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining
10 | a copy of this software and associated documentation files (the
11 | "Software"), to deal in the Software without restriction, including
12 | without limitation the rights to use, copy, modify, merge, publish,
13 | distribute, sublicense, and/or sell copies of the Software, and to
14 | permit persons to whom the Software is furnished to do so, subject to
15 | the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be
18 | included in all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 | -----------------------------------------------------------------------------------------------------------------------
28 | License: MIT
29 | Full License Text:
30 | -----------------------------------------------------------------------------------------------------------------------
31 | Copyright (c) 2004-2013 QOS.ch
32 | All rights reserved.
33 |
34 | Permission is hereby granted, free of charge, to any person obtaining
35 | a copy of this software and associated documentation files (the
36 | "Software"), to deal in the Software without restriction, including
37 | without limitation the rights to use, copy, modify, merge, publish,
38 | distribute, sublicense, and/or sell copies of the Software, and to
39 | permit persons to whom the Software is furnished to do so, subject to
40 | the following conditions:
41 |
42 | The above copyright notice and this permission notice shall be
43 | included in all copies or substantial portions of the Software.
44 |
45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
49 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
50 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
51 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/src/test/java/com/emc/ecs/nfsclient/rpc/Test_Xdr.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.rpc;
16 |
17 | import java.nio.ByteBuffer;
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import org.junit.Assert;
22 | import org.junit.Test;
23 |
24 | /**
25 | * @author seibed
26 | */
27 | public class Test_Xdr extends Assert {
28 |
29 | @Test
30 | public void testSkip() {
31 | Xdr xdr = new Xdr(200);
32 | assertEquals(0, xdr.getOffset());
33 | assertNull(xdr.getTerminalPadding());
34 |
35 | xdr.skip(0);
36 | assertEquals(0, xdr.getOffset());
37 | assertNull(xdr.getTerminalPadding());
38 | int expectedOffset = 0;
39 |
40 | for (int skip = 1; skip <= 4; ++skip) {
41 | xdr.skip(skip);
42 | expectedOffset += 4;
43 | assertEquals(expectedOffset, xdr.getOffset());
44 | assertNull(xdr.getTerminalPadding());
45 | }
46 |
47 | for (int skip = 5; skip <= 8; ++skip) {
48 | xdr.skip(skip);
49 | expectedOffset += 8;
50 | assertEquals(expectedOffset, xdr.getOffset());
51 | assertNull(xdr.getTerminalPadding());
52 | }
53 | }
54 |
55 | @Test
56 | public void testPayloadPadding() {
57 | Xdr xdr = new Xdr(200);
58 | assertEquals(0, xdr.getOffset());
59 | assertNull(xdr.getTerminalPadding());
60 |
61 | for (int payloadNumber = 1; payloadNumber < 4; ++payloadNumber) {
62 | xdr.putPayloads(getPayload(payloadNumber), 1);
63 | assertEquals(4 - payloadNumber, xdr.getTerminalPadding().limit());
64 | }
65 |
66 | xdr.putPayloads(getPayload(4), 1);
67 | assertNull(xdr.getTerminalPadding());
68 |
69 | xdr.putPayloads(getPayload(5), 1);
70 | assertNotNull(xdr.getTerminalPadding());
71 | xdr.getPayloads();
72 | assertNull(xdr.getTerminalPadding());
73 | }
74 |
75 | /**
76 | * @param payloadNumber
77 | * @return a 1-byte payload with the payload number
78 | */
79 | private List29 | * Procedure MNT maps a pathname on the server to a file handle. 30 | *
31 | * 32 | * @author seibed 33 | */ 34 | public class MountRequest extends RpcRequest { 35 | 36 | /** 37 | * Procedure number for RPC calls. 38 | */ 39 | private final static int MOUNTPROC_MNT = 1; 40 | 41 | /** 42 | * An ASCII string that describes a directory on the server. 43 | */ 44 | private final String _exportPointPath; 45 | 46 | /** 47 | * Creates the request, as specified by RFC 1813 48 | * (https://tools.ietf.org/html/rfc1813). 49 | * 50 | *51 | * Procedure MNT maps a pathname on the server to a file handle. 52 | *
53 | * 54 | * @param nfsVersion 55 | * The NFS version number. 56 | * @param exportPointPath 57 | * An ASCII string that describes a directory on the server. 58 | * @param credential 59 | * The credential used for RPC authentication. 60 | */ 61 | public MountRequest(int nfsVersion, String exportPointPath, Credential credential) { 62 | super(Nfs.MOUNTPROG, nfsVersion, MOUNTPROC_MNT, credential); 63 | _exportPointPath = exportPointPath; 64 | } 65 | 66 | /* 67 | * (non-Javadoc) 68 | * 69 | * @see 70 | * com.emc.ecs.nfsclient.rpc.RpcRequest#marshalling(com.emc.ecs.nfsclient. 71 | * rpc.Xdr) 72 | */ 73 | public void marshalling(Xdr x) { 74 | super.marshalling(x); 75 | x.putString(_exportPointPath); 76 | } 77 | 78 | /* 79 | * (non-Javadoc) 80 | * 81 | * @see com.emc.ecs.nfsclient.rpc.RpcRequest#getErrorMessage() 82 | */ 83 | public String getErrorMessage() { 84 | throw new NotImplementedException("This method should never be used during mount calls."); 85 | } 86 | 87 | @Override 88 | public String toString() { 89 | return startToString("MountRequest").toString(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3ReadRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsReadRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure READ reads data from a file. 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class Nfs3ReadRequest extends NfsReadRequest { 32 | 33 | /** 34 | * Creates the request, as specified by RFC 1813 35 | * (https://tools.ietf.org/html/rfc1813). 36 | * 37 | *38 | * Procedure READ reads data from a file. 39 | *
40 | * 41 | * @param fileHandle 42 | * The file handle of the file from which data is to be read. 43 | * This must identify a file system object of type, NF3REG. 44 | * @param offset 45 | * The position within the file at which the read is to begin. An 46 | *offset of 0 means to read data starting at the
47 | * beginning of the file. If offset is greater than
48 | * or equal to the size of the file, the status, NFS3_OK, is
49 | * returned with size set to 0 and eof
50 | * set to true, subject to access permissions
51 | * checking.
52 | * @param size
53 | * The number of bytes of data that are to be read. If
54 | * size is 0, the READ will succeed and return 0
55 | * bytes of data, subject to access permissions checking.
56 | * size must be less than or equal to the value of
57 | * the rtmax field in the FSINFO reply structure for
58 | * the file system that contains file. If greater, the server may
59 | * return only rtmax bytes, resulting in a short
60 | * read.
61 | * @param credential
62 | * The credential used for RPC authentication.
63 | * @throws FileNotFoundException
64 | */
65 | public Nfs3ReadRequest(byte[] fileHandle, long offset, int size, Credential credential)
66 | throws FileNotFoundException {
67 | super(fileHandle, offset, size, credential, Nfs3.VERSION);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/NfsRemoveRequest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs;
16 |
17 | import java.io.FileNotFoundException;
18 |
19 | import com.emc.ecs.nfsclient.rpc.Credential;
20 | import com.emc.ecs.nfsclient.rpc.Xdr;
21 |
22 | /**
23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813).
24 | *
25 | * 26 | * Procedure REMOVE removes (deletes) an entry from a directory. If the entry in 27 | * the directory was the last reference to the corresponding file system object, 28 | * the object may be destroyed. 29 | *
30 | * 31 | * @author seibed 32 | */ 33 | public class NfsRemoveRequest extends NfsRequestBase { 34 | 35 | /** 36 | * The name of the entry to be removed. 37 | */ 38 | private final String _name; 39 | 40 | /** 41 | * Creates the request, as specified by RFC 1813 42 | * (https://tools.ietf.org/html/rfc1813). 43 | * 44 | *45 | * Procedure REMOVE removes (deletes) an entry from a directory. If the 46 | * entry in the directory was the last reference to the corresponding file 47 | * system object, the object may be destroyed. 48 | *
49 | * 50 | * @param fileHandle 51 | * The file handle for the directory from which the entry is to 52 | * be removed. 53 | * @param name 54 | * The name of the entry to be removed. 55 | * @param credential 56 | * The credential used for RPC authentication. 57 | * @param nfsVersion 58 | * The NFS version number 59 | * @throws FileNotFoundException 60 | */ 61 | public NfsRemoveRequest(byte[] fileHandle, String name, Credential credential, int nfsVersion) 62 | throws FileNotFoundException { 63 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_REMOVE, credential, fileHandle); 64 | _name = trimFileName(name); 65 | } 66 | 67 | /* 68 | * (non-Javadoc) 69 | * 70 | * @see com.emc.ecs.nfsclient.nfs.NfsRequestBase#marshalling(com.emc.ecs. 71 | * nfsclient.rpc.Xdr) 72 | */ 73 | public void marshalling(Xdr xdr) { 74 | super.marshalling(xdr); 75 | xdr.putString(_name); 76 | } 77 | 78 | /* 79 | * (non-Javadoc) 80 | * 81 | * @see java.lang.Object#toString() 82 | */ 83 | public String toString() { 84 | return startToString("NfsRemoveFileRequest").append(" name").append(_name).toString(); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsRmdirRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.rpc.Credential; 20 | import com.emc.ecs.nfsclient.rpc.Xdr; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 27 | * directory entry of the subdirectory is the last reference to the 28 | * subdirectory, the subdirectory may be destroyed. 29 | *
30 | * 31 | * @author seibed 32 | */ 33 | public class NfsRmdirRequest extends NfsRequestBase { 34 | 35 | /** 36 | * The name of the subdirectory to be removed. 37 | */ 38 | private final String _name; 39 | 40 | /** 41 | * Creates the request, as specified by RFC 1813 42 | * (https://tools.ietf.org/html/rfc1813). 43 | * 44 | *45 | * Procedure RMDIR removes (deletes) a subdirectory from a directory. If the 46 | * directory entry of the subdirectory is the last reference to the 47 | * subdirectory, the subdirectory may be destroyed. 48 | *
49 | * 50 | * @param fileHandle 51 | * The file handle for the directory from which the subdirectory 52 | * is to be removed. 53 | * @param name 54 | * The name of the subdirectory to be removed. 55 | * @param credential 56 | * The credential used for RPC authentication. 57 | * @param nfsVersion 58 | * The NFS version number 59 | * @throws FileNotFoundException 60 | */ 61 | public NfsRmdirRequest(byte[] fileHandle, String name, Credential credential, int nfsVersion) 62 | throws FileNotFoundException { 63 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_RMDIR, credential, fileHandle); 64 | _name = trimFileName(name); 65 | } 66 | 67 | /* 68 | * (non-Javadoc) 69 | * 70 | * @see com.emc.ecs.nfsclient.nfs.NfsRequestBase#marshalling(com.emc.ecs. 71 | * nfsclient.rpc.Xdr) 72 | */ 73 | public void marshalling(Xdr xdr) { 74 | super.marshalling(xdr); 75 | xdr.putString(_name); 76 | } 77 | 78 | /* 79 | * (non-Javadoc) 80 | * 81 | * @see java.lang.Object#toString() 82 | */ 83 | public String toString() { 84 | return startToString("NfsRmdirRequest").append(" name").append(_name).toString(); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3ReadlinkResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import com.emc.ecs.nfsclient.nfs.NfsReadlinkResponse; 18 | 19 | /** 20 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 21 | * 22 | *23 | * This method reads the data associated with a symbolic link. The data is an 24 | * ASCII string that is opaque to the server. That is, whether created by the 25 | * NFS version 3 protocol software from a client or created locally on the 26 | * server, the data in a symbolic link is not interpreted when created, but is 27 | * simply stored. 28 | *
29 | * 30 | *31 | * A symbolic link is nominally a pointer to another file. The data is not 32 | * necessarily interpreted by the server, just stored in the file. It is 33 | * possible for a client implementation to store a path name that is not 34 | * meaningful to the server operating system in a symbolic link. A READLINK 35 | * operation returns the data to the client for interpretation. If different 36 | * implementations want to share access to symbolic links, then they must agree 37 | * on the interpretation of the data in the symbolic link. 38 | *
39 | * 40 | * @author seibed 41 | */ 42 | public class Nfs3ReadlinkResponse extends NfsReadlinkResponse { 43 | 44 | /** 45 | * Creates the response, as specified by RFC 1813 46 | * (https://tools.ietf.org/html/rfc1813). 47 | * 48 | *49 | * This method reads the data associated with a symbolic link. The data is 50 | * an ASCII string that is opaque to the server. That is, whether created by 51 | * the NFS version 3 protocol software from a client or created locally on 52 | * the server, the data in a symbolic link is not interpreted when created, 53 | * but is simply stored. 54 | *
55 | * 56 | *57 | * A symbolic link is nominally a pointer to another file. The data is not 58 | * necessarily interpreted by the server, just stored in the file. It is 59 | * possible for a client implementation to store a path name that is not 60 | * meaningful to the server operating system in a symbolic link. A READLINK 61 | * operation returns the data to the client for interpretation. If different 62 | * implementations want to share access to symbolic links, then they must 63 | * agree on the interpretation of the data in the symbolic link. 64 | *
65 | */ 66 | public Nfs3ReadlinkResponse() { 67 | super(Nfs3.VERSION); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/io/Nfs3File.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.io; 16 | 17 | import java.io.IOException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.nfs3.Nfs3; 20 | 21 | /** 22 | * Nfs3 specialization of NfsFile. Almost all functionality is implemented in 23 | * the parent class. 24 | * 25 | * @author seibed 26 | */ 27 | public class Nfs3File extends NfsFileBase29 | * Procedure UMNT removes the mount list entry for the directory that was 30 | * previously the subject of a MNT call from this client. 31 | *
32 | * 33 | * @author seibed 34 | */ 35 | public class UnmountRequest extends RpcRequest { 36 | 37 | /** 38 | * Procedure number for RPC calls. 39 | */ 40 | private final static int MOUNTPROC_UMNT = 3; 41 | 42 | /** 43 | * An ASCII string that describes a directory on the server. 44 | */ 45 | private final String _exportPointPath; 46 | 47 | /** 48 | * Creates the request, as specified by RFC 1813 49 | * (https://tools.ietf.org/html/rfc1813). 50 | * 51 | *52 | * Procedure UMNT removes the mount list entry for the directory that was 53 | * previously the subject of a MNT call from this client. 54 | *
55 | * 56 | * @param nfsVersion 57 | * The NFS version number. 58 | * @param exportPointPath 59 | * An ASCII string that describes a directory on the server. 60 | * @param credential 61 | * The credential used for RPC authentication. 62 | */ 63 | public UnmountRequest(int nfsVersion, String exportPointPath, Credential credential) { 64 | super(Nfs.MOUNTPROG, nfsVersion, MOUNTPROC_UMNT, credential); 65 | _exportPointPath = exportPointPath; 66 | } 67 | 68 | /* 69 | * (non-Javadoc) 70 | * 71 | * @see 72 | * com.emc.ecs.nfsclient.rpc.RpcRequest#marshalling(com.emc.ecs.nfsclient. 73 | * rpc.Xdr) 74 | */ 75 | public void marshalling(Xdr x) { 76 | super.marshalling(x); 77 | x.putString(_exportPointPath); 78 | } 79 | 80 | /* 81 | * (non-Javadoc) 82 | * 83 | * @see com.emc.ecs.nfsclient.rpc.RpcRequest#getErrorMessage() 84 | */ 85 | public String getErrorMessage() { 86 | throw new NotImplementedException("This method should never be used during unmount calls."); 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return startToString("UnmountRequest").toString(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/nfs3/Nfs3ReaddirRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs.nfs3; 16 | 17 | import java.io.FileNotFoundException; 18 | 19 | import com.emc.ecs.nfsclient.nfs.NfsReaddirRequest; 20 | import com.emc.ecs.nfsclient.rpc.Credential; 21 | 22 | /** 23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 24 | * 25 | *26 | * Procedure READDIR retrieves a variable number of entries, in sequence, from a 27 | * directory and returns the name and file identifier for each, with information 28 | * to allow the client to request additional directory entries in a subsequent 29 | * READDIR request. 30 | *
31 | * 32 | * @author seibed 33 | */ 34 | public class Nfs3ReaddirRequest extends NfsReaddirRequest { 35 | 36 | /** 37 | * Creates the request, as specified by RFC 1813 38 | * (https://tools.ietf.org/html/rfc1813). 39 | * 40 | *41 | * Procedure READDIR retrieves a variable number of entries, in sequence, 42 | * from a directory and returns the name and file identifier for each, with 43 | * information to allow the client to request additional directory entries 44 | * in a subsequent READDIR request. 45 | *
46 | * 47 | * @param fileHandle 48 | * The file handle for the directory to be read. 49 | * @param cookie 50 | * This should be set to 0 in the first request to read the 51 | * directory. On subsequent requests, it should be a 52 | *cookie as returned by the server.
53 | * @param cookieverf
54 | * This should be set to 0 in the first request to read the
55 | * directory. On subsequent requests, it should be a
56 | * cookieverf as returned by the server. The
57 | * cookieverf must match that returned by the
58 | * READDIR in which the cookie was acquired.
59 | * @param count
60 | * The maximum size of the READDIR3resok structure, in bytes. The
61 | * size must include all XDR overhead. The server is free to
62 | * return less than count bytes of data.
63 | * @param credential
64 | * The credential used for RPC authentication.
65 | * @throws FileNotFoundException
66 | */
67 | public Nfs3ReaddirRequest(byte[] fileHandle, long cookie, long cookieverf, int count, Credential credential)
68 | throws FileNotFoundException {
69 | super(fileHandle, cookie, cookieverf, count, credential, Nfs3.VERSION);
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/com/emc/ecs/nfsclient/nfs/NfsMkdirRequest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License").
5 | * You may not use this file except in compliance with the License.
6 | * A copy of the License is located at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0.txt
9 | *
10 | * or in the "license" file accompanying this file. This file is distributed
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing
13 | * permissions and limitations under the License.
14 | */
15 | package com.emc.ecs.nfsclient.nfs;
16 |
17 | import java.io.FileNotFoundException;
18 |
19 | import com.emc.ecs.nfsclient.rpc.Credential;
20 | import com.emc.ecs.nfsclient.rpc.Xdr;
21 |
22 | /**
23 | * The request, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813).
24 | *
25 | * 26 | * Procedure MKDIR creates a new subdirectory. 27 | *
28 | * 29 | * @author seibed 30 | */ 31 | public class NfsMkdirRequest extends NfsRequestBase { 32 | 33 | /** 34 | * The name that is to be associated with the created subdirectory. 35 | */ 36 | private final String _name; 37 | 38 | /** 39 | * The initial attributes for the subdirectory. 40 | */ 41 | private final NfsSetAttributes _attributes; 42 | 43 | /** 44 | * Creates the request, as specified by RFC 1813 45 | * (https://tools.ietf.org/html/rfc1813). 46 | * 47 | *48 | * Procedure MKDIR creates a new subdirectory. 49 | *
50 | * 51 | * @param fileHandle 52 | * The file handle for the directory in which the subdirectory is 53 | * to be created. 54 | * @param name 55 | * The name that is to be associated with the created 56 | * subdirectory. 57 | * @param attributes 58 | * The initial attributes for the subdirectory. 59 | * @param credential 60 | * The credential used for RPC authentication. 61 | * @param nfsVersion 62 | * The NFS version number 63 | * @throws FileNotFoundException 64 | */ 65 | public NfsMkdirRequest(byte[] fileHandle, String name, NfsSetAttributes attributes, Credential credential, 66 | int nfsVersion) throws FileNotFoundException { 67 | super(Nfs.RPC_PROGRAM, nfsVersion, Nfs.NFSPROC3_MKDIR, credential, fileHandle); 68 | _name = trimFileName(name); 69 | _attributes = attributes; 70 | } 71 | 72 | /* 73 | * (non-Javadoc) 74 | * 75 | * @see com.emc.ecs.nfsclient.nfs.NfsRequestBase#marshalling(com.emc.ecs. 76 | * nfsclient.rpc.Xdr) 77 | */ 78 | public void marshalling(Xdr xdr) { 79 | super.marshalling(xdr); 80 | xdr.putString(_name); 81 | _attributes.marshalling(xdr); 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * 87 | * @see java.lang.Object#toString() 88 | */ 89 | public String toString() { 90 | return startToString("NfsMkdirRequest").append(" name:").append(_name).append(" attributes: ") 91 | .append(_attributes.toString()).toString(); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/network/RPCRecordDecoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.network; 16 | 17 | import org.jboss.netty.buffer.ChannelBuffer; 18 | import org.jboss.netty.channel.Channel; 19 | import org.jboss.netty.channel.ChannelHandlerContext; 20 | import org.jboss.netty.handler.codec.frame.FrameDecoder; 21 | 22 | /** 23 | * To receive the entire response. We do not actually decode the rpc packet here. 24 | * Just get the size from the packet and then put them in internal buffer until all data arrive. 25 | * 26 | * @author seibed 27 | */ 28 | public class RPCRecordDecoder extends FrameDecoder { 29 | 30 | /** 31 | * Holds the calculated record length for each channel until the Channel is ready for buffering. 32 | * Reset to 0 after that for the next channel. 33 | */ 34 | private int _recordLength = 0; 35 | 36 | /* (non-Javadoc) 37 | * @see org.jboss.netty.handler.codec.frame.FrameDecoder#decode(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.Channel, org.jboss.netty.buffer.ChannelBuffer) 38 | */ 39 | protected Object decode(ChannelHandlerContext channelHandlerContext, Channel channel, ChannelBuffer channelBuffer) throws Exception { 40 | // Wait until the length prefix is available. 41 | if (channelBuffer.readableBytes() < 4) { 42 | // If null is returned, it means there is not enough data yet. 43 | // FrameDecoder will call again when there is a sufficient amount of data available. 44 | return null; 45 | } 46 | 47 | //marking the current reading position 48 | channelBuffer.markReaderIndex(); 49 | 50 | //get the fragment size and wait until the entire fragment is available. 51 | long fragSize = channelBuffer.readUnsignedInt(); 52 | boolean lastFragment = RecordMarkingUtil.isLastFragment(fragSize); 53 | fragSize = RecordMarkingUtil.maskFragmentSize(fragSize); 54 | if (channelBuffer.readableBytes() < fragSize) { 55 | channelBuffer.resetReaderIndex(); 56 | return null; 57 | } 58 | 59 | //seek to the beginning of the next fragment 60 | channelBuffer.skipBytes((int) fragSize); 61 | 62 | _recordLength += 4 + (int) fragSize; 63 | 64 | //check the last fragment 65 | if (!lastFragment) { 66 | //not the last fragment, the data is put in an internally maintained cumulative buffer 67 | return null; 68 | } 69 | 70 | byte[] rpcResponse = new byte[_recordLength]; 71 | channelBuffer.readerIndex(channelBuffer.readerIndex() - _recordLength); 72 | channelBuffer.readBytes(rpcResponse, 0, _recordLength); 73 | 74 | _recordLength = 0; 75 | return rpcResponse; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/emc/ecs/nfsclient/nfs/NfsRenameResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016-2018 Dell Inc. or its subsidiaries. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0.txt 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.emc.ecs.nfsclient.nfs; 16 | 17 | import com.emc.ecs.nfsclient.rpc.RpcException; 18 | import com.emc.ecs.nfsclient.rpc.Xdr; 19 | 20 | /** 21 | * The response, as specified by RFC 1813 (https://tools.ietf.org/html/rfc1813). 22 | * 23 | *
24 | * Procedure RENAME renames the file identified by name in the
25 | * directory, fileHandle, to toName in the directory,
26 | * toFileHandle. The operation is required to be atomic to the
27 | * client. toFileHandle and fileHandle must reside on
28 | * the same file system and server.
29 | *
50 | * Procedure RENAME renames the file identified by name in the
51 | * directory, fileHandle, to toName in the
52 | * directory, toFileHandle. The operation is required to be
53 | * atomic to the client. toFileHandle and
54 | * fileHandle must reside on the same file system and server.
55 | *
26 | * Procedure READDIRPLUS retrieves a variable number of entries from a file 27 | * system directory and returns complete information about each along with 28 | * information to allow the client to request additional directory entries in a 29 | * subsequent READDIRPLUS. READDIRPLUS differs from READDIR only in the amount 30 | * of information returned for each entry. In READDIR, each entry returns the 31 | * filename and the fileid. In READDIRPLUS, each entry returns the name, the 32 | * fileid, attributes (including the fileid), and file handle. 33 | *
34 | * 35 | * @author seibed 36 | */ 37 | public class Nfs3ReaddirplusResponse extends NfsReaddirplusResponse { 38 | 39 | /** 40 | * Creates the response, as specified by RFC 1813 41 | * (https://tools.ietf.org/html/rfc1813). 42 | * 43 | *44 | * Procedure READDIRPLUS retrieves a variable number of entries from a file 45 | * system directory and returns complete information about each along with 46 | * information to allow the client to request additional directory entries 47 | * in a subsequent READDIRPLUS. READDIRPLUS differs from READDIR only in the 48 | * amount of information returned for each entry. In READDIR, each entry 49 | * returns the filename and the fileid. In READDIRPLUS, each entry returns 50 | * the name, the fileid, attributes (including the fileid), and file handle. 51 | *
52 | */ 53 | public Nfs3ReaddirplusResponse() { 54 | super(Nfs3.VERSION); 55 | } 56 | 57 | /** 58 | * Creates the response, as specified by RFC 1813 59 | * (https://tools.ietf.org/html/rfc1813). 60 | * 61 | *62 | * Procedure READDIRPLUS retrieves a variable number of entries from a file 63 | * system directory and returns complete information about each along with 64 | * information to allow the client to request additional directory entries 65 | * in a subsequent READDIRPLUS. READDIRPLUS differs from READDIR only in the 66 | * amount of information returned for each entry. In READDIR, each entry 67 | * returns the filename and the fileid. In READDIRPLUS, each entry returns 68 | * the name, the fileid, attributes (including the fileid), and file handle. 69 | *
70 | * 71 | * @param entries 72 | * A list in which to store the entries. 73 | */ 74 | public Nfs3ReaddirplusResponse(List