aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-12-04 01:10:25 -0800
committerChris Lu <chris.lu@gmail.com>2018-12-04 01:10:25 -0800
commit5f8c8caec6a66dd47c79b5acc2a31eb7e9b3fd3c (patch)
tree29d50ccbdee7d0e7739b5f63f99bbe3a534b505d
parentd5197d6a50b36114d1e96a7846c4550eee947095 (diff)
downloadseaweedfs-5f8c8caec6a66dd47c79b5acc2a31eb7e9b3fd3c.tar.xz
seaweedfs-5f8c8caec6a66dd47c79b5acc2a31eb7e9b3fd3c.zip
HCFS: chmod
-rw-r--r--other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java19
-rw-r--r--other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java28
2 files changed, 46 insertions, 1 deletions
diff --git a/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java b/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java
index 4181a5119..dce642d09 100644
--- a/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java
+++ b/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java
@@ -233,7 +233,26 @@ public class SeaweedFileSystem extends org.apache.hadoop.fs.FileSystem {
path = qualify(path);
seaweedFileSystemStore.setOwner(path, owner, group);
+ }
+
+
+ /**
+ * Set permission of a path.
+ *
+ * @param path The path
+ * @param permission Access permission
+ */
+ @Override
+ public void setPermission(Path path, final FsPermission permission) throws IOException {
+ LOG.debug("setPermission path: {}", path);
+
+ if (permission == null) {
+ throw new IllegalArgumentException("The permission can't be null");
+ }
+
+ path = qualify(path);
+ seaweedFileSystemStore.setPermission(path, permission);
}
Path qualify(Path path) {
diff --git a/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java b/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java
index f34de3749..a36e9fc8e 100644
--- a/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java
+++ b/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java
@@ -297,7 +297,33 @@ public class SeaweedFileSystemStore {
entryBuilder.setAttributes(attributesBuilder);
- LOG.debug("setOwner path:{} entry:{}", path, entryBuilder, owner, group);
+ LOG.debug("setOwner path:{} entry:{}", path, entryBuilder);
+
+ filerGrpcClient.getBlockingStub().updateEntry(FilerProto.UpdateEntryRequest.newBuilder()
+ .setDirectory(getParentDirectory(path))
+ .setEntry(entryBuilder)
+ .build());
+
+ }
+
+ public void setPermission(Path path, FsPermission permission) {
+
+ LOG.debug("setPermission path:{} permission:{}", path, permission);
+
+ FilerProto.Entry entry = lookupEntry(path);
+ if (entry == null) {
+ LOG.debug("setPermission path:{} entry:{}", path, entry);
+ return;
+ }
+
+ FilerProto.Entry.Builder entryBuilder = entry.toBuilder();
+ FilerProto.FuseAttributes.Builder attributesBuilder = entry.getAttributes().toBuilder();
+
+ attributesBuilder.setFileMode(permissionToMode(permission, entry.getIsDirectory()));
+
+ entryBuilder.setAttributes(attributesBuilder);
+
+ LOG.debug("setPermission path:{} entry:{}", path, entryBuilder);
filerGrpcClient.getBlockingStub().updateEntry(FilerProto.UpdateEntryRequest.newBuilder()
.setDirectory(getParentDirectory(path))