diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java index 972a410b53d..a909edfd927 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java @@ -184,7 +184,18 @@ public class FsPermission implements Writable { return str; } - /** Apply a umask to this permission and return a new one */ + /** + * Apply a umask to this permission and return a new one. + * + * The umask is used by create, mkdir, and other Hadoop filesystem operations. + * The mode argument for these operations is modified by removing the bits + * which are set in the umask. Thus, the umask limits the permissions which + * newly created files and directories get. + * + * @param umask The umask to use + * + * @return The effective permission + */ public FsPermission applyUMask(FsPermission umask) { return new FsPermission(useraction.and(umask.useraction.not()), groupaction.and(umask.groupaction.not()), diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e614430aeb6..c62044b39ed 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -114,6 +114,9 @@ Release 2.0.3-alpha - Unreleased HDFS-4048. Use ERROR instead of INFO for volume failure logs. (Stephen Chu via eli) + HDFS-1322. Document umask in DistributedFileSystem#mkdirs javadocs. + (Colin Patrick McCabe via eli) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index df1e2e4a5e7..3e7544da9e9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -509,14 +509,32 @@ public class DistributedFileSystem extends FileSystem { } /** - * Create a directory with given name and permission, only when - * parent directory exists. + * Create a directory, only when the parent directories exist. + * + * See {@link FsPermission#applyUMask(FsPermission)} for details of how + * the permission is applied. + * + * @param f The path to create + * @param permission The permission. See FsPermission#applyUMask for + * details about how this is used to calculate the + * effective permission. */ public boolean mkdir(Path f, FsPermission permission) throws IOException { statistics.incrementWriteOps(1); return dfs.mkdirs(getPathName(f), permission, false); } + /** + * Create a directory and its parent directories. + * + * See {@link FsPermission#applyUMask(FsPermission)} for details of how + * the permission is applied. + * + * @param f The path to create + * @param permission The permission. See FsPermission#applyUMask for + * details about how this is used to calculate the + * effective permission. + */ @Override public boolean mkdirs(Path f, FsPermission permission) throws IOException { statistics.incrementWriteOps(1);