/** * Create from unmasked mode and umask. * * If the mode is already an FsCreateModes object, return it. */ public static FsPermission applyUMask(FsPermission mode, FsPermission umask) { if (mode.getUnmasked() != null) { return mode; } return create(mode.applyUMask(umask), mode); }
/** * 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); }
/** * Create from masked and unmasked modes. */ public static FsCreateModes create(FsPermission masked, FsPermission unmasked) { assert masked.getUnmasked() == null; assert unmasked.getUnmasked() == null; return new FsCreateModes(masked, unmasked); }
@Override public String toString() { return MessageFormat.format("'{' masked: {0}, unmasked: {1} '}'", super.toString(), getUnmasked()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } FsCreateModes that = (FsCreateModes) o; return getUnmasked().equals(that.getUnmasked()); }
final FsPermission permission = unmaskedPermission == null ? params.permission() : FsCreateModes.create(params.permission(), unmaskedPermission); final boolean createParent = params.createParent();
IOException { final Path absDir = fixRelativePart(dir); final FsPermission absFerms = FsCreateModes.applyUMask( permission == null ? FsPermission.getDirDefault() : permission, getUMask());
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + getUnmasked().hashCode(); return result; } }
FsCreateModes.create(permission.getDirFsPermission(), unmaskedPermission.getDirFsPermission()); final boolean b = cp.mkdirs(fullpath, masked, true);
FsPermission permission = (permOpt != null) ? permOpt.getValue() : FILE_DEFAULT_PERM; permission = FsCreateModes.applyUMask(permission, getUMask());
@Override public MkdirsResponseProto mkdirs(RpcController controller, MkdirsRequestProto req) throws ServiceException { try { FsPermission masked = req.hasUnmasked() ? FsCreateModes.create(PBHelperClient.convert(req.getMasked()), PBHelperClient.convert(req.getUnmasked())) : PBHelperClient.convert(req.getMasked()); boolean result = server.mkdirs(req.getSrc(), masked, req.getCreateParent()); return MkdirsResponseProto.newBuilder().setResult(result).build(); } catch (IOException e) { throw new ServiceException(e); } }
private FsPermission applyUMaskDir(FsPermission permission) { if (permission == null) { permission = FsPermission.getDirDefault(); } return FsCreateModes.applyUMask(permission, dfsClientConf.getUMask()); }
/** * Executes the filesystem operation. * * @param fs filesystem instance to use. * * @return <code>true</code> if the mkdirs operation was successful, * <code>false</code> otherwise. * * @throws IOException thrown if an IO error occurred. */ @Override public JSONObject execute(FileSystem fs) throws IOException { FsPermission fsPermission = new FsPermission(permission); if (unmaskedPermission != -1) { fsPermission = FsCreateModes.create(fsPermission, new FsPermission(unmaskedPermission)); } boolean mkdirs = fs.mkdirs(path, fsPermission); return toJSON(HttpFSFileSystem.MKDIRS_JSON, mkdirs); }
private FsPermission applyUMask(FsPermission permission) { if (permission == null) { permission = FsPermission.getFileDefault(); } return FsCreateModes.applyUMask(permission, dfsClientConf.getUMask()); }
@Override public CreateResponseProto create(RpcController controller, CreateRequestProto req) throws ServiceException { try { FsPermission masked = req.hasUnmasked() ? FsCreateModes.create(PBHelperClient.convert(req.getMasked()), PBHelperClient.convert(req.getUnmasked())) : PBHelperClient.convert(req.getMasked()); HdfsFileStatus result = server.create(req.getSrc(), masked, req.getClientName(), PBHelperClient.convertCreateFlag(req.getCreateFlag()), req.getCreateParent(), (short) req.getReplication(), req.getBlockSize(), PBHelperClient.convertCryptoProtocolVersions( req.getCryptoProtocolVersionList()), req.getEcPolicyName()); if (result != null) { return CreateResponseProto.newBuilder().setFs(PBHelperClient.convert(result)) .build(); } return VOID_CREATE_RESPONSE; } catch (IOException e) { throw new ServiceException(e); } }
private FsPermission applyUMask(FsPermission permission) { if (permission == null) { permission = FsPermission.getDefault(); } return FsCreateModes.applyUMask(permission, FsPermission.getUMask(getConf())); }
/** * Executes the filesystem operation. * * @param fs filesystem instance to use. * * @return The URI of the created file. * * @throws IOException thrown if an IO error occurred. */ @Override public Void execute(FileSystem fs) throws IOException { if (replication == -1) { replication = fs.getDefaultReplication(path); } if (blockSize == -1) { blockSize = fs.getDefaultBlockSize(path); } FsPermission fsPermission = new FsPermission(permission); if (unmaskedPermission != -1) { fsPermission = FsCreateModes.create(fsPermission, new FsPermission(unmaskedPermission)); } int bufferSize = fs.getConf().getInt(HTTPFS_BUFFER_SIZE_KEY, HTTP_BUFFER_SIZE_DEFAULT); OutputStream os = fs.create(path, fsPermission, override, bufferSize, replication, blockSize, null); IOUtils.copyBytes(is, os, bufferSize, true); os.close(); return null; }