Author: wang
Date: Sat May 31 00:12:02 2014
New Revision: 1598788
URL: http://svn.apache.org/r1598788
Log:
HDFS-6375. Listing extended attributes with the search permission. Contributed
by Charles Lamb.
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java?rev=1598788&r1=1598787&r2=1598788&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java
Sat May 31 00:12:02 2014
@@ -1169,6 +1169,30 @@ public abstract class AbstractFileSystem
}
/**
+ * Get all of the xattr names for a file or directory.
+ * Only the xattr names for which the logged-in user has permissions to view
+ * are returned.
+ * <p/>
+ * A regular user can only get xattr names for the "user" namespace.
+ * The super user can only get xattr names for the "user" and "trusted"
+ * namespaces.
+ * The xattr names in the "security" and "system" namespaces are only
+ * used/exposed internally by/to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public List<String> listXAttrs(Path path)
+ throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support listXAttrs");
+ }
+
+ /**
* Remove an xattr of a file or directory.
* The name must be prefixed with user/trusted/security/system and
* followed by ".". For example, "user.attr".
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java?rev=1598788&r1=1598787&r2=1598788&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
Sat May 31 00:12:02 2014
@@ -2403,8 +2403,8 @@ public abstract class FileSystem extends
* <p/>
* The access permissions of an xattr in the "user" namespace are
* defined by the file and directory permission bits.
- * An xattr can only be set when the logged-in user has the correct
permissions.
- * If the xattr exists, it will be replaced.
+ * An xattr can only be set if the logged-in user has the correct
permissions.
+ * If the xattr exists, it is replaced.
* <p/>
* @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
* http://en.wikipedia.org/wiki/Extended_file_attributes</a>
@@ -2422,7 +2422,7 @@ public abstract class FileSystem extends
}
/**
- * Get an xattr for a file or directory.
+ * Get an xattr name and value for a file or directory.
* The name must be prefixed with user/trusted/security/system and
* followed by ".". For example, "user.attr".
* <p/>
@@ -2432,7 +2432,8 @@ public abstract class FileSystem extends
* The xattrs of the "security" and "system" namespaces are only
used/exposed
* internally by/to the FS impl.
* <p/>
- * An xattr will only be returned when the logged-in user has the correct
permissions.
+ * An xattr will only be returned if the logged-in user has the
+ * correct permissions.
* <p/>
* @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
* http://en.wikipedia.org/wiki/Extended_file_attributes</a>
@@ -2448,13 +2449,13 @@ public abstract class FileSystem extends
}
/**
- * Get all of the xattrs for a file or directory.
- * Only those xattrs for which the logged-in user has permissions to view
+ * Get all of the xattr name/value pairs for a file or directory.
+ * Only those xattrs which the logged-in user has permissions to view
* are returned.
* <p/>
* A regular user can only get xattrs for the "user" namespace.
* The super user can only get xattrs for "user" and "trusted" namespaces.
- * The xattr of "security" and "system" namespaces are only used/exposed
+ * The xattrs of the "security" and "system" namespaces are only used/exposed
* internally by/to the FS impl.
* <p/>
* @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
@@ -2470,13 +2471,13 @@ public abstract class FileSystem extends
}
/**
- * Get all of the xattrs for a file or directory.
- * Only those xattrs for which the logged-in user has permissions to view
+ * Get all of the xattrs name/value pairs for a file or directory.
+ * Only those xattrs which the logged-in user has permissions to view
* are returned.
* <p/>
* A regular user can only get xattrs for the "user" namespace.
* The super user can only get xattrs for "user" and "trusted" namespaces.
- * The xattr of "security" and "system" namespaces are only used/exposed
+ * The xattrs of the "security" and "system" namespaces are only used/exposed
* internally by/to the FS impl.
* <p/>
* @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
@@ -2494,6 +2495,29 @@ public abstract class FileSystem extends
}
/**
+ * Get all of the xattr names for a file or directory.
+ * Only those xattr names which the logged-in user has permissions to view
+ * are returned.
+ * <p/>
+ * A regular user can only get xattr names for the "user" namespace.
+ * The super user can only get xattr names for "user" and "trusted"
+ * namespaces.
+ * The xattrs of the "security" and "system" namespaces are only
+ * used/exposed internally by/to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public List<String> listXAttrs(Path path) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support listXAttrs");
+ }
+
+ /**
* Remove an xattr of a file or directory.
* The name must be prefixed with user/trusted/security/system and
* followed by ".". For example, "user.attr".
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java?rev=1598788&r1=1598787&r2=1598788&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java
Sat May 31 00:12:02 2014
@@ -573,6 +573,11 @@ public class FilterFileSystem extends Fi
}
@Override
+ public List<String> listXAttrs(Path path) throws IOException {
+ return fs.listXAttrs(path);
+ }
+
+ @Override
public void removeXAttr(Path path, String name) throws IOException {
fs.removeXAttr(path, name);
}
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java?rev=1598788&r1=1598787&r2=1598788&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java
Sat May 31 00:12:02 2014
@@ -347,6 +347,11 @@ public abstract class FilterFs extends A
}
@Override
+ public List<String> listXAttrs(Path path) throws IOException {
+ return myFs.listXAttrs(path);
+ }
+
+ @Override
public void removeXAttr(Path path, String name) throws IOException {
myFs.removeXAttr(path, name);
}
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java?rev=1598788&r1=1598787&r2=1598788&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
Sat May 31 00:12:02 2014
@@ -338,6 +338,11 @@ class ChRootedFileSystem extends FilterF
}
@Override
+ public List<String> listXAttrs(Path path) throws IOException {
+ return super.listXAttrs(fullPath(path));
+ }
+
+ @Override
public void removeXAttr(Path path, String name) throws IOException {
super.removeXAttr(fullPath(path), name);
}
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java?rev=1598788&r1=1598787&r2=1598788&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
Sat May 31 00:12:02 2014
@@ -552,6 +552,13 @@ public class ViewFileSystem extends File
}
@Override
+ public List<String> listXAttrs(Path path) throws IOException {
+ InodeTree.ResolveResult<FileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ return res.targetFileSystem.listXAttrs(res.remainingPath);
+ }
+
+ @Override
public void removeXAttr(Path path, String name) throws IOException {
InodeTree.ResolveResult<FileSystem> res = fsState.resolve(getUriPath(path),
true);
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java?rev=1598788&r1=1598787&r2=1598788&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
Sat May 31 00:12:02 2014
@@ -196,6 +196,8 @@ public class TestHarFileSystem {
public Map<String, byte[]> getXAttrs(Path path, List<String> names)
throws IOException;
+ public List<String> listXAttrs(Path path) throws IOException;
+
public void removeXAttr(Path path, String name) throws IOException;
public AclStatus getAclStatus(Path path) throws IOException;