/** * 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); }
final FsPermission permission = unmaskedPermission == null ? params.permission() : FsCreateModes.create(params.permission(), unmaskedPermission); final boolean createParent = params.createParent();
FsCreateModes.create(permission.getDirFsPermission(), unmaskedPermission.getDirFsPermission()); final boolean b = cp.mkdirs(fullpath, masked, true);
@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); } }
/** * 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); }
@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); } }
/** * 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; }