[ https://issues.apache.org/jira/browse/HADOOP-11347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14574902#comment-14574902 ]
Colin Patrick McCabe commented on HADOOP-11347: ----------------------------------------------- Thanks for looking at this, [~varun_saxena]. bq. private FsPermission umask = new FsPermission((short)0022); I don't think this needs to have a default value, given that {{initialize}} should always be called first. It can just be null until the FS is initialized. {code} @@ -296,12 +299,16 @@ private FSDataOutputStream create(Path f, boolean overwrite, protected OutputStream createOutputStream(Path f, boolean append) throws IOException { - return createOutputStreamWithMode(f, append, null); + return createOutputStreamWithMode(f, append, FsPermission.getFileDefault()); } protected OutputStream createOutputStreamWithMode(Path f, boolean append, FsPermission permission) throws IOException { - return new LocalFSFileOutputStream(f, append, permission); + if (null == permission) { + permission = FsPermission.getFileDefault(); + } + return new LocalFSFileOutputStream( + f, append, permission.applyUMask(umask)); } {code} Rather than changing this, I would prefer to change the {{LocalFSFileOutputStream}} to apply the umask to the permission that was passed in. It's a package-private constructor only used in this file, so we should be able to change it without compatibility issues. That way we would have fewer pieces of code that needed to be dealing with umask. Similarly with mkdir / mkOneDirWithMode. > Inconsistent enforcement of umask between FileSystem and FileContext > interacting with local file system. > -------------------------------------------------------------------------------------------------------- > > Key: HADOOP-11347 > URL: https://issues.apache.org/jira/browse/HADOOP-11347 > Project: Hadoop Common > Issue Type: Bug > Components: fs > Affects Versions: 2.7.0 > Reporter: Chris Nauroth > Assignee: Varun Saxena > Labels: BB2015-05-RFC > Attachments: HADOOP-11347.001.patch, HADOOP-11347.002.patch, > HADOOP-11347.004.patch, HADOOP-11347.03.patch > > > The {{FileSystem}} and {{FileContext}} APIs are inconsistent in enforcement > of umask for newly created directories. {{FileContext}} utilizes > configuration property {{fs.permissions.umask-mode}} and runs a separate > {{chmod}} call to guarantee bypassing the process umask. This is the > expected behavior for Hadoop as discussed in the documentation of > {{fs.permissions.umask-mode}}. For the equivalent {{FileSystem}} APIs, it > does not use {{fs.permissions.umask-mode}}. Instead, the permissions end up > getting controlled by the process umask. -- This message was sent by Atlassian JIRA (v6.3.4#6332)