protected FsPermission getPermission() { if (permission == null) { permission = FsPermission.getFileDefault(); } return permission; }
/** * Sets permission. * @param permission if permission is null, default value is set */ protected void setPermission(FsPermission permission) { this.permission = (permission == null) ? FsPermission.getFileDefault() : permission; }
return FsPermission.getFileDefault(); + conf.get(permssionConfKey) + ", using default file permissions.", e); return FsPermission.getFileDefault(); return FsPermission.getFileDefault();
/** * Opens an FSDataOutputStream at the indicated Path with write-progress * reporting. Same as create(), except fails if parent directory doesn't * already exist. * @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. * @param blockSize block size * @param progress the progress reporter * @throws IOException IO failure * @see #setPermission(Path, FsPermission) */ public FSDataOutputStream createNonRecursive(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { return this.createNonRecursive(f, FsPermission.getFileDefault(), overwrite, bufferSize, replication, blockSize, progress); }
/** * 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); }
public FileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, Path symlink, Path path, Set<AttrFlags> attr) { this.length = length; this.isdir = isdir; this.block_replication = (short)block_replication; this.blocksize = blocksize; this.modification_time = modification_time; this.access_time = access_time; if (permission != null) { this.permission = permission; } else if (isdir) { this.permission = FsPermission.getDirDefault(); } else if (symlink != null) { this.permission = FsPermission.getDefault(); } else { this.permission = FsPermission.getFileDefault(); } this.owner = (owner == null) ? "" : owner; this.group = (group == null) ? "" : group; this.symlink = symlink; this.path = path; this.attr = attr; // The variables isdir and symlink indicate the type: // 1. isdir implies directory, in which case symlink must be null. // 2. !isdir implies a file or symlink, symlink != null implies a // symlink, otherwise it's a file. assert (isdir && symlink == null) || !isdir; }
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); } } } } }
HConstants.DATA_FILE_UMASK_KEY); assertEquals(FsPermission.getFileDefault(), defaultFsPerm);
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());
/** * Sets permission. * @param permission if permission is null, default value is set */ protected void setPermission(FsPermission permission) { this.permission = (permission == null) ? FsPermission.getFileDefault() : permission; }
/** * Sets permission. * @param permission if permission is null, default value is set */ protected void setPermission(FsPermission permission) { this.permission = (permission == null) ? FsPermission.getFileDefault() : permission; }
/** * @return file permission after applying umask */ @JsonIgnore public FsPermission getFilePermission() { return FsPermission.getFileDefault().applyUMask(new FsPermission(umask)); }
@Override @SuppressWarnings("deprecation") public FSDataOutputStream createNonRecursive(final Path f, final boolean overwrite, final int bufferSize, final short replication, final long blockSize, final Progressable progress) throws IOException { return this.createNonRecursive(f, FsPermission.getFileDefault(), overwrite, bufferSize, replication, blockSize, progress); }
@Override public FSDataOutputStream createNonRecursive(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { return this.createNonRecursive(f, FsPermission.getFileDefault(), overwrite, bufferSize, replication, blockSize, progress); }
@Override @SuppressWarnings("deprecation") public FSDataOutputStream createNonRecursive(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { return this.createNonRecursive(f, FsPermission.getFileDefault(), overwrite, bufferSize, replication, blockSize, progress); }
private FsPermission applyUMask(FsPermission permission) { if (permission == null) { permission = FsPermission.getFileDefault(); } return FsCreateModes.applyUMask(permission, dfsClientConf.getUMask()); }
@Test public void testMkdirsRemoteFile() throws IOException { doReturn(true).when(mockLocalFS).mkdirs( new Path("/foo/bar/dir2"), FsPermission.getFileDefault()); doReturn(true).when(mockRemoteFS).mkdirs( new Path("/foo/bar/dir2"), FsPermission.getFileDefault()); Path path = new Path("/foo/bar/dir2"); assertTrue(fs.mkdirs(path, FsPermission.getFileDefault())); }
@Test public void testCreateRoot() throws IOException { Path root = new Path("/"); try { fs.create(root, FsPermission.getFileDefault(), true, 0, (short) 1, 4096, null); fail("Expected create call to throw an exception"); } catch (AccessControlException e) { // ok } }
@Test public void testCreateLocalFile() throws IOException { try { Path path = new Path("foo/bar/file"); @SuppressWarnings("unused") FSDataOutputStream fdos = fs.create(path, FsPermission.getFileDefault(), true, 0, (short) 1, 4096, null); fail("Expected create call to throw an exception"); } catch (IOException e) { // ok } }