/** * * @return the umask of this FileContext */ public FsPermission getUMask() { return (umask != null ? umask : FsPermission.getUMask(conf)); }
/** * Create an FSDataOutputStream at the indicated Path with write-progress * reporting. * @param f the file name to open * @param overwrite if a file with this name already exists, then if true, * the file will be overwritten, and if false an error will be thrown. * @param bufferSize the size of the buffer to be used. * @param replication required block replication for the file. * @throws IOException IO failure */ public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress ) throws IOException { return this.create(f, FsCreateModes.applyUMask( FsPermission.getFileDefault(), FsPermission.getUMask(getConf())), overwrite, bufferSize, replication, blockSize, progress); }
protected boolean mkOneDirWithMode(Path p, File p2f, FsPermission permission) throws IOException { if (permission == null) { permission = FsPermission.getDirDefault(); } permission = permission.applyUMask(FsPermission.getUMask(getConf())); if (Shell.WINDOWS && NativeIO.isAvailable()) { try { NativeIO.Windows.createDirectoryWithMode(p2f, permission.toShort()); return true; } catch (IOException e) { if (LOG.isDebugEnabled()) { LOG.debug(String.format( "NativeIO.createDirectoryWithMode error, path = %s, mode = %o", p2f, permission.toShort()), e); } return false; } } else { boolean b = p2f.mkdir(); if (b) { setPermission(p, permission); } return b; } }
FSDataOutputStream create(PathData item, boolean lazyPersist, boolean direct) throws IOException { try { if (lazyPersist) { EnumSet<CreateFlag> createFlags = EnumSet.of(CREATE, LAZY_PERSIST); return create(item.path, FsPermission.getFileDefault().applyUMask( FsPermission.getUMask(getConf())), createFlags, getConf().getInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT), (short) 1, getDefaultBlockSize(), null, null); } else { return create(item.path, true); } } finally { // might have been created but stream was interrupted if (!direct) { deleteOnExit(item.path); } } }
private LocalFSFileOutputStream(Path f, boolean append, FsPermission permission) throws IOException { File file = pathToFile(f); if (!append && permission == null) { permission = FsPermission.getFileDefault(); } if (permission == null) { this.fos = new FileOutputStream(file, append); } else { permission = permission.applyUMask(FsPermission.getUMask(getConf())); if (Shell.WINDOWS && NativeIO.isAvailable()) { this.fos = NativeIO.Windows.createFileOutputStreamWithMode(file, append, permission.toShort()); } else { this.fos = new FileOutputStream(file, append); boolean success = false; try { setPermission(f, permission); success = true; } finally { if (!success) { IOUtils.cleanup(LOG, this.fos); } } } } }
try { stat = FILE_CREATOR.create(namenode, src, FsPermission.getFileDefault().applyUMask(FsPermission.getUMask(conf)), clientName, new EnumSetWritable<>(overwrite ? EnumSet.of(CREATE, OVERWRITE) : EnumSet.of(CREATE)), createParent, replication, blockSize, CryptoProtocolVersion.supported());
/** * Create a FileContext with specified FS as default using the specified * config. * * @param defFS * @param aConf * @return new FileContext with specifed FS as default. */ public static FileContext getFileContext(final AbstractFileSystem defFS, final Configuration aConf) { return new FileContext(defFS, FsPermission.getUMask(aConf), aConf); }
/** * Create a FileContext with specified FS as default using the specified * config. * * @param defFS * @param aConf * @return new FileContext with specifed FS as default. */ public static FileContext getFileContext(final AbstractFileSystem defFS, final Configuration aConf) { return new FileContext(defFS, FsPermission.getUMask(aConf), aConf); }
/** * Create a FileContext with specified FS as default using the specified * config. * * @param defFS * @param aConf * @return new FileContext with specifed FS as default. */ public static FileContext getFileContext(final AbstractFileSystem defFS, final Configuration aConf) { return new FileContext(defFS, FsPermission.getUMask(aConf), aConf); }
/** * Create a FileContext with specified FS as default using the specified * config. * * @param defFS * @param aConf * @return new FileContext with specifed FS as default. */ public static FileContext getFileContext(final AbstractFileSystem defFS, final Configuration aConf) { return new FileContext(defFS, FsPermission.getUMask(aConf), aConf); }
public void testDeprecatedUmask() { Configuration conf = new Configuration(); conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "302"); // 302 = 0456 FsPermission umask = FsPermission.getUMask(conf); assertEquals(0456, umask.toShort()); } }
private void createDir(FileSystem fs, Path path, FsPermission fsPerm) throws IOException { FsPermission dirPerm = new FsPermission(fsPerm); fs.mkdirs(path, dirPerm); FsPermission umask = FsPermission.getUMask(fs.getConf()); if (!dirPerm.equals(dirPerm.applyUMask(umask))) { fs.setPermission(path, new FsPermission(fsPerm)); } }
private void createDir(FileSystem fs, Path path, FsPermission fsPerm) throws IOException { FsPermission dirPerm = new FsPermission(fsPerm); fs.mkdirs(path, dirPerm); FsPermission umask = FsPermission.getUMask(fs.getConf()); if (!dirPerm.equals(dirPerm.applyUMask(umask))) { fs.setPermission(path, new FsPermission(fsPerm)); } }
private void createDir(FileSystem fs, Path path, FsPermission fsPerm) throws IOException { FsPermission dirPerm = new FsPermission(fsPerm); fs.mkdirs(path, dirPerm); FsPermission umask = FsPermission.getUMask(fs.getConf()); if (!dirPerm.equals(dirPerm.applyUMask(umask))) { fs.setPermission(path, new FsPermission(fsPerm)); } }
protected void createDir(FileSystem fs, Path path, FsPermission fsPerm) throws IOException { FsPermission dirPerm = new FsPermission(fsPerm); fs.mkdirs(path, dirPerm); FsPermission umask = FsPermission.getUMask(fs.getConf()); if (!dirPerm.equals(dirPerm.applyUMask(umask))) { fs.setPermission(path, new FsPermission(fsPerm)); } }
private FsPermission applyUMask(FsPermission permission) { if (permission == null) { permission = FsPermission.getDefault(); } return permission.applyUMask(FsPermission.getUMask(getConf())); }
private FsPermission applyUMask(FsPermission permission) { if (permission == null) { permission = FsPermission.getDefault(); } return FsCreateModes.applyUMask(permission, FsPermission.getUMask(getConf())); }
private FsPermission applyUMask(FsPermission permission) { if (permission == null) { permission = FsPermission.getDefault(); } return permission.applyUMask(FsPermission.getUMask(getConf())); }
public void testDeprecatedUmask() { Configuration conf = new Configuration(); conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "302"); // 302 = 0456 FsPermission umask = FsPermission.getUMask(conf); assertEquals(0456, umask.toShort()); } }
public void testDeprecatedUmask() { Configuration conf = new Configuration(); conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "302"); // 302 = 0456 FsPermission umask = FsPermission.getUMask(conf); assertEquals(0456, umask.toShort()); } }