HDFS-1322. Document umask in DistributedFileSystem#mkdirs javadocs. Contributed by Colin Patrick McCabe

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1408533 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-11-13 01:29:51 +00:00
parent 877b8200df
commit 4321bc1d5c
3 changed files with 35 additions and 3 deletions

View File

@ -184,7 +184,18 @@ public class FsPermission implements Writable {
return str; 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) { public FsPermission applyUMask(FsPermission umask) {
return new FsPermission(useraction.and(umask.useraction.not()), return new FsPermission(useraction.and(umask.useraction.not()),
groupaction.and(umask.groupaction.not()), groupaction.and(umask.groupaction.not()),

View File

@ -114,6 +114,9 @@ Release 2.0.3-alpha - Unreleased
HDFS-4048. Use ERROR instead of INFO for volume failure logs. HDFS-4048. Use ERROR instead of INFO for volume failure logs.
(Stephen Chu via eli) (Stephen Chu via eli)
HDFS-1322. Document umask in DistributedFileSystem#mkdirs javadocs.
(Colin Patrick McCabe via eli)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -509,14 +509,32 @@ public class DistributedFileSystem extends FileSystem {
} }
/** /**
* Create a directory with given name and permission, only when * Create a directory, only when the parent directories exist.
* parent directory exists. *
* 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 { public boolean mkdir(Path f, FsPermission permission) throws IOException {
statistics.incrementWriteOps(1); statistics.incrementWriteOps(1);
return dfs.mkdirs(getPathName(f), permission, false); 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 @Override
public boolean mkdirs(Path f, FsPermission permission) throws IOException { public boolean mkdirs(Path f, FsPermission permission) throws IOException {
statistics.incrementWriteOps(1); statistics.incrementWriteOps(1);