use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class FSSTAT3Response method serialize.
@Override
public XDR serialize(XDR out, int xid, Verifier verifier) {
super.serialize(out, xid, verifier);
out.writeBoolean(true);
if (postOpAttr == null) {
postOpAttr = new Nfs3FileAttributes();
}
postOpAttr.serialize(out);
if (getStatus() == Nfs3Status.NFS3_OK) {
out.writeLongAsHyper(tbytes);
out.writeLongAsHyper(fbytes);
out.writeLongAsHyper(abytes);
out.writeLongAsHyper(tfiles);
out.writeLongAsHyper(ffiles);
out.writeLongAsHyper(afiles);
out.writeInt(invarsec);
}
return out;
}
use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class READ3Response method deserialize.
public static READ3Response deserialize(XDR xdr) {
int status = xdr.readInt();
xdr.readBoolean();
Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.deserialize(xdr);
int count = 0;
boolean eof = false;
byte[] data = new byte[0];
if (status == Nfs3Status.NFS3_OK) {
count = xdr.readInt();
eof = xdr.readBoolean();
int len = xdr.readInt();
assert (len == count);
data = xdr.readFixedOpaque(count);
}
return new READ3Response(status, postOpAttr, count, eof, ByteBuffer.wrap(data));
}
use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class READDIR3Response method deserialize.
public static READDIR3Response deserialize(XDR xdr) {
int status = xdr.readInt();
xdr.readBoolean();
Nfs3FileAttributes postOpDirAttr = Nfs3FileAttributes.deserialize(xdr);
long cookieVerf = 0;
ArrayList<Entry3> entries = new ArrayList<Entry3>();
DirList3 dirList = null;
if (status == Nfs3Status.NFS3_OK) {
cookieVerf = xdr.readHyper();
while (xdr.readBoolean()) {
Entry3 e = Entry3.deserialzie(xdr);
entries.add(e);
}
boolean eof = xdr.readBoolean();
Entry3[] allEntries = new Entry3[entries.size()];
entries.toArray(allEntries);
dirList = new DirList3(allEntries, eof);
}
return new READDIR3Response(status, postOpDirAttr, cookieVerf, dirList);
}
use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class READLINK3Response method deserialize.
public static READLINK3Response deserialize(XDR xdr) {
int status = xdr.readInt();
xdr.readBoolean();
Nfs3FileAttributes postOpSymlinkAttr = Nfs3FileAttributes.deserialize(xdr);
byte[] path = new byte[0];
if (status == Nfs3Status.NFS3_OK) {
path = xdr.readVariableOpaque();
}
return new READLINK3Response(status, postOpSymlinkAttr, path);
}
use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class RpcProgramNfs3 method access.
@VisibleForTesting
ACCESS3Response access(XDR xdr, SecurityHandler securityHandler, SocketAddress remoteAddress) {
ACCESS3Response response = new ACCESS3Response(Nfs3Status.NFS3_OK);
if (!checkAccessPrivilege(remoteAddress, AccessPrivilege.READ_ONLY)) {
response.setStatus(Nfs3Status.NFS3ERR_ACCES);
return response;
}
DFSClient dfsClient = clientCache.getDfsClient(securityHandler.getUser());
if (dfsClient == null) {
response.setStatus(Nfs3Status.NFS3ERR_SERVERFAULT);
return response;
}
ACCESS3Request request;
try {
request = ACCESS3Request.deserialize(xdr);
} catch (IOException e) {
LOG.error("Invalid ACCESS request");
return new ACCESS3Response(Nfs3Status.NFS3ERR_INVAL);
}
FileHandle handle = request.getHandle();
Nfs3FileAttributes attrs;
if (LOG.isDebugEnabled()) {
LOG.debug("NFS ACCESS fileId: " + handle.getFileId() + " client: " + remoteAddress);
}
try {
attrs = writeManager.getFileAttr(dfsClient, handle, iug);
if (attrs == null) {
LOG.error("Can't get path for fileId: " + handle.getFileId());
return new ACCESS3Response(Nfs3Status.NFS3ERR_STALE);
}
if (iug.getUserName(securityHandler.getUid(), "unknown").equals(superuser)) {
int access = Nfs3Constant.ACCESS3_LOOKUP | Nfs3Constant.ACCESS3_DELETE | Nfs3Constant.ACCESS3_EXECUTE | Nfs3Constant.ACCESS3_EXTEND | Nfs3Constant.ACCESS3_MODIFY | Nfs3Constant.ACCESS3_READ;
return new ACCESS3Response(Nfs3Status.NFS3_OK, attrs, access);
}
int access = Nfs3Utils.getAccessRightsForUserGroup(securityHandler.getUid(), securityHandler.getGid(), securityHandler.getAuxGids(), attrs);
return new ACCESS3Response(Nfs3Status.NFS3_OK, attrs, access);
} catch (RemoteException r) {
LOG.warn("Exception ", r);
IOException io = r.unwrapRemoteException();
/**
* AuthorizationException can be thrown if the user can't be proxy'ed.
*/
if (io instanceof AuthorizationException) {
return new ACCESS3Response(Nfs3Status.NFS3ERR_ACCES);
} else {
return new ACCESS3Response(Nfs3Status.NFS3ERR_IO);
}
} catch (IOException e) {
LOG.warn("Exception ", e);
int status = mapErrorStatus(e);
return new ACCESS3Response(status);
}
}
Aggregations