Initial commit: notification-elements-demo app

Interactive Angular 19 demo for @sda/notification-elements-ui with
6 sections: Bell & Feed, Notification Center, Inbox, Comments &
Threads, Mention Input, and Full-Featured layout. Includes mock
data, dark mode toggle, and real-time event log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Giuliano Silvestro
2026-02-13 21:49:19 +10:00
commit 5d0c9ec7eb
36473 changed files with 3778146 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { Nfsv3Encoder } from './Nfsv3Encoder';
import { RpcMessageEncoder } from '../../rpc/RpcMessageEncoder';
import { RmRecordEncoder } from '../../rm/RmRecordEncoder';
import { Nfsv3Proc } from './constants';
import { RpcOpaqueAuth } from '../../rpc/messages';
import type * as msg from './messages';
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
export declare class FullNfsv3Encoder<W extends IWriter & IWriterGrowable = IWriter & IWriterGrowable> {
program: number;
readonly writer: W;
protected readonly nfsEncoder: Nfsv3Encoder<W>;
protected readonly rpcEncoder: RpcMessageEncoder<W>;
protected readonly rmEncoder: RmRecordEncoder<W>;
constructor(program?: number, writer?: W);
encodeCall(xid: number, proc: Nfsv3Proc, cred: RpcOpaqueAuth, verf: RpcOpaqueAuth, request: msg.Nfsv3Request): Uint8Array;
writeCall(xid: number, proc: Nfsv3Proc, cred: RpcOpaqueAuth, verf: RpcOpaqueAuth, request: msg.Nfsv3Request): void;
encodeAcceptedReply(xid: number, proc: Nfsv3Proc, verf: RpcOpaqueAuth, response: msg.Nfsv3Response): Uint8Array;
writeAcceptedReply(xid: number, proc: Nfsv3Proc, verf: RpcOpaqueAuth, response: msg.Nfsv3Response): void;
encodeRejectedReply(xid: number, rejectStat: number, mismatchInfo?: {
low: number;
high: number;
}, authStat?: number): Uint8Array;
writeRejectedReply(xid: number, rejectStat: number, mismatchInfo?: {
low: number;
high: number;
}, authStat?: number): void;
private writeRmHeader;
}

View File

@@ -0,0 +1,73 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FullNfsv3Encoder = void 0;
const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
const Nfsv3Encoder_1 = require("./Nfsv3Encoder");
const RpcMessageEncoder_1 = require("../../rpc/RpcMessageEncoder");
const RmRecordEncoder_1 = require("../../rm/RmRecordEncoder");
const MAX_SINGLE_FRAME_SIZE = 0x7fffffff;
const RM_HEADER_SIZE = 4;
class FullNfsv3Encoder {
constructor(program = 100003, writer = new Writer_1.Writer()) {
this.program = program;
this.writer = writer;
this.nfsEncoder = new Nfsv3Encoder_1.Nfsv3Encoder(writer);
this.rpcEncoder = new RpcMessageEncoder_1.RpcMessageEncoder(writer);
this.rmEncoder = new RmRecordEncoder_1.RmRecordEncoder(writer);
}
encodeCall(xid, proc, cred, verf, request) {
this.writeCall(xid, proc, cred, verf, request);
return this.writer.flush();
}
writeCall(xid, proc, cred, verf, request) {
const writer = this.writer;
const rmHeaderPosition = writer.x;
writer.x += RM_HEADER_SIZE;
this.rpcEncoder.writeCall(xid, 100003, 3, proc, cred, verf);
this.nfsEncoder.writeMessage(request, proc, true);
this.writeRmHeader(rmHeaderPosition, writer.x);
}
encodeAcceptedReply(xid, proc, verf, response) {
this.writeAcceptedReply(xid, proc, verf, response);
return this.writer.flush();
}
writeAcceptedReply(xid, proc, verf, response) {
const writer = this.writer;
const rmHeaderPosition = writer.x;
writer.x += RM_HEADER_SIZE;
this.rpcEncoder.writeAcceptedReply(xid, verf, 0);
this.nfsEncoder.writeMessage(response, proc, false);
this.writeRmHeader(rmHeaderPosition, writer.x);
}
encodeRejectedReply(xid, rejectStat, mismatchInfo, authStat) {
this.writeRejectedReply(xid, rejectStat, mismatchInfo, authStat);
return this.writer.flush();
}
writeRejectedReply(xid, rejectStat, mismatchInfo, authStat) {
const writer = this.writer;
const rmHeaderPosition = writer.x;
writer.x += RM_HEADER_SIZE;
this.rpcEncoder.writeRejectedReply(xid, rejectStat, mismatchInfo, authStat);
this.writeRmHeader(rmHeaderPosition, writer.x);
}
writeRmHeader(rmHeaderPosition, endPosition) {
const writer = this.writer;
const rmEncoder = this.rmEncoder;
const totalSize = endPosition - rmHeaderPosition - RM_HEADER_SIZE;
if (totalSize <= MAX_SINGLE_FRAME_SIZE) {
const currentX = writer.x;
writer.x = rmHeaderPosition;
rmEncoder.writeHdr(1, totalSize);
writer.x = currentX;
}
else {
const currentX = writer.x;
writer.x = rmHeaderPosition;
const data = writer.uint8.subarray(rmHeaderPosition + RM_HEADER_SIZE, currentX);
writer.reset();
rmEncoder.writeRecord(data);
}
}
}
exports.FullNfsv3Encoder = FullNfsv3Encoder;
//# sourceMappingURL=FullNfsv3Encoder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FullNfsv3Encoder.js","sourceRoot":"","sources":["../../../src/nfs/v3/FullNfsv3Encoder.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,iDAA4C;AAC5C,mEAA8D;AAC9D,8DAAyD;AAOzD,MAAM,qBAAqB,GAAG,UAAU,CAAC;AACzC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,MAAa,gBAAgB;IAK3B,YACS,UAAkB,MAAM,EACf,SAAY,IAAI,eAAM,EAAS;QADxC,YAAO,GAAP,OAAO,CAAiB;QACf,WAAM,GAAN,MAAM,CAAyB;QAE/C,IAAI,CAAC,UAAU,GAAG,IAAI,2BAAY,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAiB,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAe,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAEM,UAAU,CACf,GAAW,EACX,IAAe,EACf,IAAmB,EACnB,IAAmB,EACnB,OAAyB;QAEzB,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,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,CAAC,CAAC;YAChF,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAnGD,4CAmGC"}

View File

@@ -0,0 +1,78 @@
import { Reader } from '@jsonjoy.com/buffers/lib/Reader';
import { XdrDecoder } from '../../xdr/XdrDecoder';
import { Nfsv3Proc } from './constants';
import * as msg from './messages';
export declare class Nfsv3Decoder {
protected readonly xdr: XdrDecoder;
constructor(reader?: Reader);
decodeMessage(reader: Reader, proc: Nfsv3Proc, isRequest: boolean): msg.Nfsv3Message | undefined;
private decodeRequest;
private decodeResponse;
private readFh;
private readFilename;
private readTime;
private readSpecData;
private readFattr;
private readPostOpAttr;
private readWccAttr;
private readPreOpAttr;
private readWccData;
private readPostOpFh;
private readSetMode;
private readSetUid;
private readSetGid;
private readSetSize;
private readSetAtime;
private readSetMtime;
private readSattr;
private readSattrGuard;
private readDirOpArgs;
private readCreateHow;
private readMknodData;
private readEntry;
private readEntryPlus;
private readDirList;
private readDirListPlus;
private decodeGetattrRequest;
private decodeGetattrResponse;
private decodeSetattrRequest;
private decodeSetattrResponse;
private decodeLookupRequest;
private decodeLookupResponse;
private decodeAccessRequest;
private decodeAccessResponse;
private decodeReadlinkRequest;
private decodeReadlinkResponse;
private decodeReadRequest;
private decodeReadResponse;
private decodeWriteRequest;
private decodeWriteResponse;
private decodeCreateRequest;
private decodeCreateResponse;
private decodeMkdirRequest;
private decodeMkdirResponse;
private decodeSymlinkRequest;
private decodeSymlinkResponse;
private decodeMknodRequest;
private decodeMknodResponse;
private decodeRemoveRequest;
private decodeRemoveResponse;
private decodeRmdirRequest;
private decodeRmdirResponse;
private decodeRenameRequest;
private decodeRenameResponse;
private decodeLinkRequest;
private decodeLinkResponse;
private decodeReaddirRequest;
private decodeReaddirResponse;
private decodeReaddirplusRequest;
private decodeReaddirplusResponse;
private decodeFsstatRequest;
private decodeFsstatResponse;
private decodeFsinfoRequest;
private decodeFsinfoResponse;
private decodePathconfRequest;
private decodePathconfResponse;
private decodeCommitRequest;
private decodeCommitResponse;
}

View File

@@ -0,0 +1,757 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv3Decoder = void 0;
const tslib_1 = require("tslib");
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
const XdrDecoder_1 = require("../../xdr/XdrDecoder");
const errors_1 = require("./errors");
const msg = tslib_1.__importStar(require("./messages"));
const structs = tslib_1.__importStar(require("./structs"));
class Nfsv3Decoder {
constructor(reader = new Reader_1.Reader()) {
this.xdr = new XdrDecoder_1.XdrDecoder(reader);
}
decodeMessage(reader, proc, isRequest) {
this.xdr.reader = reader;
const startPos = reader.x;
try {
if (isRequest) {
return this.decodeRequest(proc);
}
else {
return this.decodeResponse(proc);
}
}
catch (err) {
if (err instanceof RangeError) {
reader.x = startPos;
return undefined;
}
throw err;
}
}
decodeRequest(proc) {
switch (proc) {
case 1:
return this.decodeGetattrRequest();
case 2:
return this.decodeSetattrRequest();
case 3:
return this.decodeLookupRequest();
case 4:
return this.decodeAccessRequest();
case 5:
return this.decodeReadlinkRequest();
case 6:
return this.decodeReadRequest();
case 7:
return this.decodeWriteRequest();
case 8:
return this.decodeCreateRequest();
case 9:
return this.decodeMkdirRequest();
case 10:
return this.decodeSymlinkRequest();
case 11:
return this.decodeMknodRequest();
case 12:
return this.decodeRemoveRequest();
case 13:
return this.decodeRmdirRequest();
case 14:
return this.decodeRenameRequest();
case 15:
return this.decodeLinkRequest();
case 16:
return this.decodeReaddirRequest();
case 17:
return this.decodeReaddirplusRequest();
case 18:
return this.decodeFsstatRequest();
case 19:
return this.decodeFsinfoRequest();
case 20:
return this.decodePathconfRequest();
case 21:
return this.decodeCommitRequest();
default:
throw new errors_1.Nfsv3DecodingError(`Unknown procedure: \${proc}`);
}
}
decodeResponse(proc) {
switch (proc) {
case 1:
return this.decodeGetattrResponse();
case 2:
return this.decodeSetattrResponse();
case 3:
return this.decodeLookupResponse();
case 4:
return this.decodeAccessResponse();
case 5:
return this.decodeReadlinkResponse();
case 6:
return this.decodeReadResponse();
case 7:
return this.decodeWriteResponse();
case 8:
return this.decodeCreateResponse();
case 9:
return this.decodeMkdirResponse();
case 10:
return this.decodeSymlinkResponse();
case 11:
return this.decodeMknodResponse();
case 12:
return this.decodeRemoveResponse();
case 13:
return this.decodeRmdirResponse();
case 14:
return this.decodeRenameResponse();
case 15:
return this.decodeLinkResponse();
case 16:
return this.decodeReaddirResponse();
case 17:
return this.decodeReaddirplusResponse();
case 18:
return this.decodeFsstatResponse();
case 19:
return this.decodeFsinfoResponse();
case 20:
return this.decodePathconfResponse();
case 21:
return this.decodeCommitResponse();
default:
throw new errors_1.Nfsv3DecodingError(`Unknown procedure: \${proc}`);
}
}
readFh() {
const data = this.xdr.readVarlenOpaque();
return new structs.Nfsv3Fh(data);
}
readFilename() {
return this.xdr.readString();
}
readTime() {
const xdr = this.xdr;
const seconds = xdr.readUnsignedInt();
const nseconds = xdr.readUnsignedInt();
return new structs.Nfsv3Time(seconds, nseconds);
}
readSpecData() {
const xdr = this.xdr;
const specdata1 = xdr.readUnsignedInt();
const specdata2 = xdr.readUnsignedInt();
return new structs.Nfsv3SpecData(specdata1, specdata2);
}
readFattr() {
const xdr = this.xdr;
const type = xdr.readUnsignedInt();
const mode = xdr.readUnsignedInt();
const nlink = xdr.readUnsignedInt();
const uid = xdr.readUnsignedInt();
const gid = xdr.readUnsignedInt();
const size = xdr.readUnsignedHyper();
const used = xdr.readUnsignedHyper();
const rdev = this.readSpecData();
const fsid = xdr.readUnsignedHyper();
const fileid = xdr.readUnsignedHyper();
const atime = this.readTime();
const mtime = this.readTime();
const ctime = this.readTime();
return new structs.Nfsv3Fattr(type, mode, nlink, uid, gid, size, used, rdev, fsid, fileid, atime, mtime, ctime);
}
readPostOpAttr() {
const attributesFollow = this.xdr.readBoolean();
const attributes = attributesFollow ? this.readFattr() : undefined;
return new structs.Nfsv3PostOpAttr(attributesFollow, attributes);
}
readWccAttr() {
const size = this.xdr.readUnsignedHyper();
const mtime = this.readTime();
const ctime = this.readTime();
return new structs.Nfsv3WccAttr(size, mtime, ctime);
}
readPreOpAttr() {
const attributesFollow = this.xdr.readBoolean();
const attributes = attributesFollow ? this.readWccAttr() : undefined;
return new structs.Nfsv3PreOpAttr(attributesFollow, attributes);
}
readWccData() {
const before = this.readPreOpAttr();
const after = this.readPostOpAttr();
return new structs.Nfsv3WccData(before, after);
}
readPostOpFh() {
const handleFollows = this.xdr.readBoolean();
const handle = handleFollows ? this.readFh() : undefined;
return new structs.Nfsv3PostOpFh(handleFollows, handle);
}
readSetMode() {
const set = this.xdr.readBoolean();
const mode = set ? this.xdr.readUnsignedInt() : undefined;
return new structs.Nfsv3SetMode(set, mode);
}
readSetUid() {
const set = this.xdr.readBoolean();
const uid = set ? this.xdr.readUnsignedInt() : undefined;
return new structs.Nfsv3SetUid(set, uid);
}
readSetGid() {
const set = this.xdr.readBoolean();
const gid = set ? this.xdr.readUnsignedInt() : undefined;
return new structs.Nfsv3SetGid(set, gid);
}
readSetSize() {
const set = this.xdr.readBoolean();
const size = set ? this.xdr.readUnsignedHyper() : undefined;
return new structs.Nfsv3SetSize(set, size);
}
readSetAtime() {
const how = this.xdr.readUnsignedInt();
const atime = how === 2 ? this.readTime() : undefined;
return new structs.Nfsv3SetAtime(how, atime);
}
readSetMtime() {
const how = this.xdr.readUnsignedInt();
const mtime = how === 2 ? this.readTime() : undefined;
return new structs.Nfsv3SetMtime(how, mtime);
}
readSattr() {
const mode = this.readSetMode();
const uid = this.readSetUid();
const gid = this.readSetGid();
const size = this.readSetSize();
const atime = this.readSetAtime();
const mtime = this.readSetMtime();
return new structs.Nfsv3Sattr(mode, uid, gid, size, atime, mtime);
}
readSattrGuard() {
const check = this.xdr.readBoolean();
const objCtime = check ? this.readTime() : undefined;
return new structs.Nfsv3SattrGuard(check, objCtime);
}
readDirOpArgs() {
const dir = this.readFh();
const name = this.readFilename();
return new structs.Nfsv3DirOpArgs(dir, name);
}
readCreateHow() {
const xdr = this.xdr;
const mode = xdr.readUnsignedInt();
let objAttributes;
let verf;
if (mode === 0 || mode === 1) {
objAttributes = this.readSattr();
}
else if (mode === 2) {
const verfData = xdr.readOpaque(8);
verf = verfData;
}
return new structs.Nfsv3CreateHow(mode, objAttributes, verf);
}
readMknodData() {
const type = this.xdr.readUnsignedInt();
let chr;
let blk;
let sock;
let pipe;
switch (type) {
case 4:
chr = new structs.Nfsv3DeviceData(this.readSattr(), this.readSpecData());
break;
case 3:
blk = new structs.Nfsv3DeviceData(this.readSattr(), this.readSpecData());
break;
case 6:
sock = this.readSattr();
break;
case 7:
pipe = this.readSattr();
break;
}
return new structs.Nfsv3MknodData(type, chr, blk, sock, pipe);
}
readEntry() {
const xdr = this.xdr;
const valueFollows = xdr.readBoolean();
if (!valueFollows)
return undefined;
const fileid = xdr.readUnsignedHyper();
const name = this.readFilename();
const cookie = xdr.readUnsignedHyper();
const nextentry = this.readEntry();
return new structs.Nfsv3Entry(fileid, name, cookie, nextentry);
}
readEntryPlus() {
const xdr = this.xdr;
const valueFollows = xdr.readBoolean();
if (!valueFollows)
return undefined;
const fileid = xdr.readUnsignedHyper();
const name = this.readFilename();
const cookie = xdr.readUnsignedHyper();
const nameAttributes = this.readPostOpAttr();
const nameHandle = this.readPostOpFh();
const nextentry = this.readEntryPlus();
return new structs.Nfsv3EntryPlus(fileid, name, cookie, nameAttributes, nameHandle, nextentry);
}
readDirList() {
const entries = this.readEntry();
const eof = this.xdr.readBoolean();
return new structs.Nfsv3DirList(eof, entries);
}
readDirListPlus() {
const entries = this.readEntryPlus();
const eof = this.xdr.readBoolean();
return new structs.Nfsv3DirListPlus(eof, entries);
}
decodeGetattrRequest() {
const object = this.readFh();
return new msg.Nfsv3GetattrRequest(object);
}
decodeGetattrResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
if (status === 0) {
const objAttributes = this.readFattr();
resok = new msg.Nfsv3GetattrResOk(objAttributes);
}
return new msg.Nfsv3GetattrResponse(status, resok);
}
decodeSetattrRequest() {
const object = this.readFh();
const newAttributes = this.readSattr();
const guard = this.readSattrGuard();
return new msg.Nfsv3SetattrRequest(object, newAttributes, guard);
}
decodeSetattrResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
const objWcc = this.readWccData();
if (status === 0) {
resok = new msg.Nfsv3SetattrResOk(objWcc);
}
else {
resfail = new msg.Nfsv3SetattrResFail(objWcc);
}
return new msg.Nfsv3SetattrResponse(status, resok, resfail);
}
decodeLookupRequest() {
const what = this.readDirOpArgs();
return new msg.Nfsv3LookupRequest(what);
}
decodeLookupResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
if (status === 0) {
const object = this.readFh();
const objAttributes = this.readPostOpAttr();
const dirAttributes = this.readPostOpAttr();
resok = new msg.Nfsv3LookupResOk(object, objAttributes, dirAttributes);
}
else {
const dirAttributes = this.readPostOpAttr();
resfail = new msg.Nfsv3LookupResFail(dirAttributes);
}
return new msg.Nfsv3LookupResponse(status, resok, resfail);
}
decodeAccessRequest() {
const object = this.readFh();
const access = this.xdr.readUnsignedInt();
return new msg.Nfsv3AccessRequest(object, access);
}
decodeAccessResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const objAttributes = this.readPostOpAttr();
if (status === 0) {
const access = xdr.readUnsignedInt();
resok = new msg.Nfsv3AccessResOk(objAttributes, access);
}
else {
resfail = new msg.Nfsv3AccessResFail(objAttributes);
}
return new msg.Nfsv3AccessResponse(status, resok, resfail);
}
decodeReadlinkRequest() {
const symlink = this.readFh();
return new msg.Nfsv3ReadlinkRequest(symlink);
}
decodeReadlinkResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
const symlinkAttributes = this.readPostOpAttr();
if (status === 0) {
const data = this.readFilename();
resok = new msg.Nfsv3ReadlinkResOk(symlinkAttributes, data);
}
else {
resfail = new msg.Nfsv3ReadlinkResFail(symlinkAttributes);
}
return new msg.Nfsv3ReadlinkResponse(status, resok, resfail);
}
decodeReadRequest() {
const file = this.readFh();
const xdr = this.xdr;
const offset = xdr.readUnsignedHyper();
const count = xdr.readUnsignedInt();
return new msg.Nfsv3ReadRequest(file, offset, count);
}
decodeReadResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
const fileAttributes = this.readPostOpAttr();
if (status === 0) {
const xdr = this.xdr;
const count = xdr.readUnsignedInt();
const eof = xdr.readBoolean();
const data = xdr.readVarlenOpaque();
resok = new msg.Nfsv3ReadResOk(fileAttributes, count, eof, data);
}
else {
resfail = new msg.Nfsv3ReadResFail(fileAttributes);
}
return new msg.Nfsv3ReadResponse(status, resok, resfail);
}
decodeWriteRequest() {
const file = this.readFh();
const xdr = this.xdr;
const offset = xdr.readUnsignedHyper();
const count = xdr.readUnsignedInt();
const stable = xdr.readUnsignedInt();
const data = xdr.readVarlenOpaque();
return new msg.Nfsv3WriteRequest(file, offset, count, stable, data);
}
decodeWriteResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const fileWcc = this.readWccData();
if (status === 0) {
const count = xdr.readUnsignedInt();
const committed = xdr.readUnsignedInt();
const verf = xdr.readOpaque(8);
resok = new msg.Nfsv3WriteResOk(fileWcc, count, committed, verf);
}
else {
resfail = new msg.Nfsv3WriteResFail(fileWcc);
}
return new msg.Nfsv3WriteResponse(status, resok, resfail);
}
decodeCreateRequest() {
const where = this.readDirOpArgs();
const how = this.readCreateHow();
return new msg.Nfsv3CreateRequest(where, how);
}
decodeCreateResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
if (status === 0) {
const obj = this.readPostOpFh();
const objAttributes = this.readPostOpAttr();
const dirWcc = this.readWccData();
resok = new msg.Nfsv3CreateResOk(obj, objAttributes, dirWcc);
}
else {
const dirWcc = this.readWccData();
resfail = new msg.Nfsv3CreateResFail(dirWcc);
}
return new msg.Nfsv3CreateResponse(status, resok, resfail);
}
decodeMkdirRequest() {
const where = this.readDirOpArgs();
const attributes = this.readSattr();
return new msg.Nfsv3MkdirRequest(where, attributes);
}
decodeMkdirResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
if (status === 0) {
const obj = this.readPostOpFh();
const objAttributes = this.readPostOpAttr();
const dirWcc = this.readWccData();
resok = new msg.Nfsv3MkdirResOk(obj, objAttributes, dirWcc);
}
else {
const dirWcc = this.readWccData();
resfail = new msg.Nfsv3MkdirResFail(dirWcc);
}
return new msg.Nfsv3MkdirResponse(status, resok, resfail);
}
decodeSymlinkRequest() {
const where = this.readDirOpArgs();
const symlinkAttributes = this.readSattr();
const symlinkData = this.readFilename();
return new msg.Nfsv3SymlinkRequest(where, symlinkAttributes, symlinkData);
}
decodeSymlinkResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
if (status === 0) {
const obj = this.readPostOpFh();
const objAttributes = this.readPostOpAttr();
const dirWcc = this.readWccData();
resok = new msg.Nfsv3SymlinkResOk(obj, objAttributes, dirWcc);
}
else {
const dirWcc = this.readWccData();
resfail = new msg.Nfsv3SymlinkResFail(dirWcc);
}
return new msg.Nfsv3SymlinkResponse(status, resok, resfail);
}
decodeMknodRequest() {
const where = this.readDirOpArgs();
const what = this.readMknodData();
return new msg.Nfsv3MknodRequest(where, what);
}
decodeMknodResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
if (status === 0) {
const obj = this.readPostOpFh();
const objAttributes = this.readPostOpAttr();
const dirWcc = this.readWccData();
resok = new msg.Nfsv3MknodResOk(obj, objAttributes, dirWcc);
}
else {
const dirWcc = this.readWccData();
resfail = new msg.Nfsv3MknodResFail(dirWcc);
}
return new msg.Nfsv3MknodResponse(status, resok, resfail);
}
decodeRemoveRequest() {
const object = this.readDirOpArgs();
return new msg.Nfsv3RemoveRequest(object);
}
decodeRemoveResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
const dirWcc = this.readWccData();
if (status === 0) {
resok = new msg.Nfsv3RemoveResOk(dirWcc);
}
else {
resfail = new msg.Nfsv3RemoveResFail(dirWcc);
}
return new msg.Nfsv3RemoveResponse(status, resok, resfail);
}
decodeRmdirRequest() {
const object = this.readDirOpArgs();
return new msg.Nfsv3RmdirRequest(object);
}
decodeRmdirResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
const dirWcc = this.readWccData();
if (status === 0) {
resok = new msg.Nfsv3RmdirResOk(dirWcc);
}
else {
resfail = new msg.Nfsv3RmdirResFail(dirWcc);
}
return new msg.Nfsv3RmdirResponse(status, resok, resfail);
}
decodeRenameRequest() {
const from = this.readDirOpArgs();
const to = this.readDirOpArgs();
return new msg.Nfsv3RenameRequest(from, to);
}
decodeRenameResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
const fromDirWcc = this.readWccData();
const toDirWcc = this.readWccData();
if (status === 0) {
resok = new msg.Nfsv3RenameResOk(fromDirWcc, toDirWcc);
}
else {
resfail = new msg.Nfsv3RenameResFail(fromDirWcc, toDirWcc);
}
return new msg.Nfsv3RenameResponse(status, resok, resfail);
}
decodeLinkRequest() {
const file = this.readFh();
const link = this.readDirOpArgs();
return new msg.Nfsv3LinkRequest(file, link);
}
decodeLinkResponse() {
const status = this.xdr.readUnsignedInt();
let resok;
let resfail;
const fileAttributes = this.readPostOpAttr();
const linkDirWcc = this.readWccData();
if (status === 0) {
resok = new msg.Nfsv3LinkResOk(fileAttributes, linkDirWcc);
}
else {
resfail = new msg.Nfsv3LinkResFail(fileAttributes, linkDirWcc);
}
return new msg.Nfsv3LinkResponse(status, resok, resfail);
}
decodeReaddirRequest() {
const dir = this.readFh();
const xdr = this.xdr;
const cookie = xdr.readUnsignedHyper();
const cookieverf = xdr.readOpaque(8);
const count = xdr.readUnsignedInt();
return new msg.Nfsv3ReaddirRequest(dir, cookie, cookieverf, count);
}
decodeReaddirResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const dirAttributes = this.readPostOpAttr();
if (status === 0) {
const cookieverf = xdr.readOpaque(8);
const reply = this.readDirList();
resok = new msg.Nfsv3ReaddirResOk(dirAttributes, cookieverf, reply);
}
else {
resfail = new msg.Nfsv3ReaddirResFail(dirAttributes);
}
return new msg.Nfsv3ReaddirResponse(status, resok, resfail);
}
decodeReaddirplusRequest() {
const dir = this.readFh();
const xdr = this.xdr;
const cookie = xdr.readUnsignedHyper();
const cookieverf = xdr.readOpaque(8);
const dircount = xdr.readUnsignedInt();
const maxcount = xdr.readUnsignedInt();
return new msg.Nfsv3ReaddirplusRequest(dir, cookie, cookieverf, dircount, maxcount);
}
decodeReaddirplusResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const dirAttributes = this.readPostOpAttr();
if (status === 0) {
const cookieverf = xdr.readOpaque(8);
const reply = this.readDirListPlus();
resok = new msg.Nfsv3ReaddirplusResOk(dirAttributes, cookieverf, reply);
}
else {
resfail = new msg.Nfsv3ReaddirplusResFail(dirAttributes);
}
return new msg.Nfsv3ReaddirplusResponse(status, resok, resfail);
}
decodeFsstatRequest() {
const fsroot = this.readFh();
return new msg.Nfsv3FsstatRequest(fsroot);
}
decodeFsstatResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const objAttributes = this.readPostOpAttr();
if (status === 0) {
const tbytes = xdr.readUnsignedHyper();
const fbytes = xdr.readUnsignedHyper();
const abytes = xdr.readUnsignedHyper();
const tfiles = xdr.readUnsignedHyper();
const ffiles = xdr.readUnsignedHyper();
const afiles = xdr.readUnsignedHyper();
const invarsec = xdr.readUnsignedInt();
resok = new msg.Nfsv3FsstatResOk(objAttributes, tbytes, fbytes, abytes, tfiles, ffiles, afiles, invarsec);
}
else {
resfail = new msg.Nfsv3FsstatResFail(objAttributes);
}
return new msg.Nfsv3FsstatResponse(status, resok, resfail);
}
decodeFsinfoRequest() {
const fsroot = this.readFh();
return new msg.Nfsv3FsinfoRequest(fsroot);
}
decodeFsinfoResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const objAttributes = this.readPostOpAttr();
if (status === 0) {
const rtmax = xdr.readUnsignedInt();
const rtpref = xdr.readUnsignedInt();
const rtmult = xdr.readUnsignedInt();
const wtmax = xdr.readUnsignedInt();
const wtpref = xdr.readUnsignedInt();
const wtmult = xdr.readUnsignedInt();
const dtpref = xdr.readUnsignedInt();
const maxfilesize = xdr.readUnsignedHyper();
const timeDelta = { seconds: xdr.readUnsignedInt(), nseconds: xdr.readUnsignedInt() };
const properties = xdr.readUnsignedInt();
resok = new msg.Nfsv3FsinfoResOk(objAttributes, rtmax, rtpref, rtmult, wtmax, wtpref, wtmult, dtpref, maxfilesize, timeDelta, properties);
}
else {
resfail = new msg.Nfsv3FsinfoResFail(objAttributes);
}
return new msg.Nfsv3FsinfoResponse(status, resok, resfail);
}
decodePathconfRequest() {
const object = this.readFh();
return new msg.Nfsv3PathconfRequest(object);
}
decodePathconfResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const objAttributes = this.readPostOpAttr();
if (status === 0) {
const linkmax = xdr.readUnsignedInt();
const namemax = xdr.readUnsignedInt();
const noTrunc = xdr.readBoolean();
const chownRestricted = xdr.readBoolean();
const caseInsensitive = xdr.readBoolean();
const casePreserving = xdr.readBoolean();
resok = new msg.Nfsv3PathconfResOk(objAttributes, linkmax, namemax, noTrunc, chownRestricted, caseInsensitive, casePreserving);
}
else {
resfail = new msg.Nfsv3PathconfResFail(objAttributes);
}
return new msg.Nfsv3PathconfResponse(status, resok, resfail);
}
decodeCommitRequest() {
const file = this.readFh();
const xdr = this.xdr;
const offset = xdr.readUnsignedHyper();
const count = xdr.readUnsignedInt();
return new msg.Nfsv3CommitRequest(file, offset, count);
}
decodeCommitResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
let resok;
let resfail;
const fileWcc = this.readWccData();
if (status === 0) {
const verf = xdr.readOpaque(8);
resok = new msg.Nfsv3CommitResOk(fileWcc, verf);
}
else {
resfail = new msg.Nfsv3CommitResFail(fileWcc);
}
return new msg.Nfsv3CommitResponse(status, resok, resfail);
}
}
exports.Nfsv3Decoder = Nfsv3Decoder;
//# sourceMappingURL=Nfsv3Decoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,80 @@
import { XdrEncoder } from '../../xdr/XdrEncoder';
import { Nfsv3Proc } from './constants';
import * as msg from './messages';
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
export declare class Nfsv3Encoder<W extends IWriter & IWriterGrowable = IWriter & IWriterGrowable> {
readonly writer: W;
protected readonly xdr: XdrEncoder;
constructor(writer?: W);
encodeMessage(message: msg.Nfsv3Message, proc: Nfsv3Proc, isRequest: boolean): Uint8Array;
writeMessage(message: msg.Nfsv3Message, proc: Nfsv3Proc, isRequest: boolean): void;
private writeRequest;
private writeResponse;
private writeFh;
private writeFilename;
private writeTime;
private writeSpecData;
private writeFattr;
private writePostOpAttr;
private writeWccAttr;
private writePreOpAttr;
private writeWccData;
private writePostOpFh;
private writeSetMode;
private writeSetUid;
private writeSetGid;
private writeSetSize;
private writeSetAtime;
private writeSetMtime;
private writeSattr;
private writeSattrGuard;
private writeDirOpArgs;
private writeCreateHow;
private writeMknodData;
private writeEntry;
private writeEntryPlus;
private writeDirList;
private writeDirListPlus;
private writeGetattrRequest;
private writeGetattrResponse;
private writeSetattrRequest;
private writeSetattrResponse;
private writeLookupRequest;
private writeLookupResponse;
private writeAccessRequest;
private writeAccessResponse;
private writeReadlinkRequest;
private writeReadlinkResponse;
private writeReadRequest;
private writeReadResponse;
private writeWriteRequest;
private writeWriteResponse;
private writeCreateRequest;
private writeCreateResponse;
private writeMkdirRequest;
private writeMkdirResponse;
private writeSymlinkRequest;
private writeSymlinkResponse;
private writeMknodRequest;
private writeMknodResponse;
private writeRemoveRequest;
private writeRemoveResponse;
private writeRmdirRequest;
private writeRmdirResponse;
private writeRenameRequest;
private writeRenameResponse;
private writeLinkRequest;
private writeLinkResponse;
private writeReaddirRequest;
private writeReaddirResponse;
private writeReaddirplusRequest;
private writeReaddirplusResponse;
private writeFsstatRequest;
private writeFsstatResponse;
private writeFsinfoRequest;
private writeFsinfoResponse;
private writePathconfRequest;
private writePathconfResponse;
private writeCommitRequest;
private writeCommitResponse;
}

View File

@@ -0,0 +1,659 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv3Encoder = void 0;
const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
const XdrEncoder_1 = require("../../xdr/XdrEncoder");
const errors_1 = require("./errors");
class Nfsv3Encoder {
constructor(writer = new Writer_1.Writer()) {
this.writer = writer;
this.xdr = new XdrEncoder_1.XdrEncoder(writer);
}
encodeMessage(message, proc, isRequest) {
if (isRequest)
this.writeRequest(message, proc);
else
this.writeResponse(message, proc);
return this.writer.flush();
}
writeMessage(message, proc, isRequest) {
if (isRequest)
this.writeRequest(message, proc);
else
this.writeResponse(message, proc);
}
writeRequest(request, proc) {
switch (proc) {
case 1:
return this.writeGetattrRequest(request);
case 2:
return this.writeSetattrRequest(request);
case 3:
return this.writeLookupRequest(request);
case 4:
return this.writeAccessRequest(request);
case 5:
return this.writeReadlinkRequest(request);
case 6:
return this.writeReadRequest(request);
case 7:
return this.writeWriteRequest(request);
case 8:
return this.writeCreateRequest(request);
case 9:
return this.writeMkdirRequest(request);
case 10:
return this.writeSymlinkRequest(request);
case 11:
return this.writeMknodRequest(request);
case 12:
return this.writeRemoveRequest(request);
case 13:
return this.writeRmdirRequest(request);
case 14:
return this.writeRenameRequest(request);
case 15:
return this.writeLinkRequest(request);
case 16:
return this.writeReaddirRequest(request);
case 17:
return this.writeReaddirplusRequest(request);
case 18:
return this.writeFsstatRequest(request);
case 19:
return this.writeFsinfoRequest(request);
case 20:
return this.writePathconfRequest(request);
case 21:
return this.writeCommitRequest(request);
default:
throw new errors_1.Nfsv3EncodingError(`Unknown procedure: ${proc}`);
}
}
writeResponse(response, proc) {
switch (proc) {
case 1:
return this.writeGetattrResponse(response);
case 2:
return this.writeSetattrResponse(response);
case 3:
return this.writeLookupResponse(response);
case 4:
return this.writeAccessResponse(response);
case 5:
return this.writeReadlinkResponse(response);
case 6:
return this.writeReadResponse(response);
case 7:
return this.writeWriteResponse(response);
case 8:
return this.writeCreateResponse(response);
case 9:
return this.writeMkdirResponse(response);
case 10:
return this.writeSymlinkResponse(response);
case 11:
return this.writeMknodResponse(response);
case 12:
return this.writeRemoveResponse(response);
case 13:
return this.writeRmdirResponse(response);
case 14:
return this.writeRenameResponse(response);
case 15:
return this.writeLinkResponse(response);
case 16:
return this.writeReaddirResponse(response);
case 17:
return this.writeReaddirplusResponse(response);
case 18:
return this.writeFsstatResponse(response);
case 19:
return this.writeFsinfoResponse(response);
case 20:
return this.writePathconfResponse(response);
case 21:
return this.writeCommitResponse(response);
default:
throw new errors_1.Nfsv3EncodingError(`Unknown procedure: ${proc}`);
}
}
writeFh(fh) {
this.xdr.writeVarlenOpaque(fh.data);
}
writeFilename(filename) {
this.xdr.writeStr(filename);
}
writeTime(time) {
const xdr = this.xdr;
xdr.writeUnsignedInt(time.seconds);
xdr.writeUnsignedInt(time.nseconds);
}
writeSpecData(spec) {
const xdr = this.xdr;
xdr.writeUnsignedInt(spec.specdata1);
xdr.writeUnsignedInt(spec.specdata2);
}
writeFattr(attr) {
const xdr = this.xdr;
xdr.writeUnsignedInt(attr.type);
xdr.writeUnsignedInt(attr.mode);
xdr.writeUnsignedInt(attr.nlink);
xdr.writeUnsignedInt(attr.uid);
xdr.writeUnsignedInt(attr.gid);
xdr.writeUnsignedHyper(attr.size);
xdr.writeUnsignedHyper(attr.used);
this.writeSpecData(attr.rdev);
xdr.writeUnsignedHyper(attr.fsid);
xdr.writeUnsignedHyper(attr.fileid);
this.writeTime(attr.atime);
this.writeTime(attr.mtime);
this.writeTime(attr.ctime);
}
writePostOpAttr(attr) {
this.xdr.writeBoolean(attr.attributesFollow);
if (attr.attributesFollow && attr.attributes) {
this.writeFattr(attr.attributes);
}
}
writeWccAttr(attr) {
this.xdr.writeUnsignedHyper(attr.size);
this.writeTime(attr.mtime);
this.writeTime(attr.ctime);
}
writePreOpAttr(attr) {
this.xdr.writeBoolean(attr.attributesFollow);
if (attr.attributesFollow && attr.attributes) {
this.writeWccAttr(attr.attributes);
}
}
writeWccData(wcc) {
this.writePreOpAttr(wcc.before);
this.writePostOpAttr(wcc.after);
}
writePostOpFh(fh) {
this.xdr.writeBoolean(fh.handleFollows);
if (fh.handleFollows && fh.handle) {
this.writeFh(fh.handle);
}
}
writeSetMode(setMode) {
const xdr = this.xdr;
xdr.writeBoolean(setMode.set);
if (setMode.set && setMode.mode !== undefined) {
xdr.writeUnsignedInt(setMode.mode);
}
}
writeSetUid(setUid) {
const xdr = this.xdr;
xdr.writeBoolean(setUid.set);
if (setUid.set && setUid.uid !== undefined) {
xdr.writeUnsignedInt(setUid.uid);
}
}
writeSetGid(setGid) {
const xdr = this.xdr;
xdr.writeBoolean(setGid.set);
if (setGid.set && setGid.gid !== undefined) {
xdr.writeUnsignedInt(setGid.gid);
}
}
writeSetSize(setSize) {
const xdr = this.xdr;
xdr.writeBoolean(setSize.set);
if (setSize.set && setSize.size !== undefined) {
xdr.writeUnsignedHyper(setSize.size);
}
}
writeSetAtime(setAtime) {
this.xdr.writeUnsignedInt(setAtime.how);
if (setAtime.how === 2 && setAtime.atime) {
this.writeTime(setAtime.atime);
}
}
writeSetMtime(setMtime) {
const xdr = this.xdr;
xdr.writeUnsignedInt(setMtime.how);
if (setMtime.how === 2 && setMtime.mtime) {
this.writeTime(setMtime.mtime);
}
}
writeSattr(sattr) {
this.writeSetMode(sattr.mode);
this.writeSetUid(sattr.uid);
this.writeSetGid(sattr.gid);
this.writeSetSize(sattr.size);
this.writeSetAtime(sattr.atime);
this.writeSetMtime(sattr.mtime);
}
writeSattrGuard(guard) {
const xdr = this.xdr;
xdr.writeBoolean(guard.check);
if (guard.check && guard.objCtime) {
this.writeTime(guard.objCtime);
}
}
writeDirOpArgs(args) {
this.writeFh(args.dir);
this.writeFilename(args.name);
}
writeCreateHow(how) {
const xdr = this.xdr;
xdr.writeUnsignedInt(how.mode);
switch (how.mode) {
case 0:
case 1:
if (how.objAttributes) {
this.writeSattr(how.objAttributes);
}
break;
case 2:
if (how.verf) {
xdr.writeOpaque(how.verf);
}
break;
}
}
writeMknodData(data) {
this.xdr.writeUnsignedInt(data.type);
switch (data.type) {
case 4:
if (data.chr) {
this.writeSattr(data.chr.devAttributes);
this.writeSpecData(data.chr.spec);
}
break;
case 3:
if (data.blk) {
this.writeSattr(data.blk.devAttributes);
this.writeSpecData(data.blk.spec);
}
break;
case 6:
if (data.sock) {
this.writeSattr(data.sock);
}
break;
case 7:
if (data.pipe) {
this.writeSattr(data.pipe);
}
break;
}
}
writeEntry(entry) {
const xdr = this.xdr;
if (!entry) {
xdr.writeBoolean(false);
return;
}
xdr.writeBoolean(true);
xdr.writeUnsignedHyper(entry.fileid);
this.writeFilename(entry.name);
xdr.writeUnsignedHyper(entry.cookie);
this.writeEntry(entry.nextentry);
}
writeEntryPlus(entry) {
const xdr = this.xdr;
if (!entry) {
xdr.writeBoolean(false);
return;
}
xdr.writeBoolean(true);
xdr.writeUnsignedHyper(entry.fileid);
this.writeFilename(entry.name);
xdr.writeUnsignedHyper(entry.cookie);
this.writePostOpAttr(entry.nameAttributes);
this.writePostOpFh(entry.nameHandle);
this.writeEntryPlus(entry.nextentry);
}
writeDirList(dirList) {
this.writeEntry(dirList.entries);
this.xdr.writeBoolean(dirList.eof);
}
writeDirListPlus(dirList) {
this.writeEntryPlus(dirList.entries);
this.xdr.writeBoolean(dirList.eof);
}
writeGetattrRequest(req) {
this.writeFh(req.object);
}
writeGetattrResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeFattr(res.resok.objAttributes);
}
}
writeSetattrRequest(req) {
this.writeFh(req.object);
this.writeSattr(req.newAttributes);
this.writeSattrGuard(req.guard);
}
writeSetattrResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeWccData(res.resok.objWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.objWcc);
}
}
writeLookupRequest(req) {
this.writeDirOpArgs(req.what);
}
writeLookupResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeFh(res.resok.object);
this.writePostOpAttr(res.resok.objAttributes);
this.writePostOpAttr(res.resok.dirAttributes);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.dirAttributes);
}
}
writeAccessRequest(req) {
this.writeFh(req.object);
this.xdr.writeUnsignedInt(req.access);
}
writeAccessResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.objAttributes);
xdr.writeUnsignedInt(res.resok.access);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.objAttributes);
}
}
writeReadlinkRequest(req) {
this.writeFh(req.symlink);
}
writeReadlinkResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.symlinkAttributes);
this.writeFilename(res.resok.data);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.symlinkAttributes);
}
}
writeReadRequest(req) {
this.writeFh(req.file);
const xdr = this.xdr;
xdr.writeUnsignedHyper(req.offset);
xdr.writeUnsignedInt(req.count);
}
writeReadResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.fileAttributes);
xdr.writeUnsignedInt(res.resok.count);
xdr.writeBoolean(res.resok.eof);
xdr.writeVarlenOpaque(res.resok.data);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.fileAttributes);
}
}
writeWriteRequest(req) {
this.writeFh(req.file);
const xdr = this.xdr;
xdr.writeUnsignedHyper(req.offset);
xdr.writeUnsignedInt(req.count);
xdr.writeUnsignedInt(req.stable);
xdr.writeVarlenOpaque(req.data);
}
writeWriteResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeWccData(res.resok.fileWcc);
xdr.writeUnsignedInt(res.resok.count);
xdr.writeUnsignedInt(res.resok.committed);
xdr.writeOpaque(res.resok.verf);
}
else if (res.resfail) {
this.writeWccData(res.resfail.fileWcc);
}
}
writeCreateRequest(req) {
this.writeDirOpArgs(req.where);
this.writeCreateHow(req.how);
}
writeCreateResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpFh(res.resok.obj);
this.writePostOpAttr(res.resok.objAttributes);
this.writeWccData(res.resok.dirWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.dirWcc);
}
}
writeMkdirRequest(req) {
this.writeDirOpArgs(req.where);
this.writeSattr(req.attributes);
}
writeMkdirResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpFh(res.resok.obj);
this.writePostOpAttr(res.resok.objAttributes);
this.writeWccData(res.resok.dirWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.dirWcc);
}
}
writeSymlinkRequest(req) {
this.writeDirOpArgs(req.where);
this.writeSattr(req.symlinkAttributes);
this.writeFilename(req.symlinkData);
}
writeSymlinkResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpFh(res.resok.obj);
this.writePostOpAttr(res.resok.objAttributes);
this.writeWccData(res.resok.dirWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.dirWcc);
}
}
writeMknodRequest(req) {
this.writeDirOpArgs(req.where);
this.writeMknodData(req.what);
}
writeMknodResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpFh(res.resok.obj);
this.writePostOpAttr(res.resok.objAttributes);
this.writeWccData(res.resok.dirWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.dirWcc);
}
}
writeRemoveRequest(req) {
this.writeDirOpArgs(req.object);
}
writeRemoveResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeWccData(res.resok.dirWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.dirWcc);
}
}
writeRmdirRequest(req) {
this.writeDirOpArgs(req.object);
}
writeRmdirResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeWccData(res.resok.dirWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.dirWcc);
}
}
writeRenameRequest(req) {
this.writeDirOpArgs(req.from);
this.writeDirOpArgs(req.to);
}
writeRenameResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeWccData(res.resok.fromDirWcc);
this.writeWccData(res.resok.toDirWcc);
}
else if (res.resfail) {
this.writeWccData(res.resfail.fromDirWcc);
this.writeWccData(res.resfail.toDirWcc);
}
}
writeLinkRequest(req) {
this.writeFh(req.file);
this.writeDirOpArgs(req.link);
}
writeLinkResponse(res) {
this.xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.fileAttributes);
this.writeWccData(res.resok.linkDirWcc);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.fileAttributes);
this.writeWccData(res.resfail.linkDirWcc);
}
}
writeReaddirRequest(req) {
this.writeFh(req.dir);
const xdr = this.xdr;
xdr.writeUnsignedHyper(req.cookie);
xdr.writeOpaque(req.cookieverf);
xdr.writeUnsignedInt(req.count);
}
writeReaddirResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.dirAttributes);
xdr.writeOpaque(res.resok.cookieverf);
this.writeDirList(res.resok.reply);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.dirAttributes);
}
}
writeReaddirplusRequest(req) {
this.writeFh(req.dir);
const xdr = this.xdr;
xdr.writeUnsignedHyper(req.cookie);
xdr.writeOpaque(req.cookieverf);
xdr.writeUnsignedInt(req.dircount);
xdr.writeUnsignedInt(req.maxcount);
}
writeReaddirplusResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.dirAttributes);
xdr.writeOpaque(res.resok.cookieverf);
this.writeDirListPlus(res.resok.reply);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.dirAttributes);
}
}
writeFsstatRequest(req) {
this.writeFh(req.fsroot);
}
writeFsstatResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.objAttributes);
xdr.writeUnsignedHyper(res.resok.tbytes);
xdr.writeUnsignedHyper(res.resok.fbytes);
xdr.writeUnsignedHyper(res.resok.abytes);
xdr.writeUnsignedHyper(res.resok.tfiles);
xdr.writeUnsignedHyper(res.resok.ffiles);
xdr.writeUnsignedHyper(res.resok.afiles);
xdr.writeUnsignedInt(res.resok.invarsec);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.objAttributes);
}
}
writeFsinfoRequest(req) {
this.writeFh(req.fsroot);
}
writeFsinfoResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.objAttributes);
xdr.writeUnsignedInt(res.resok.rtmax);
xdr.writeUnsignedInt(res.resok.rtpref);
xdr.writeUnsignedInt(res.resok.rtmult);
xdr.writeUnsignedInt(res.resok.wtmax);
xdr.writeUnsignedInt(res.resok.wtpref);
xdr.writeUnsignedInt(res.resok.wtmult);
xdr.writeUnsignedInt(res.resok.dtpref);
xdr.writeUnsignedHyper(res.resok.maxfilesize);
xdr.writeUnsignedInt(res.resok.timeDelta.seconds);
xdr.writeUnsignedInt(res.resok.timeDelta.nseconds);
xdr.writeUnsignedInt(res.resok.properties);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.objAttributes);
}
}
writePathconfRequest(req) {
this.writeFh(req.object);
}
writePathconfResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writePostOpAttr(res.resok.objAttributes);
xdr.writeUnsignedInt(res.resok.linkmax);
xdr.writeUnsignedInt(res.resok.namemax);
xdr.writeBoolean(res.resok.noTrunc);
xdr.writeBoolean(res.resok.chownRestricted);
xdr.writeBoolean(res.resok.caseInsensitive);
xdr.writeBoolean(res.resok.casePreserving);
}
else if (res.resfail) {
this.writePostOpAttr(res.resfail.objAttributes);
}
}
writeCommitRequest(req) {
this.writeFh(req.file);
const xdr = this.xdr;
xdr.writeUnsignedHyper(req.offset);
xdr.writeUnsignedInt(req.count);
}
writeCommitResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.resok) {
this.writeWccData(res.resok.fileWcc);
xdr.writeOpaque(res.resok.verf);
}
else if (res.resfail) {
this.writeWccData(res.resfail.fileWcc);
}
}
}
exports.Nfsv3Encoder = Nfsv3Encoder;
//# sourceMappingURL=Nfsv3Encoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,115 @@
export declare const enum Nfsv3Const {
PROGRAM = 100003,
VERSION = 3,
FHSIZE = 64,
COOKIEVERFSIZE = 8,
CREATEVERFSIZE = 8,
WRITEVERFSIZE = 8
}
export declare const enum Nfsv3Proc {
NULL = 0,
GETATTR = 1,
SETATTR = 2,
LOOKUP = 3,
ACCESS = 4,
READLINK = 5,
READ = 6,
WRITE = 7,
CREATE = 8,
MKDIR = 9,
SYMLINK = 10,
MKNOD = 11,
REMOVE = 12,
RMDIR = 13,
RENAME = 14,
LINK = 15,
READDIR = 16,
READDIRPLUS = 17,
FSSTAT = 18,
FSINFO = 19,
PATHCONF = 20,
COMMIT = 21
}
export declare const enum Nfsv3Stat {
NFS3_OK = 0,
NFS3ERR_PERM = 1,
NFS3ERR_NOENT = 2,
NFS3ERR_IO = 5,
NFS3ERR_NXIO = 6,
NFS3ERR_ACCES = 13,
NFS3ERR_EXIST = 17,
NFS3ERR_XDEV = 18,
NFS3ERR_NODEV = 19,
NFS3ERR_NOTDIR = 20,
NFS3ERR_ISDIR = 21,
NFS3ERR_INVAL = 22,
NFS3ERR_FBIG = 27,
NFS3ERR_NOSPC = 28,
NFS3ERR_ROFS = 30,
NFS3ERR_MLINK = 31,
NFS3ERR_NAMETOOLONG = 63,
NFS3ERR_NOTEMPTY = 66,
NFS3ERR_DQUOT = 69,
NFS3ERR_STALE = 70,
NFS3ERR_REMOTE = 71,
NFS3ERR_BADHANDLE = 10001,
NFS3ERR_NOT_SYNC = 10002,
NFS3ERR_BAD_COOKIE = 10003,
NFS3ERR_NOTSUPP = 10004,
NFS3ERR_TOOSMALL = 10005,
NFS3ERR_SERVERFAULT = 10006,
NFS3ERR_BADTYPE = 10007,
NFS3ERR_JUKEBOX = 10008
}
export declare const enum Nfsv3FType {
NF3REG = 1,
NF3DIR = 2,
NF3BLK = 3,
NF3CHR = 4,
NF3LNK = 5,
NF3SOCK = 6,
NF3FIFO = 7
}
export declare const enum Nfsv3TimeHow {
DONT_CHANGE = 0,
SET_TO_SERVER_TIME = 1,
SET_TO_CLIENT_TIME = 2
}
export declare const enum Nfsv3StableHow {
UNSTABLE = 0,
DATA_SYNC = 1,
FILE_SYNC = 2
}
export declare const enum Nfsv3CreateMode {
UNCHECKED = 0,
GUARDED = 1,
EXCLUSIVE = 2
}
export declare const enum Nfsv3Access {
READ = 1,
LOOKUP = 2,
MODIFY = 4,
EXTEND = 8,
DELETE = 16,
EXECUTE = 32
}
export declare const enum Nfsv3Mode {
SUID = 2048,
SGID = 1024,
SVTX = 512,
RUSR = 256,
WUSR = 128,
XUSR = 64,
RGRP = 32,
WGRP = 16,
XGRP = 8,
ROTH = 4,
WOTH = 2,
XOTH = 1
}
export declare const enum Nfsv3Fsf {
LINK = 1,
SYMLINK = 2,
HOMOGENEOUS = 8,
CANSETTIME = 16
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/nfs/v3/constants.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
export declare class Nfsv3DecodingError extends Error {
constructor(message?: string);
}
export declare class Nfsv3EncodingError extends Error {
constructor(message?: string);
}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv3EncodingError = exports.Nfsv3DecodingError = void 0;
class Nfsv3DecodingError extends Error {
constructor(message) {
super(message ? 'NFSv3_DECODING: ' + message : 'NFSv3_DECODING');
}
}
exports.Nfsv3DecodingError = Nfsv3DecodingError;
class Nfsv3EncodingError extends Error {
constructor(message) {
super(message ? 'NFSv3_ENCODING: ' + message : 'NFSv3_ENCODING');
}
}
exports.Nfsv3EncodingError = Nfsv3EncodingError;
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/nfs/v3/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACnE,CAAC;CACF;AAJD,gDAIC;AAED,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACnE,CAAC;CACF;AAJD,gDAIC"}

View File

@@ -0,0 +1,6 @@
export * from './constants';
export * from './structs';
export * from './messages';
export * from './Nfsv3Decoder';
export * from './Nfsv3Encoder';
export * from './FullNfsv3Encoder';

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./constants"), exports);
tslib_1.__exportStar(require("./structs"), exports);
tslib_1.__exportStar(require("./messages"), exports);
tslib_1.__exportStar(require("./Nfsv3Decoder"), exports);
tslib_1.__exportStar(require("./Nfsv3Encoder"), exports);
tslib_1.__exportStar(require("./FullNfsv3Encoder"), exports);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nfs/v3/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,oDAA0B;AAC1B,qDAA2B;AAC3B,yDAA+B;AAC/B,yDAA+B;AAC/B,6DAAmC"}

View File

@@ -0,0 +1,33 @@
import { Reader } from '@jsonjoy.com/buffers/lib/Reader';
import { XdrDecoder } from '../../../xdr/XdrDecoder';
import { NlmProc } from './constants';
import * as msg from './messages';
export declare class NlmDecoder {
protected readonly xdr: XdrDecoder;
constructor(reader?: Reader);
decodeMessage(reader: Reader, proc: NlmProc, isRequest: boolean): msg.NlmMessage | undefined;
private decodeRequest;
private decodeResponse;
private readCookie;
private readNetobj;
private readNlm4Holder;
private readNlm4Lock;
private readNlm4Share;
private readTestArgs;
private readLockArgs;
private readCancelArgs;
private readUnlockArgs;
private readShareArgs;
private decodeTestRequest;
private decodeTestResponse;
private decodeLockRequest;
private decodeResponse4;
private decodeCancelRequest;
private decodeUnlockRequest;
private decodeGrantedRequest;
private decodeShareRequest;
private decodeShareResponse;
private decodeUnshareRequest;
private decodeNmLockRequest;
private decodeFreeAllRequest;
}

View File

@@ -0,0 +1,209 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NlmDecoder = void 0;
const tslib_1 = require("tslib");
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
const XdrDecoder_1 = require("../../../xdr/XdrDecoder");
const errors_1 = require("../errors");
const msg = tslib_1.__importStar(require("./messages"));
const structs = tslib_1.__importStar(require("./structs"));
class NlmDecoder {
constructor(reader = new Reader_1.Reader()) {
this.xdr = new XdrDecoder_1.XdrDecoder(reader);
}
decodeMessage(reader, proc, isRequest) {
this.xdr.reader = reader;
const startPos = reader.x;
try {
if (isRequest) {
return this.decodeRequest(proc);
}
else {
return this.decodeResponse(proc);
}
}
catch (err) {
if (err instanceof RangeError) {
reader.x = startPos;
return undefined;
}
throw err;
}
}
decodeRequest(proc) {
switch (proc) {
case 0:
return undefined;
case 1:
return this.decodeTestRequest();
case 2:
return this.decodeLockRequest();
case 3:
return this.decodeCancelRequest();
case 4:
return this.decodeUnlockRequest();
case 5:
return this.decodeGrantedRequest();
case 20:
return this.decodeShareRequest();
case 21:
return this.decodeUnshareRequest();
case 22:
return this.decodeNmLockRequest();
case 23:
return this.decodeFreeAllRequest();
default:
throw new errors_1.Nfsv3DecodingError(`Unknown NLM procedure: ${proc}`);
}
}
decodeResponse(proc) {
switch (proc) {
case 0:
return undefined;
case 1:
return this.decodeTestResponse();
case 2:
case 3:
case 4:
case 5:
case 22:
return this.decodeResponse4();
case 20:
case 21:
return this.decodeShareResponse();
default:
throw new errors_1.Nfsv3DecodingError(`Unknown NLM procedure: ${proc}`);
}
}
readCookie() {
const data = this.xdr.readVarlenOpaque();
return new Reader_1.Reader(data);
}
readNetobj() {
const data = this.xdr.readVarlenOpaque();
return new Reader_1.Reader(data);
}
readNlm4Holder() {
const xdr = this.xdr;
const exclusive = xdr.readBoolean();
const svid = xdr.readInt();
const oh = this.readNetobj();
const offset = xdr.readUnsignedHyper();
const length = xdr.readUnsignedHyper();
return new structs.Nlm4Holder(exclusive, svid, oh, offset, length);
}
readNlm4Lock() {
const xdr = this.xdr;
const callerName = xdr.readString();
const fh = this.readNetobj();
const oh = this.readNetobj();
const svid = xdr.readInt();
const offset = xdr.readUnsignedHyper();
const length = xdr.readUnsignedHyper();
return new structs.Nlm4Lock(callerName, fh, oh, svid, offset, length);
}
readNlm4Share() {
const xdr = this.xdr;
const callerName = xdr.readString();
const fh = this.readNetobj();
const oh = this.readNetobj();
const mode = xdr.readUnsignedInt();
const access = xdr.readUnsignedInt();
return new structs.Nlm4Share(callerName, fh, oh, mode, access);
}
readTestArgs() {
const cookie = this.readCookie();
const exclusive = this.xdr.readBoolean();
const lock = this.readNlm4Lock();
return new msg.Nlm4TestArgs(cookie, exclusive, lock);
}
readLockArgs() {
const xdr = this.xdr;
const cookie = this.readCookie();
const block = xdr.readBoolean();
const exclusive = xdr.readBoolean();
const lock = this.readNlm4Lock();
const reclaim = xdr.readBoolean();
const state = xdr.readInt();
return new msg.Nlm4LockArgs(cookie, block, exclusive, lock, reclaim, state);
}
readCancelArgs() {
const xdr = this.xdr;
const cookie = this.readCookie();
const block = xdr.readBoolean();
const exclusive = xdr.readBoolean();
const lock = this.readNlm4Lock();
return new msg.Nlm4CancelArgs(cookie, block, exclusive, lock);
}
readUnlockArgs() {
const cookie = this.readCookie();
const lock = this.readNlm4Lock();
return new msg.Nlm4UnlockArgs(cookie, lock);
}
readShareArgs() {
const cookie = this.readCookie();
const share = this.readNlm4Share();
const reclaim = this.xdr.readBoolean();
return new msg.Nlm4ShareArgs(cookie, share, reclaim);
}
decodeTestRequest() {
const args = this.readTestArgs();
return new msg.Nlm4TestRequest(args);
}
decodeTestResponse() {
const xdr = this.xdr;
const cookie = this.readCookie();
const stat = xdr.readUnsignedInt();
const holder = stat === 1 ? this.readNlm4Holder() : undefined;
return new msg.Nlm4TestResponse(cookie, stat, holder);
}
decodeLockRequest() {
const args = this.readLockArgs();
return new msg.Nlm4LockRequest(args);
}
decodeResponse4() {
const cookie = this.readCookie();
const stat = this.xdr.readUnsignedInt();
return new msg.Nlm4Response(cookie, stat);
}
decodeCancelRequest() {
const args = this.readCancelArgs();
return new msg.Nlm4CancelRequest(args);
}
decodeUnlockRequest() {
const args = this.readUnlockArgs();
return new msg.Nlm4UnlockRequest(args);
}
decodeGrantedRequest() {
const args = this.readTestArgs();
return new msg.Nlm4GrantedRequest(args);
}
decodeShareRequest() {
const args = this.readShareArgs();
return new msg.Nlm4ShareRequest(args);
}
decodeShareResponse() {
const xdr = this.xdr;
const cookie = this.readCookie();
const stat = xdr.readUnsignedInt();
const sequence = xdr.readInt();
return new msg.Nlm4ShareResponse(cookie, stat, sequence);
}
decodeUnshareRequest() {
const args = this.readShareArgs();
return new msg.Nlm4UnshareRequest(args);
}
decodeNmLockRequest() {
const args = this.readLockArgs();
return new msg.Nlm4NmLockRequest(args);
}
decodeFreeAllRequest() {
const xdr = this.xdr;
const name = xdr.readString();
const state = xdr.readInt();
const notify = new structs.Nlm4Notify(name, state);
return new msg.Nlm4FreeAllRequest(notify);
}
}
exports.NlmDecoder = NlmDecoder;
//# sourceMappingURL=NlmDecoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,35 @@
import { XdrEncoder } from '../../../xdr/XdrEncoder';
import { NlmProc } from './constants';
import * as msg from './messages';
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
export declare class NlmEncoder<W extends IWriter & IWriterGrowable = IWriter & IWriterGrowable> {
readonly writer: W;
protected readonly xdr: XdrEncoder;
constructor(writer?: W);
encodeMessage(message: msg.NlmMessage, proc: NlmProc, isRequest: boolean): Uint8Array;
writeMessage(message: msg.NlmMessage, proc: NlmProc, isRequest: boolean): void;
private writeRequest;
private writeResponse;
private writeCookie;
private writeNetobj;
private writeNlm4Holder;
private writeNlm4Lock;
private writeNlm4Share;
private writeTestArgs;
private writeLockArgs;
private writeCancelArgs;
private writeUnlockArgs;
private writeShareArgs;
private writeTestRequest;
private writeTestResponse;
private writeLockRequest;
private writeResponse4;
private writeCancelRequest;
private writeUnlockRequest;
private writeGrantedRequest;
private writeShareRequest;
private writeShareResponse;
private writeUnshareRequest;
private writeNmLockRequest;
private writeFreeAllRequest;
}

View File

@@ -0,0 +1,182 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NlmEncoder = void 0;
const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
const XdrEncoder_1 = require("../../../xdr/XdrEncoder");
const errors_1 = require("../errors");
class NlmEncoder {
constructor(writer = new Writer_1.Writer()) {
this.writer = writer;
this.xdr = new XdrEncoder_1.XdrEncoder(writer);
}
encodeMessage(message, proc, isRequest) {
if (isRequest)
this.writeRequest(message, proc);
else
this.writeResponse(message, proc);
return this.writer.flush();
}
writeMessage(message, proc, isRequest) {
if (isRequest)
this.writeRequest(message, proc);
else
this.writeResponse(message, proc);
}
writeRequest(request, proc) {
switch (proc) {
case 0:
return;
case 1:
return this.writeTestRequest(request);
case 2:
return this.writeLockRequest(request);
case 3:
return this.writeCancelRequest(request);
case 4:
return this.writeUnlockRequest(request);
case 5:
return this.writeGrantedRequest(request);
case 20:
return this.writeShareRequest(request);
case 21:
return this.writeUnshareRequest(request);
case 22:
return this.writeNmLockRequest(request);
case 23:
return this.writeFreeAllRequest(request);
default:
throw new errors_1.Nfsv3EncodingError(`Unknown NLM procedure: ${proc}`);
}
}
writeResponse(response, proc) {
switch (proc) {
case 0:
return;
case 1:
return this.writeTestResponse(response);
case 2:
case 3:
case 4:
case 5:
case 22:
return this.writeResponse4(response);
case 20:
case 21:
return this.writeShareResponse(response);
default:
throw new errors_1.Nfsv3EncodingError(`Unknown NLM procedure: ${proc}`);
}
}
writeCookie(cookie) {
const data = cookie.uint8;
this.xdr.writeVarlenOpaque(data);
}
writeNetobj(obj) {
const data = obj.uint8;
this.xdr.writeVarlenOpaque(data);
}
writeNlm4Holder(holder) {
const xdr = this.xdr;
xdr.writeBoolean(holder.exclusive);
xdr.writeInt(holder.svid);
this.writeNetobj(holder.oh);
xdr.writeUnsignedHyper(holder.offset);
xdr.writeUnsignedHyper(holder.length);
}
writeNlm4Lock(lock) {
const xdr = this.xdr;
xdr.writeStr(lock.callerName);
this.writeNetobj(lock.fh);
this.writeNetobj(lock.oh);
xdr.writeInt(lock.svid);
xdr.writeUnsignedHyper(lock.offset);
xdr.writeUnsignedHyper(lock.length);
}
writeNlm4Share(share) {
const xdr = this.xdr;
xdr.writeStr(share.callerName);
this.writeNetobj(share.fh);
this.writeNetobj(share.oh);
xdr.writeUnsignedInt(share.mode);
xdr.writeUnsignedInt(share.access);
}
writeTestArgs(args) {
this.writeCookie(args.cookie);
this.xdr.writeBoolean(args.exclusive);
this.writeNlm4Lock(args.lock);
}
writeLockArgs(args) {
const xdr = this.xdr;
this.writeCookie(args.cookie);
xdr.writeBoolean(args.block);
xdr.writeBoolean(args.exclusive);
this.writeNlm4Lock(args.lock);
xdr.writeBoolean(args.reclaim);
xdr.writeInt(args.state);
}
writeCancelArgs(args) {
const xdr = this.xdr;
this.writeCookie(args.cookie);
xdr.writeBoolean(args.block);
xdr.writeBoolean(args.exclusive);
this.writeNlm4Lock(args.lock);
}
writeUnlockArgs(args) {
this.writeCookie(args.cookie);
this.writeNlm4Lock(args.lock);
}
writeShareArgs(args) {
this.writeCookie(args.cookie);
this.writeNlm4Share(args.share);
this.xdr.writeBoolean(args.reclaim);
}
writeTestRequest(req) {
this.writeTestArgs(req.args);
}
writeTestResponse(res) {
const xdr = this.xdr;
this.writeCookie(res.cookie);
xdr.writeUnsignedInt(res.stat);
if (res.stat === 1 && res.holder) {
this.writeNlm4Holder(res.holder);
}
}
writeLockRequest(req) {
this.writeLockArgs(req.args);
}
writeResponse4(res) {
this.writeCookie(res.cookie);
this.xdr.writeUnsignedInt(res.stat);
}
writeCancelRequest(req) {
this.writeCancelArgs(req.args);
}
writeUnlockRequest(req) {
this.writeUnlockArgs(req.args);
}
writeGrantedRequest(req) {
this.writeTestArgs(req.args);
}
writeShareRequest(req) {
this.writeShareArgs(req.args);
}
writeShareResponse(res) {
const xdr = this.xdr;
this.writeCookie(res.cookie);
xdr.writeUnsignedInt(res.stat);
xdr.writeInt(res.sequence);
}
writeUnshareRequest(req) {
this.writeShareArgs(req.args);
}
writeNmLockRequest(req) {
this.writeLockArgs(req.args);
}
writeFreeAllRequest(req) {
const xdr = this.xdr;
xdr.writeStr(req.notify.name);
xdr.writeInt(req.notify.state);
}
}
exports.NlmEncoder = NlmEncoder;
//# sourceMappingURL=NlmEncoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,39 @@
export declare const enum NlmConst {
PROGRAM = 100021,
VERSION = 4,
LM_MAXSTRLEN = 1024
}
export declare const enum NlmProc {
NULL = 0,
TEST = 1,
LOCK = 2,
CANCEL = 3,
UNLOCK = 4,
GRANTED = 5,
TEST_MSG = 6,
LOCK_MSG = 7,
CANCEL_MSG = 8,
UNLOCK_MSG = 9,
GRANTED_MSG = 10,
TEST_RES = 11,
LOCK_RES = 12,
CANCEL_RES = 13,
UNLOCK_RES = 14,
GRANTED_RES = 15,
SHARE = 20,
UNSHARE = 21,
NM_LOCK = 22,
FREE_ALL = 23
}
export declare const enum Nlm4Stat {
NLM4_GRANTED = 0,
NLM4_DENIED = 1,
NLM4_DENIED_NOLOCKS = 2,
NLM4_BLOCKED = 3,
NLM4_DENIED_GRACE_PERIOD = 4,
NLM4_DEADLCK = 5,
NLM4_ROFS = 6,
NLM4_STALE_FH = 7,
NLM4_FBIG = 8,
NLM4_FAILED = 9
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/nfs/v3/locks/constants.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,96 @@
import { Nlm4Stat } from './constants';
import type { Reader } from '@jsonjoy.com/buffers/lib/Reader';
import type * as stucts from './structs';
export type NlmMessage = NlmRequest | NlmResponse;
export type NlmRequest = Nlm4TestRequest | Nlm4LockRequest | Nlm4CancelRequest | Nlm4UnlockRequest | Nlm4GrantedRequest | Nlm4ShareRequest | Nlm4UnshareRequest | Nlm4NmLockRequest | Nlm4FreeAllRequest;
export type NlmResponse = Nlm4TestResponse | Nlm4Response | Nlm4ShareResponse;
export declare class Nlm4TestArgs {
readonly cookie: Reader;
readonly exclusive: boolean;
readonly lock: stucts.Nlm4Lock;
constructor(cookie: Reader, exclusive: boolean, lock: stucts.Nlm4Lock);
}
export declare class Nlm4TestRequest {
readonly args: Nlm4TestArgs;
constructor(args: Nlm4TestArgs);
}
export declare class Nlm4TestDenied {
readonly holder: stucts.Nlm4Holder;
constructor(holder: stucts.Nlm4Holder);
}
export declare class Nlm4TestResponse {
readonly cookie: Reader;
readonly stat: Nlm4Stat;
readonly holder?: stucts.Nlm4Holder | undefined;
constructor(cookie: Reader, stat: Nlm4Stat, holder?: stucts.Nlm4Holder | undefined);
}
export declare class Nlm4LockArgs {
readonly cookie: Reader;
readonly block: boolean;
readonly exclusive: boolean;
readonly lock: stucts.Nlm4Lock;
readonly reclaim: boolean;
readonly state: number;
constructor(cookie: Reader, block: boolean, exclusive: boolean, lock: stucts.Nlm4Lock, reclaim: boolean, state: number);
}
export declare class Nlm4LockRequest {
readonly args: Nlm4LockArgs;
constructor(args: Nlm4LockArgs);
}
export declare class Nlm4Response {
readonly cookie: Reader;
readonly stat: Nlm4Stat;
constructor(cookie: Reader, stat: Nlm4Stat);
}
export declare class Nlm4CancelArgs {
readonly cookie: Reader;
readonly block: boolean;
readonly exclusive: boolean;
readonly lock: stucts.Nlm4Lock;
constructor(cookie: Reader, block: boolean, exclusive: boolean, lock: stucts.Nlm4Lock);
}
export declare class Nlm4CancelRequest {
readonly args: Nlm4CancelArgs;
constructor(args: Nlm4CancelArgs);
}
export declare class Nlm4UnlockArgs {
readonly cookie: Reader;
readonly lock: stucts.Nlm4Lock;
constructor(cookie: Reader, lock: stucts.Nlm4Lock);
}
export declare class Nlm4UnlockRequest {
readonly args: Nlm4UnlockArgs;
constructor(args: Nlm4UnlockArgs);
}
export declare class Nlm4GrantedRequest {
readonly args: Nlm4TestArgs;
constructor(args: Nlm4TestArgs);
}
export declare class Nlm4ShareArgs {
readonly cookie: Reader;
readonly share: stucts.Nlm4Share;
readonly reclaim: boolean;
constructor(cookie: Reader, share: stucts.Nlm4Share, reclaim: boolean);
}
export declare class Nlm4ShareRequest {
readonly args: Nlm4ShareArgs;
constructor(args: Nlm4ShareArgs);
}
export declare class Nlm4ShareResponse {
readonly cookie: Reader;
readonly stat: Nlm4Stat;
readonly sequence: number;
constructor(cookie: Reader, stat: Nlm4Stat, sequence: number);
}
export declare class Nlm4UnshareRequest {
readonly args: Nlm4ShareArgs;
constructor(args: Nlm4ShareArgs);
}
export declare class Nlm4NmLockRequest {
readonly args: Nlm4LockArgs;
constructor(args: Nlm4LockArgs);
}
export declare class Nlm4FreeAllRequest {
readonly notify: stucts.Nlm4Notify;
constructor(notify: stucts.Nlm4Notify);
}

View File

@@ -0,0 +1,130 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nlm4FreeAllRequest = exports.Nlm4NmLockRequest = exports.Nlm4UnshareRequest = exports.Nlm4ShareResponse = exports.Nlm4ShareRequest = exports.Nlm4ShareArgs = exports.Nlm4GrantedRequest = exports.Nlm4UnlockRequest = exports.Nlm4UnlockArgs = exports.Nlm4CancelRequest = exports.Nlm4CancelArgs = exports.Nlm4Response = exports.Nlm4LockRequest = exports.Nlm4LockArgs = exports.Nlm4TestResponse = exports.Nlm4TestDenied = exports.Nlm4TestRequest = exports.Nlm4TestArgs = void 0;
class Nlm4TestArgs {
constructor(cookie, exclusive, lock) {
this.cookie = cookie;
this.exclusive = exclusive;
this.lock = lock;
}
}
exports.Nlm4TestArgs = Nlm4TestArgs;
class Nlm4TestRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4TestRequest = Nlm4TestRequest;
class Nlm4TestDenied {
constructor(holder) {
this.holder = holder;
}
}
exports.Nlm4TestDenied = Nlm4TestDenied;
class Nlm4TestResponse {
constructor(cookie, stat, holder) {
this.cookie = cookie;
this.stat = stat;
this.holder = holder;
}
}
exports.Nlm4TestResponse = Nlm4TestResponse;
class Nlm4LockArgs {
constructor(cookie, block, exclusive, lock, reclaim, state) {
this.cookie = cookie;
this.block = block;
this.exclusive = exclusive;
this.lock = lock;
this.reclaim = reclaim;
this.state = state;
}
}
exports.Nlm4LockArgs = Nlm4LockArgs;
class Nlm4LockRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4LockRequest = Nlm4LockRequest;
class Nlm4Response {
constructor(cookie, stat) {
this.cookie = cookie;
this.stat = stat;
}
}
exports.Nlm4Response = Nlm4Response;
class Nlm4CancelArgs {
constructor(cookie, block, exclusive, lock) {
this.cookie = cookie;
this.block = block;
this.exclusive = exclusive;
this.lock = lock;
}
}
exports.Nlm4CancelArgs = Nlm4CancelArgs;
class Nlm4CancelRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4CancelRequest = Nlm4CancelRequest;
class Nlm4UnlockArgs {
constructor(cookie, lock) {
this.cookie = cookie;
this.lock = lock;
}
}
exports.Nlm4UnlockArgs = Nlm4UnlockArgs;
class Nlm4UnlockRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4UnlockRequest = Nlm4UnlockRequest;
class Nlm4GrantedRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4GrantedRequest = Nlm4GrantedRequest;
class Nlm4ShareArgs {
constructor(cookie, share, reclaim) {
this.cookie = cookie;
this.share = share;
this.reclaim = reclaim;
}
}
exports.Nlm4ShareArgs = Nlm4ShareArgs;
class Nlm4ShareRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4ShareRequest = Nlm4ShareRequest;
class Nlm4ShareResponse {
constructor(cookie, stat, sequence) {
this.cookie = cookie;
this.stat = stat;
this.sequence = sequence;
}
}
exports.Nlm4ShareResponse = Nlm4ShareResponse;
class Nlm4UnshareRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4UnshareRequest = Nlm4UnshareRequest;
class Nlm4NmLockRequest {
constructor(args) {
this.args = args;
}
}
exports.Nlm4NmLockRequest = Nlm4NmLockRequest;
class Nlm4FreeAllRequest {
constructor(notify) {
this.notify = notify;
}
}
exports.Nlm4FreeAllRequest = Nlm4FreeAllRequest;
//# sourceMappingURL=messages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"messages.js","sourceRo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IAC5B,YAA4B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;CACnD;AAFD,8CAEC;AAKD,MAAa,kBAAkB;IAC7B,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;CAC1D;AAFD,gDAEC"}

View File

@@ -0,0 +1,31 @@
import type { Reader } from '@jsonjoy.com/buffers/lib/Reader';
export declare class Nlm4Holder {
readonly exclusive: boolean;
readonly svid: number;
readonly oh: Reader;
readonly offset: bigint;
readonly length: bigint;
constructor(exclusive: boolean, svid: number, oh: Reader, offset: bigint, length: bigint);
}
export declare class Nlm4Lock {
readonly callerName: string;
readonly fh: Reader;
readonly oh: Reader;
readonly svid: number;
readonly offset: bigint;
readonly length: bigint;
constructor(callerName: string, fh: Reader, oh: Reader, svid: number, offset: bigint, length: bigint);
}
export declare class Nlm4Share {
readonly callerName: string;
readonly fh: Reader;
readonly oh: Reader;
readonly mode: number;
readonly access: number;
constructor(callerName: string, fh: Reader, oh: Reader, mode: number, access: number);
}
export declare class Nlm4Notify {
readonly name: string;
readonly state: number;
constructor(name: string, state: number);
}

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nlm4Notify = exports.Nlm4Share = exports.Nlm4Lock = exports.Nlm4Holder = void 0;
class Nlm4Holder {
constructor(exclusive, svid, oh, offset, length) {
this.exclusive = exclusive;
this.svid = svid;
this.oh = oh;
this.offset = offset;
this.length = length;
}
}
exports.Nlm4Holder = Nlm4Holder;
class Nlm4Lock {
constructor(callerName, fh, oh, svid, offset, length) {
this.callerName = callerName;
this.fh = fh;
this.oh = oh;
this.svid = svid;
this.offset = offset;
this.length = length;
}
}
exports.Nlm4Lock = Nlm4Lock;
class Nlm4Share {
constructor(callerName, fh, oh, mode, access) {
this.callerName = callerName;
this.fh = fh;
this.oh = oh;
this.mode = mode;
this.access = access;
}
}
exports.Nlm4Share = Nlm4Share;
class Nlm4Notify {
constructor(name, state) {
this.name = name;
this.state = state;
}
}
exports.Nlm4Notify = Nlm4Notify;
//# sourceMappingURL=structs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../src/nfs/v3/locks/structs.ts"],"names":[],"mappings":";;;AASA,MAAa,UAAU;IACrB,YACkB,SAAkB,EAClB,IAAY,EACZ,EAAU,EACV,MAAc,EACd,MAAc;QAJd,cAAS,GAAT,SAAS,CAAS;QAClB,SAAI,GAAJ,IAAI,CAAQ;QACZ,OAAE,GAAF,EAAE,CAAQ;QACV,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;IAC7B,CAAC;CACL;AARD,gCAQC;AAKD,MAAa,QAAQ;IACnB,YACkB,UAAkB,EAClB,EAAU,EACV,EAAU,EACV,IAAY,EACZ,MAAc,EACd,MAAc;QALd,eAAU,GAAV,UAAU,CAAQ;QAClB,OAAE,GAAF,EAAE,CAAQ;QACV,OAAE,GAAF,EAAE,CAAQ;QACV,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;IAC7B,CAAC;CACL;AATD,4BASC;AAKD,MAAa,SAAS;IACpB,YACkB,UAAkB,EAClB,EAAU,EACV,EAAU,EACV,IAAY,EACZ,MAAc;QAJd,eAAU,GAAV,UAAU,CAAQ;QAClB,OAAE,GAAF,EAAE,CAAQ;QACV,OAAE,GAAF,EAAE,CAAQ;QACV,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;IAC7B,CAAC;CACL;AARD,8BAQC;AAKD,MAAa,UAAU;IACrB,YACkB,IAAY,EACZ,KAAa;QADb,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;IAC5B,CAAC;CACL;AALD,gCAKC"}

View File

@@ -0,0 +1,459 @@
import type { Nfsv3Stat } from './constants';
import type * as stucts from './structs';
export type Nfsv3Message = Nfsv3Request | Nfsv3Response;
export type Nfsv3Request = Nfsv3GetattrRequest | Nfsv3SetattrRequest | Nfsv3LookupRequest | Nfsv3AccessRequest | Nfsv3ReadlinkRequest | Nfsv3ReadRequest | Nfsv3WriteRequest | Nfsv3CreateRequest | Nfsv3MkdirRequest | Nfsv3SymlinkRequest | Nfsv3MknodRequest | Nfsv3RemoveRequest | Nfsv3RmdirRequest | Nfsv3RenameRequest | Nfsv3LinkRequest | Nfsv3ReaddirRequest | Nfsv3ReaddirplusRequest | Nfsv3FsstatRequest | Nfsv3FsinfoRequest | Nfsv3PathconfRequest | Nfsv3CommitRequest;
export type Nfsv3Response = Nfsv3GetattrResponse | Nfsv3SetattrResponse | Nfsv3LookupResponse | Nfsv3AccessResponse | Nfsv3ReadlinkResponse | Nfsv3ReadResponse | Nfsv3WriteResponse | Nfsv3CreateResponse | Nfsv3MkdirResponse | Nfsv3SymlinkResponse | Nfsv3MknodResponse | Nfsv3RemoveResponse | Nfsv3RmdirResponse | Nfsv3RenameResponse | Nfsv3LinkResponse | Nfsv3ReaddirResponse | Nfsv3ReaddirplusResponse | Nfsv3FsstatResponse | Nfsv3FsinfoResponse | Nfsv3PathconfResponse | Nfsv3CommitResponse;
export declare class Nfsv3GetattrRequest {
readonly object: stucts.Nfsv3Fh;
constructor(object: stucts.Nfsv3Fh);
}
export declare class Nfsv3GetattrResOk {
readonly objAttributes: stucts.Nfsv3Fattr;
constructor(objAttributes: stucts.Nfsv3Fattr);
}
export declare class Nfsv3GetattrResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3GetattrResOk | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3GetattrResOk | undefined);
}
export declare class Nfsv3SetattrRequest {
readonly object: stucts.Nfsv3Fh;
readonly newAttributes: stucts.Nfsv3Sattr;
readonly guard: stucts.Nfsv3SattrGuard;
constructor(object: stucts.Nfsv3Fh, newAttributes: stucts.Nfsv3Sattr, guard: stucts.Nfsv3SattrGuard);
}
export declare class Nfsv3SetattrResOk {
readonly objWcc: stucts.Nfsv3WccData;
constructor(objWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3SetattrResFail {
readonly objWcc: stucts.Nfsv3WccData;
constructor(objWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3SetattrResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3SetattrResOk | undefined;
readonly resfail?: Nfsv3SetattrResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3SetattrResOk | undefined, resfail?: Nfsv3SetattrResFail | undefined);
}
export declare class Nfsv3LookupRequest {
readonly what: stucts.Nfsv3DirOpArgs;
constructor(what: stucts.Nfsv3DirOpArgs);
}
export declare class Nfsv3LookupResOk {
readonly object: stucts.Nfsv3Fh;
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly dirAttributes: stucts.Nfsv3PostOpAttr;
constructor(object: stucts.Nfsv3Fh, objAttributes: stucts.Nfsv3PostOpAttr, dirAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3LookupResFail {
readonly dirAttributes: stucts.Nfsv3PostOpAttr;
constructor(dirAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3LookupResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3LookupResOk | undefined;
readonly resfail?: Nfsv3LookupResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3LookupResOk | undefined, resfail?: Nfsv3LookupResFail | undefined);
}
export declare class Nfsv3AccessRequest {
readonly object: stucts.Nfsv3Fh;
readonly access: number;
constructor(object: stucts.Nfsv3Fh, access: number);
}
export declare class Nfsv3AccessResOk {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly access: number;
constructor(objAttributes: stucts.Nfsv3PostOpAttr, access: number);
}
export declare class Nfsv3AccessResFail {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
constructor(objAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3AccessResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3AccessResOk | undefined;
readonly resfail?: Nfsv3AccessResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3AccessResOk | undefined, resfail?: Nfsv3AccessResFail | undefined);
}
export declare class Nfsv3ReadlinkRequest {
readonly symlink: stucts.Nfsv3Fh;
constructor(symlink: stucts.Nfsv3Fh);
}
export declare class Nfsv3ReadlinkResOk {
readonly symlinkAttributes: stucts.Nfsv3PostOpAttr;
readonly data: string;
constructor(symlinkAttributes: stucts.Nfsv3PostOpAttr, data: string);
}
export declare class Nfsv3ReadlinkResFail {
readonly symlinkAttributes: stucts.Nfsv3PostOpAttr;
constructor(symlinkAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3ReadlinkResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3ReadlinkResOk | undefined;
readonly resfail?: Nfsv3ReadlinkResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3ReadlinkResOk | undefined, resfail?: Nfsv3ReadlinkResFail | undefined);
}
export declare class Nfsv3ReadRequest {
readonly file: stucts.Nfsv3Fh;
readonly offset: bigint;
readonly count: number;
constructor(file: stucts.Nfsv3Fh, offset: bigint, count: number);
}
export declare class Nfsv3ReadResOk {
readonly fileAttributes: stucts.Nfsv3PostOpAttr;
readonly count: number;
readonly eof: boolean;
readonly data: Uint8Array;
constructor(fileAttributes: stucts.Nfsv3PostOpAttr, count: number, eof: boolean, data: Uint8Array);
}
export declare class Nfsv3ReadResFail {
readonly fileAttributes: stucts.Nfsv3PostOpAttr;
constructor(fileAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3ReadResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3ReadResOk | undefined;
readonly resfail?: Nfsv3ReadResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3ReadResOk | undefined, resfail?: Nfsv3ReadResFail | undefined);
}
export declare class Nfsv3WriteRequest {
readonly file: stucts.Nfsv3Fh;
readonly offset: bigint;
readonly count: number;
readonly stable: number;
readonly data: Uint8Array;
constructor(file: stucts.Nfsv3Fh, offset: bigint, count: number, stable: number, data: Uint8Array);
}
export declare class Nfsv3WriteResOk {
readonly fileWcc: stucts.Nfsv3WccData;
readonly count: number;
readonly committed: number;
readonly verf: Uint8Array;
constructor(fileWcc: stucts.Nfsv3WccData, count: number, committed: number, verf: Uint8Array);
}
export declare class Nfsv3WriteResFail {
readonly fileWcc: stucts.Nfsv3WccData;
constructor(fileWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3WriteResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3WriteResOk | undefined;
readonly resfail?: Nfsv3WriteResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3WriteResOk | undefined, resfail?: Nfsv3WriteResFail | undefined);
}
export declare class Nfsv3CreateRequest {
readonly where: stucts.Nfsv3DirOpArgs;
readonly how: stucts.Nfsv3CreateHow;
constructor(where: stucts.Nfsv3DirOpArgs, how: stucts.Nfsv3CreateHow);
}
export declare class Nfsv3CreateResOk {
readonly obj: stucts.Nfsv3PostOpFh;
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly dirWcc: stucts.Nfsv3WccData;
constructor(obj: stucts.Nfsv3PostOpFh, objAttributes: stucts.Nfsv3PostOpAttr, dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3CreateResFail {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3CreateResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3CreateResOk | undefined;
readonly resfail?: Nfsv3CreateResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3CreateResOk | undefined, resfail?: Nfsv3CreateResFail | undefined);
}
export declare class Nfsv3MkdirRequest {
readonly where: stucts.Nfsv3DirOpArgs;
readonly attributes: stucts.Nfsv3Sattr;
constructor(where: stucts.Nfsv3DirOpArgs, attributes: stucts.Nfsv3Sattr);
}
export declare class Nfsv3MkdirResOk {
readonly obj: stucts.Nfsv3PostOpFh;
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly dirWcc: stucts.Nfsv3WccData;
constructor(obj: stucts.Nfsv3PostOpFh, objAttributes: stucts.Nfsv3PostOpAttr, dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3MkdirResFail {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3MkdirResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3MkdirResOk | undefined;
readonly resfail?: Nfsv3MkdirResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3MkdirResOk | undefined, resfail?: Nfsv3MkdirResFail | undefined);
}
export declare class Nfsv3SymlinkRequest {
readonly where: stucts.Nfsv3DirOpArgs;
readonly symlinkAttributes: stucts.Nfsv3Sattr;
readonly symlinkData: string;
constructor(where: stucts.Nfsv3DirOpArgs, symlinkAttributes: stucts.Nfsv3Sattr, symlinkData: string);
}
export declare class Nfsv3SymlinkResOk {
readonly obj: stucts.Nfsv3PostOpFh;
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly dirWcc: stucts.Nfsv3WccData;
constructor(obj: stucts.Nfsv3PostOpFh, objAttributes: stucts.Nfsv3PostOpAttr, dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3SymlinkResFail {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3SymlinkResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3SymlinkResOk | undefined;
readonly resfail?: Nfsv3SymlinkResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3SymlinkResOk | undefined, resfail?: Nfsv3SymlinkResFail | undefined);
}
export declare class Nfsv3MknodRequest {
readonly where: stucts.Nfsv3DirOpArgs;
readonly what: stucts.Nfsv3MknodData;
constructor(where: stucts.Nfsv3DirOpArgs, what: stucts.Nfsv3MknodData);
}
export declare class Nfsv3MknodResOk {
readonly obj: stucts.Nfsv3PostOpFh;
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly dirWcc: stucts.Nfsv3WccData;
constructor(obj: stucts.Nfsv3PostOpFh, objAttributes: stucts.Nfsv3PostOpAttr, dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3MknodResFail {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3MknodResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3MknodResOk | undefined;
readonly resfail?: Nfsv3MknodResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3MknodResOk | undefined, resfail?: Nfsv3MknodResFail | undefined);
}
export declare class Nfsv3RemoveRequest {
readonly object: stucts.Nfsv3DirOpArgs;
constructor(object: stucts.Nfsv3DirOpArgs);
}
export declare class Nfsv3RemoveResOk {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3RemoveResFail {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3RemoveResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3RemoveResOk | undefined;
readonly resfail?: Nfsv3RemoveResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3RemoveResOk | undefined, resfail?: Nfsv3RemoveResFail | undefined);
}
export declare class Nfsv3RmdirRequest {
readonly object: stucts.Nfsv3DirOpArgs;
constructor(object: stucts.Nfsv3DirOpArgs);
}
export declare class Nfsv3RmdirResOk {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3RmdirResFail {
readonly dirWcc: stucts.Nfsv3WccData;
constructor(dirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3RmdirResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3RmdirResOk | undefined;
readonly resfail?: Nfsv3RmdirResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3RmdirResOk | undefined, resfail?: Nfsv3RmdirResFail | undefined);
}
export declare class Nfsv3RenameRequest {
readonly from: stucts.Nfsv3DirOpArgs;
readonly to: stucts.Nfsv3DirOpArgs;
constructor(from: stucts.Nfsv3DirOpArgs, to: stucts.Nfsv3DirOpArgs);
}
export declare class Nfsv3RenameResOk {
readonly fromDirWcc: stucts.Nfsv3WccData;
readonly toDirWcc: stucts.Nfsv3WccData;
constructor(fromDirWcc: stucts.Nfsv3WccData, toDirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3RenameResFail {
readonly fromDirWcc: stucts.Nfsv3WccData;
readonly toDirWcc: stucts.Nfsv3WccData;
constructor(fromDirWcc: stucts.Nfsv3WccData, toDirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3RenameResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3RenameResOk | undefined;
readonly resfail?: Nfsv3RenameResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3RenameResOk | undefined, resfail?: Nfsv3RenameResFail | undefined);
}
export declare class Nfsv3LinkRequest {
readonly file: stucts.Nfsv3Fh;
readonly link: stucts.Nfsv3DirOpArgs;
constructor(file: stucts.Nfsv3Fh, link: stucts.Nfsv3DirOpArgs);
}
export declare class Nfsv3LinkResOk {
readonly fileAttributes: stucts.Nfsv3PostOpAttr;
readonly linkDirWcc: stucts.Nfsv3WccData;
constructor(fileAttributes: stucts.Nfsv3PostOpAttr, linkDirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3LinkResFail {
readonly fileAttributes: stucts.Nfsv3PostOpAttr;
readonly linkDirWcc: stucts.Nfsv3WccData;
constructor(fileAttributes: stucts.Nfsv3PostOpAttr, linkDirWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3LinkResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3LinkResOk | undefined;
readonly resfail?: Nfsv3LinkResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3LinkResOk | undefined, resfail?: Nfsv3LinkResFail | undefined);
}
export declare class Nfsv3ReaddirRequest {
readonly dir: stucts.Nfsv3Fh;
readonly cookie: bigint;
readonly cookieverf: Uint8Array;
readonly count: number;
constructor(dir: stucts.Nfsv3Fh, cookie: bigint, cookieverf: Uint8Array, count: number);
}
export declare class Nfsv3ReaddirResOk {
readonly dirAttributes: stucts.Nfsv3PostOpAttr;
readonly cookieverf: Uint8Array;
readonly reply: stucts.Nfsv3DirList;
constructor(dirAttributes: stucts.Nfsv3PostOpAttr, cookieverf: Uint8Array, reply: stucts.Nfsv3DirList);
}
export declare class Nfsv3ReaddirResFail {
readonly dirAttributes: stucts.Nfsv3PostOpAttr;
constructor(dirAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3ReaddirResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3ReaddirResOk | undefined;
readonly resfail?: Nfsv3ReaddirResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3ReaddirResOk | undefined, resfail?: Nfsv3ReaddirResFail | undefined);
}
export declare class Nfsv3ReaddirplusRequest {
readonly dir: stucts.Nfsv3Fh;
readonly cookie: bigint;
readonly cookieverf: Uint8Array;
readonly dircount: number;
readonly maxcount: number;
constructor(dir: stucts.Nfsv3Fh, cookie: bigint, cookieverf: Uint8Array, dircount: number, maxcount: number);
}
export declare class Nfsv3ReaddirplusResOk {
readonly dirAttributes: stucts.Nfsv3PostOpAttr;
readonly cookieverf: Uint8Array;
readonly reply: stucts.Nfsv3DirListPlus;
constructor(dirAttributes: stucts.Nfsv3PostOpAttr, cookieverf: Uint8Array, reply: stucts.Nfsv3DirListPlus);
}
export declare class Nfsv3ReaddirplusResFail {
readonly dirAttributes: stucts.Nfsv3PostOpAttr;
constructor(dirAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3ReaddirplusResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3ReaddirplusResOk | undefined;
readonly resfail?: Nfsv3ReaddirplusResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3ReaddirplusResOk | undefined, resfail?: Nfsv3ReaddirplusResFail | undefined);
}
export declare class Nfsv3FsstatRequest {
readonly fsroot: stucts.Nfsv3Fh;
constructor(fsroot: stucts.Nfsv3Fh);
}
export declare class Nfsv3FsstatResOk {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly tbytes: bigint;
readonly fbytes: bigint;
readonly abytes: bigint;
readonly tfiles: bigint;
readonly ffiles: bigint;
readonly afiles: bigint;
readonly invarsec: number;
constructor(objAttributes: stucts.Nfsv3PostOpAttr, tbytes: bigint, fbytes: bigint, abytes: bigint, tfiles: bigint, ffiles: bigint, afiles: bigint, invarsec: number);
}
export declare class Nfsv3FsstatResFail {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
constructor(objAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3FsstatResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3FsstatResOk | undefined;
readonly resfail?: Nfsv3FsstatResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3FsstatResOk | undefined, resfail?: Nfsv3FsstatResFail | undefined);
}
export declare class Nfsv3FsinfoRequest {
readonly fsroot: stucts.Nfsv3Fh;
constructor(fsroot: stucts.Nfsv3Fh);
}
export declare class Nfsv3FsinfoResOk {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly rtmax: number;
readonly rtpref: number;
readonly rtmult: number;
readonly wtmax: number;
readonly wtpref: number;
readonly wtmult: number;
readonly dtpref: number;
readonly maxfilesize: bigint;
readonly timeDelta: {
seconds: number;
nseconds: number;
};
readonly properties: number;
constructor(objAttributes: stucts.Nfsv3PostOpAttr, rtmax: number, rtpref: number, rtmult: number, wtmax: number, wtpref: number, wtmult: number, dtpref: number, maxfilesize: bigint, timeDelta: {
seconds: number;
nseconds: number;
}, properties: number);
}
export declare class Nfsv3FsinfoResFail {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
constructor(objAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3FsinfoResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3FsinfoResOk | undefined;
readonly resfail?: Nfsv3FsinfoResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3FsinfoResOk | undefined, resfail?: Nfsv3FsinfoResFail | undefined);
}
export declare class Nfsv3PathconfRequest {
readonly object: stucts.Nfsv3Fh;
constructor(object: stucts.Nfsv3Fh);
}
export declare class Nfsv3PathconfResOk {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
readonly linkmax: number;
readonly namemax: number;
readonly noTrunc: boolean;
readonly chownRestricted: boolean;
readonly caseInsensitive: boolean;
readonly casePreserving: boolean;
constructor(objAttributes: stucts.Nfsv3PostOpAttr, linkmax: number, namemax: number, noTrunc: boolean, chownRestricted: boolean, caseInsensitive: boolean, casePreserving: boolean);
}
export declare class Nfsv3PathconfResFail {
readonly objAttributes: stucts.Nfsv3PostOpAttr;
constructor(objAttributes: stucts.Nfsv3PostOpAttr);
}
export declare class Nfsv3PathconfResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3PathconfResOk | undefined;
readonly resfail?: Nfsv3PathconfResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3PathconfResOk | undefined, resfail?: Nfsv3PathconfResFail | undefined);
}
export declare class Nfsv3CommitRequest {
readonly file: stucts.Nfsv3Fh;
readonly offset: bigint;
readonly count: number;
constructor(file: stucts.Nfsv3Fh, offset: bigint, count: number);
}
export declare class Nfsv3CommitResOk {
readonly fileWcc: stucts.Nfsv3WccData;
readonly verf: Uint8Array;
constructor(fileWcc: stucts.Nfsv3WccData, verf: Uint8Array);
}
export declare class Nfsv3CommitResFail {
readonly fileWcc: stucts.Nfsv3WccData;
constructor(fileWcc: stucts.Nfsv3WccData);
}
export declare class Nfsv3CommitResponse {
readonly status: Nfsv3Stat;
readonly resok?: Nfsv3CommitResOk | undefined;
readonly resfail?: Nfsv3CommitResFail | undefined;
constructor(status: Nfsv3Stat, resok?: Nfsv3CommitResOk | undefined, resfail?: Nfsv3CommitResFail | undefined);
}

View File

@@ -0,0 +1,619 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv3RmdirResFail = exports.Nfsv3RmdirResOk = exports.Nfsv3RmdirRequest = exports.Nfsv3RemoveResponse = exports.Nfsv3RemoveResFail = exports.Nfsv3RemoveResOk = exports.Nfsv3RemoveRequest = exports.Nfsv3MknodResponse = exports.Nfsv3MknodResFail = exports.Nfsv3MknodResOk = exports.Nfsv3MknodRequest = exports.Nfsv3SymlinkResponse = exports.Nfsv3SymlinkResFail = exports.Nfsv3SymlinkResOk = exports.Nfsv3SymlinkRequest = exports.Nfsv3MkdirResponse = exports.Nfsv3MkdirResFail = exports.Nfsv3MkdirResOk = exports.Nfsv3MkdirRequest = exports.Nfsv3CreateResponse = exports.Nfsv3CreateResFail = exports.Nfsv3CreateResOk = exports.Nfsv3CreateRequest = exports.Nfsv3WriteResponse = exports.Nfsv3WriteResFail = exports.Nfsv3WriteResOk = exports.Nfsv3WriteRequest = exports.Nfsv3ReadResponse = exports.Nfsv3ReadResFail = exports.Nfsv3ReadResOk = exports.Nfsv3ReadRequest = exports.Nfsv3ReadlinkResponse = exports.Nfsv3ReadlinkResFail = exports.Nfsv3ReadlinkResOk = exports.Nfsv3ReadlinkRequest = exports.Nfsv3AccessResponse = exports.Nfsv3AccessResFail = exports.Nfsv3AccessResOk = exports.Nfsv3AccessRequest = exports.Nfsv3LookupResponse = exports.Nfsv3LookupResFail = exports.Nfsv3LookupResOk = exports.Nfsv3LookupRequest = exports.Nfsv3SetattrResponse = exports.Nfsv3SetattrResFail = exports.Nfsv3SetattrResOk = exports.Nfsv3SetattrRequest = exports.Nfsv3GetattrResponse = exports.Nfsv3GetattrResOk = exports.Nfsv3GetattrRequest = void 0;
exports.Nfsv3CommitResponse = exports.Nfsv3CommitResFail = exports.Nfsv3CommitResOk = exports.Nfsv3CommitRequest = exports.Nfsv3PathconfResponse = exports.Nfsv3PathconfResFail = exports.Nfsv3PathconfResOk = exports.Nfsv3PathconfRequest = exports.Nfsv3FsinfoResponse = exports.Nfsv3FsinfoResFail = exports.Nfsv3FsinfoResOk = exports.Nfsv3FsinfoRequest = exports.Nfsv3FsstatResponse = exports.Nfsv3FsstatResFail = exports.Nfsv3FsstatResOk = exports.Nfsv3FsstatRequest = exports.Nfsv3ReaddirplusResponse = exports.Nfsv3ReaddirplusResFail = exports.Nfsv3ReaddirplusResOk = exports.Nfsv3ReaddirplusRequest = exports.Nfsv3ReaddirResponse = exports.Nfsv3ReaddirResFail = exports.Nfsv3ReaddirResOk = exports.Nfsv3ReaddirRequest = exports.Nfsv3LinkResponse = exports.Nfsv3LinkResFail = exports.Nfsv3LinkResOk = exports.Nfsv3LinkRequest = exports.Nfsv3RenameResponse = exports.Nfsv3RenameResFail = exports.Nfsv3RenameResOk = exports.Nfsv3RenameRequest = exports.Nfsv3RmdirResponse = void 0;
class Nfsv3GetattrRequest {
constructor(object) {
this.object = object;
}
}
exports.Nfsv3GetattrRequest = Nfsv3GetattrRequest;
class Nfsv3GetattrResOk {
constructor(objAttributes) {
this.objAttributes = objAttributes;
}
}
exports.Nfsv3GetattrResOk = Nfsv3GetattrResOk;
class Nfsv3GetattrResponse {
constructor(status, resok) {
this.status = status;
this.resok = resok;
}
}
exports.Nfsv3GetattrResponse = Nfsv3GetattrResponse;
class Nfsv3SetattrRequest {
constructor(object, newAttributes, guard) {
this.object = object;
this.newAttributes = newAttributes;
this.guard = guard;
}
}
exports.Nfsv3SetattrRequest = Nfsv3SetattrRequest;
class Nfsv3SetattrResOk {
constructor(objWcc) {
this.objWcc = objWcc;
}
}
exports.Nfsv3SetattrResOk = Nfsv3SetattrResOk;
class Nfsv3SetattrResFail {
constructor(objWcc) {
this.objWcc = objWcc;
}
}
exports.Nfsv3SetattrResFail = Nfsv3SetattrResFail;
class Nfsv3SetattrResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3SetattrResponse = Nfsv3SetattrResponse;
class Nfsv3LookupRequest {
constructor(what) {
this.what = what;
}
}
exports.Nfsv3LookupRequest = Nfsv3LookupRequest;
class Nfsv3LookupResOk {
constructor(object, objAttributes, dirAttributes) {
this.object = object;
this.objAttributes = objAttributes;
this.dirAttributes = dirAttributes;
}
}
exports.Nfsv3LookupResOk = Nfsv3LookupResOk;
class Nfsv3LookupResFail {
constructor(dirAttributes) {
this.dirAttributes = dirAttributes;
}
}
exports.Nfsv3LookupResFail = Nfsv3LookupResFail;
class Nfsv3LookupResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3LookupResponse = Nfsv3LookupResponse;
class Nfsv3AccessRequest {
constructor(object, access) {
this.object = object;
this.access = access;
}
}
exports.Nfsv3AccessRequest = Nfsv3AccessRequest;
class Nfsv3AccessResOk {
constructor(objAttributes, access) {
this.objAttributes = objAttributes;
this.access = access;
}
}
exports.Nfsv3AccessResOk = Nfsv3AccessResOk;
class Nfsv3AccessResFail {
constructor(objAttributes) {
this.objAttributes = objAttributes;
}
}
exports.Nfsv3AccessResFail = Nfsv3AccessResFail;
class Nfsv3AccessResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3AccessResponse = Nfsv3AccessResponse;
class Nfsv3ReadlinkRequest {
constructor(symlink) {
this.symlink = symlink;
}
}
exports.Nfsv3ReadlinkRequest = Nfsv3ReadlinkRequest;
class Nfsv3ReadlinkResOk {
constructor(symlinkAttributes, data) {
this.symlinkAttributes = symlinkAttributes;
this.data = data;
}
}
exports.Nfsv3ReadlinkResOk = Nfsv3ReadlinkResOk;
class Nfsv3ReadlinkResFail {
constructor(symlinkAttributes) {
this.symlinkAttributes = symlinkAttributes;
}
}
exports.Nfsv3ReadlinkResFail = Nfsv3ReadlinkResFail;
class Nfsv3ReadlinkResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3ReadlinkResponse = Nfsv3ReadlinkResponse;
class Nfsv3ReadRequest {
constructor(file, offset, count) {
this.file = file;
this.offset = offset;
this.count = count;
}
}
exports.Nfsv3ReadRequest = Nfsv3ReadRequest;
class Nfsv3ReadResOk {
constructor(fileAttributes, count, eof, data) {
this.fileAttributes = fileAttributes;
this.count = count;
this.eof = eof;
this.data = data;
}
}
exports.Nfsv3ReadResOk = Nfsv3ReadResOk;
class Nfsv3ReadResFail {
constructor(fileAttributes) {
this.fileAttributes = fileAttributes;
}
}
exports.Nfsv3ReadResFail = Nfsv3ReadResFail;
class Nfsv3ReadResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3ReadResponse = Nfsv3ReadResponse;
class Nfsv3WriteRequest {
constructor(file, offset, count, stable, data) {
this.file = file;
this.offset = offset;
this.count = count;
this.stable = stable;
this.data = data;
}
}
exports.Nfsv3WriteRequest = Nfsv3WriteRequest;
class Nfsv3WriteResOk {
constructor(fileWcc, count, committed, verf) {
this.fileWcc = fileWcc;
this.count = count;
this.committed = committed;
this.verf = verf;
}
}
exports.Nfsv3WriteResOk = Nfsv3WriteResOk;
class Nfsv3WriteResFail {
constructor(fileWcc) {
this.fileWcc = fileWcc;
}
}
exports.Nfsv3WriteResFail = Nfsv3WriteResFail;
class Nfsv3WriteResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3WriteResponse = Nfsv3WriteResponse;
class Nfsv3CreateRequest {
constructor(where, how) {
this.where = where;
this.how = how;
}
}
exports.Nfsv3CreateRequest = Nfsv3CreateRequest;
class Nfsv3CreateResOk {
constructor(obj, objAttributes, dirWcc) {
this.obj = obj;
this.objAttributes = objAttributes;
this.dirWcc = dirWcc;
}
}
exports.Nfsv3CreateResOk = Nfsv3CreateResOk;
class Nfsv3CreateResFail {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3CreateResFail = Nfsv3CreateResFail;
class Nfsv3CreateResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3CreateResponse = Nfsv3CreateResponse;
class Nfsv3MkdirRequest {
constructor(where, attributes) {
this.where = where;
this.attributes = attributes;
}
}
exports.Nfsv3MkdirRequest = Nfsv3MkdirRequest;
class Nfsv3MkdirResOk {
constructor(obj, objAttributes, dirWcc) {
this.obj = obj;
this.objAttributes = objAttributes;
this.dirWcc = dirWcc;
}
}
exports.Nfsv3MkdirResOk = Nfsv3MkdirResOk;
class Nfsv3MkdirResFail {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3MkdirResFail = Nfsv3MkdirResFail;
class Nfsv3MkdirResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3MkdirResponse = Nfsv3MkdirResponse;
class Nfsv3SymlinkRequest {
constructor(where, symlinkAttributes, symlinkData) {
this.where = where;
this.symlinkAttributes = symlinkAttributes;
this.symlinkData = symlinkData;
}
}
exports.Nfsv3SymlinkRequest = Nfsv3SymlinkRequest;
class Nfsv3SymlinkResOk {
constructor(obj, objAttributes, dirWcc) {
this.obj = obj;
this.objAttributes = objAttributes;
this.dirWcc = dirWcc;
}
}
exports.Nfsv3SymlinkResOk = Nfsv3SymlinkResOk;
class Nfsv3SymlinkResFail {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3SymlinkResFail = Nfsv3SymlinkResFail;
class Nfsv3SymlinkResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3SymlinkResponse = Nfsv3SymlinkResponse;
class Nfsv3MknodRequest {
constructor(where, what) {
this.where = where;
this.what = what;
}
}
exports.Nfsv3MknodRequest = Nfsv3MknodRequest;
class Nfsv3MknodResOk {
constructor(obj, objAttributes, dirWcc) {
this.obj = obj;
this.objAttributes = objAttributes;
this.dirWcc = dirWcc;
}
}
exports.Nfsv3MknodResOk = Nfsv3MknodResOk;
class Nfsv3MknodResFail {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3MknodResFail = Nfsv3MknodResFail;
class Nfsv3MknodResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3MknodResponse = Nfsv3MknodResponse;
class Nfsv3RemoveRequest {
constructor(object) {
this.object = object;
}
}
exports.Nfsv3RemoveRequest = Nfsv3RemoveRequest;
class Nfsv3RemoveResOk {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3RemoveResOk = Nfsv3RemoveResOk;
class Nfsv3RemoveResFail {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3RemoveResFail = Nfsv3RemoveResFail;
class Nfsv3RemoveResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3RemoveResponse = Nfsv3RemoveResponse;
class Nfsv3RmdirRequest {
constructor(object) {
this.object = object;
}
}
exports.Nfsv3RmdirRequest = Nfsv3RmdirRequest;
class Nfsv3RmdirResOk {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3RmdirResOk = Nfsv3RmdirResOk;
class Nfsv3RmdirResFail {
constructor(dirWcc) {
this.dirWcc = dirWcc;
}
}
exports.Nfsv3RmdirResFail = Nfsv3RmdirResFail;
class Nfsv3RmdirResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3RmdirResponse = Nfsv3RmdirResponse;
class Nfsv3RenameRequest {
constructor(from, to) {
this.from = from;
this.to = to;
}
}
exports.Nfsv3RenameRequest = Nfsv3RenameRequest;
class Nfsv3RenameResOk {
constructor(fromDirWcc, toDirWcc) {
this.fromDirWcc = fromDirWcc;
this.toDirWcc = toDirWcc;
}
}
exports.Nfsv3RenameResOk = Nfsv3RenameResOk;
class Nfsv3RenameResFail {
constructor(fromDirWcc, toDirWcc) {
this.fromDirWcc = fromDirWcc;
this.toDirWcc = toDirWcc;
}
}
exports.Nfsv3RenameResFail = Nfsv3RenameResFail;
class Nfsv3RenameResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3RenameResponse = Nfsv3RenameResponse;
class Nfsv3LinkRequest {
constructor(file, link) {
this.file = file;
this.link = link;
}
}
exports.Nfsv3LinkRequest = Nfsv3LinkRequest;
class Nfsv3LinkResOk {
constructor(fileAttributes, linkDirWcc) {
this.fileAttributes = fileAttributes;
this.linkDirWcc = linkDirWcc;
}
}
exports.Nfsv3LinkResOk = Nfsv3LinkResOk;
class Nfsv3LinkResFail {
constructor(fileAttributes, linkDirWcc) {
this.fileAttributes = fileAttributes;
this.linkDirWcc = linkDirWcc;
}
}
exports.Nfsv3LinkResFail = Nfsv3LinkResFail;
class Nfsv3LinkResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3LinkResponse = Nfsv3LinkResponse;
class Nfsv3ReaddirRequest {
constructor(dir, cookie, cookieverf, count) {
this.dir = dir;
this.cookie = cookie;
this.cookieverf = cookieverf;
this.count = count;
}
}
exports.Nfsv3ReaddirRequest = Nfsv3ReaddirRequest;
class Nfsv3ReaddirResOk {
constructor(dirAttributes, cookieverf, reply) {
this.dirAttributes = dirAttributes;
this.cookieverf = cookieverf;
this.reply = reply;
}
}
exports.Nfsv3ReaddirResOk = Nfsv3ReaddirResOk;
class Nfsv3ReaddirResFail {
constructor(dirAttributes) {
this.dirAttributes = dirAttributes;
}
}
exports.Nfsv3ReaddirResFail = Nfsv3ReaddirResFail;
class Nfsv3ReaddirResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3ReaddirResponse = Nfsv3ReaddirResponse;
class Nfsv3ReaddirplusRequest {
constructor(dir, cookie, cookieverf, dircount, maxcount) {
this.dir = dir;
this.cookie = cookie;
this.cookieverf = cookieverf;
this.dircount = dircount;
this.maxcount = maxcount;
}
}
exports.Nfsv3ReaddirplusRequest = Nfsv3ReaddirplusRequest;
class Nfsv3ReaddirplusResOk {
constructor(dirAttributes, cookieverf, reply) {
this.dirAttributes = dirAttributes;
this.cookieverf = cookieverf;
this.reply = reply;
}
}
exports.Nfsv3ReaddirplusResOk = Nfsv3ReaddirplusResOk;
class Nfsv3ReaddirplusResFail {
constructor(dirAttributes) {
this.dirAttributes = dirAttributes;
}
}
exports.Nfsv3ReaddirplusResFail = Nfsv3ReaddirplusResFail;
class Nfsv3ReaddirplusResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3ReaddirplusResponse = Nfsv3ReaddirplusResponse;
class Nfsv3FsstatRequest {
constructor(fsroot) {
this.fsroot = fsroot;
}
}
exports.Nfsv3FsstatRequest = Nfsv3FsstatRequest;
class Nfsv3FsstatResOk {
constructor(objAttributes, tbytes, fbytes, abytes, tfiles, ffiles, afiles, invarsec) {
this.objAttributes = objAttributes;
this.tbytes = tbytes;
this.fbytes = fbytes;
this.abytes = abytes;
this.tfiles = tfiles;
this.ffiles = ffiles;
this.afiles = afiles;
this.invarsec = invarsec;
}
}
exports.Nfsv3FsstatResOk = Nfsv3FsstatResOk;
class Nfsv3FsstatResFail {
constructor(objAttributes) {
this.objAttributes = objAttributes;
}
}
exports.Nfsv3FsstatResFail = Nfsv3FsstatResFail;
class Nfsv3FsstatResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3FsstatResponse = Nfsv3FsstatResponse;
class Nfsv3FsinfoRequest {
constructor(fsroot) {
this.fsroot = fsroot;
}
}
exports.Nfsv3FsinfoRequest = Nfsv3FsinfoRequest;
class Nfsv3FsinfoResOk {
constructor(objAttributes, rtmax, rtpref, rtmult, wtmax, wtpref, wtmult, dtpref, maxfilesize, timeDelta, properties) {
this.objAttributes = objAttributes;
this.rtmax = rtmax;
this.rtpref = rtpref;
this.rtmult = rtmult;
this.wtmax = wtmax;
this.wtpref = wtpref;
this.wtmult = wtmult;
this.dtpref = dtpref;
this.maxfilesize = maxfilesize;
this.timeDelta = timeDelta;
this.properties = properties;
}
}
exports.Nfsv3FsinfoResOk = Nfsv3FsinfoResOk;
class Nfsv3FsinfoResFail {
constructor(objAttributes) {
this.objAttributes = objAttributes;
}
}
exports.Nfsv3FsinfoResFail = Nfsv3FsinfoResFail;
class Nfsv3FsinfoResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3FsinfoResponse = Nfsv3FsinfoResponse;
class Nfsv3PathconfRequest {
constructor(object) {
this.object = object;
}
}
exports.Nfsv3PathconfRequest = Nfsv3PathconfRequest;
class Nfsv3PathconfResOk {
constructor(objAttributes, linkmax, namemax, noTrunc, chownRestricted, caseInsensitive, casePreserving) {
this.objAttributes = objAttributes;
this.linkmax = linkmax;
this.namemax = namemax;
this.noTrunc = noTrunc;
this.chownRestricted = chownRestricted;
this.caseInsensitive = caseInsensitive;
this.casePreserving = casePreserving;
}
}
exports.Nfsv3PathconfResOk = Nfsv3PathconfResOk;
class Nfsv3PathconfResFail {
constructor(objAttributes) {
this.objAttributes = objAttributes;
}
}
exports.Nfsv3PathconfResFail = Nfsv3PathconfResFail;
class Nfsv3PathconfResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3PathconfResponse = Nfsv3PathconfResponse;
class Nfsv3CommitRequest {
constructor(file, offset, count) {
this.file = file;
this.offset = offset;
this.count = count;
}
}
exports.Nfsv3CommitRequest = Nfsv3CommitRequest;
class Nfsv3CommitResOk {
constructor(fileWcc, verf) {
this.fileWcc = fileWcc;
this.verf = verf;
}
}
exports.Nfsv3CommitResOk = Nfsv3CommitResOk;
class Nfsv3CommitResFail {
constructor(fileWcc) {
this.fileWcc = fileWcc;
}
}
exports.Nfsv3CommitResFail = Nfsv3CommitResFail;
class Nfsv3CommitResponse {
constructor(status, resok, resfail) {
this.status = status;
this.resok = resok;
this.resfail = resfail;
}
}
exports.Nfsv3CommitResponse = Nfsv3CommitResponse;
//# sourceMappingURL=messages.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
import { Reader } from '@jsonjoy.com/buffers/lib/Reader';
import { XdrDecoder } from '../../../xdr/XdrDecoder';
import { MountProc } from './constants';
import * as msg from './messages';
export declare class MountDecoder {
protected readonly xdr: XdrDecoder;
constructor(reader?: Reader);
decodeMessage(reader: Reader, proc: MountProc, isRequest: boolean): msg.MountMessage | undefined;
private decodeRequest;
private decodeResponse;
private readFhandle3;
private readDirpath;
private readMountBody;
private readGroupNode;
private readExportNode;
private decodeMntRequest;
private decodeMntResponse;
private decodeDumpResponse;
private decodeUmntRequest;
private decodeExportResponse;
}

View File

@@ -0,0 +1,135 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MountDecoder = void 0;
const tslib_1 = require("tslib");
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
const XdrDecoder_1 = require("../../../xdr/XdrDecoder");
const errors_1 = require("../errors");
const msg = tslib_1.__importStar(require("./messages"));
const structs = tslib_1.__importStar(require("./structs"));
class MountDecoder {
constructor(reader = new Reader_1.Reader()) {
this.xdr = new XdrDecoder_1.XdrDecoder(reader);
}
decodeMessage(reader, proc, isRequest) {
this.xdr.reader = reader;
const startPos = reader.x;
try {
if (isRequest) {
return this.decodeRequest(proc);
}
else {
return this.decodeResponse(proc);
}
}
catch (err) {
if (err instanceof RangeError) {
reader.x = startPos;
return undefined;
}
throw err;
}
}
decodeRequest(proc) {
switch (proc) {
case 0:
return undefined;
case 1:
return this.decodeMntRequest();
case 2:
return new msg.MountDumpRequest();
case 3:
return this.decodeUmntRequest();
case 4:
return new msg.MountUmntallRequest();
case 5:
return new msg.MountExportRequest();
default:
throw new errors_1.Nfsv3DecodingError(`Unknown MOUNT procedure: ${proc}`);
}
}
decodeResponse(proc) {
switch (proc) {
case 0:
return undefined;
case 1:
return this.decodeMntResponse();
case 2:
return this.decodeDumpResponse();
case 3:
return undefined;
case 4:
return undefined;
case 5:
return this.decodeExportResponse();
default:
throw new errors_1.Nfsv3DecodingError(`Unknown MOUNT procedure: ${proc}`);
}
}
readFhandle3() {
const data = this.xdr.readVarlenOpaque();
return new structs.MountFhandle3(new Reader_1.Reader(data));
}
readDirpath() {
return this.xdr.readString();
}
readMountBody() {
const valueFollows = this.xdr.readBoolean();
if (!valueFollows)
return undefined;
const hostname = this.xdr.readString();
const directory = this.readDirpath();
const next = this.readMountBody();
return new structs.MountBody(hostname, directory, next);
}
readGroupNode() {
const valueFollows = this.xdr.readBoolean();
if (!valueFollows)
return undefined;
const name = this.xdr.readString();
const next = this.readGroupNode();
return new structs.MountGroupNode(name, next);
}
readExportNode() {
const valueFollows = this.xdr.readBoolean();
if (!valueFollows)
return undefined;
const dir = this.readDirpath();
const groups = this.readGroupNode();
const next = this.readExportNode();
return new structs.MountExportNode(dir, groups, next);
}
decodeMntRequest() {
const dirpath = this.readDirpath();
return new msg.MountMntRequest(dirpath);
}
decodeMntResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status !== 0) {
return new msg.MountMntResponse(status);
}
const fhandle = this.readFhandle3();
const authFlavorsCount = xdr.readUnsignedInt();
const authFlavors = [];
for (let i = 0; i < authFlavorsCount; i++) {
authFlavors.push(xdr.readUnsignedInt());
}
const mountinfo = new msg.MountMntResOk(fhandle, authFlavors);
return new msg.MountMntResponse(status, mountinfo);
}
decodeDumpResponse() {
const mountlist = this.readMountBody();
return new msg.MountDumpResponse(mountlist);
}
decodeUmntRequest() {
const dirpath = this.readDirpath();
return new msg.MountUmntRequest(dirpath);
}
decodeExportResponse() {
const exports = this.readExportNode();
return new msg.MountExportResponse(exports);
}
}
exports.MountDecoder = MountDecoder;
//# sourceMappingURL=MountDecoder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MountDecoder.js","sourceRoot":"","sources":["../../../../src/nfs/v3/mount/MountDecoder.ts"],"names":[],"mappings":";;;;AAAA,4DAAuD;AACvD,wDAAmD;AAEnD,sCAA6C;AAC7C,wDAAkC;AAClC,2DAAqC;AAErC,MAAa,YAAY;IAGvB,YAAY,SAAiB,IAAI,eAAM,EAAE;QACvC,IAAI,CAAC,GAAG,GAAG,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAEM,aAAa,CAAC,MAAc,EAAE,IAAe,EAAE,SAAkB;QACtE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC;YACH,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,UAAU,EAAE,CAAC;gBAC9B,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC;gBACpB,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,IAAe;QACnC,QAAQ,IAAI,EAAE,CAAC;YACb;gBACE,OAAO,SAAS,CAAC;YACnB;gBACE,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACjC;gBACE,OAAO,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC;YACpC;gBACE,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAClC;gBACE,OAAO,IAAI,GAAG,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AC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC9D,OAAO,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAEO,kBAAkB;QACxB,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACvC,OAAO,IAAI,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;IAEO,iBAAiB;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,OAAO,IAAI,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAEO,oBAAoB;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACtC,OAAO,IAAI,GAAG,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF;AArID,oCAqIC"}

View File

@@ -0,0 +1,23 @@
import { XdrEncoder } from '../../../xdr/XdrEncoder';
import { MountProc } from './constants';
import * as msg from './messages';
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
export declare class MountEncoder<W extends IWriter & IWriterGrowable = IWriter & IWriterGrowable> {
readonly writer: W;
protected readonly xdr: XdrEncoder;
constructor(writer?: W);
encodeMessage(message: msg.MountMessage, proc: MountProc, isRequest: boolean): Uint8Array;
writeMessage(message: msg.MountMessage, proc: MountProc, isRequest: boolean): void;
private writeRequest;
private writeResponse;
private writeFhandle3;
private writeDirpath;
private writeMountBody;
private writeGroupNode;
private writeExportNode;
private writeMntRequest;
private writeMntResponse;
private writeDumpResponse;
private writeUmntRequest;
private writeExportResponse;
}

View File

@@ -0,0 +1,125 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MountEncoder = void 0;
const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
const XdrEncoder_1 = require("../../../xdr/XdrEncoder");
const errors_1 = require("../errors");
class MountEncoder {
constructor(writer = new Writer_1.Writer()) {
this.writer = writer;
this.xdr = new XdrEncoder_1.XdrEncoder(writer);
}
encodeMessage(message, proc, isRequest) {
if (isRequest)
this.writeRequest(message, proc);
else
this.writeResponse(message, proc);
return this.writer.flush();
}
writeMessage(message, proc, isRequest) {
if (isRequest)
this.writeRequest(message, proc);
else
this.writeResponse(message, proc);
}
writeRequest(request, proc) {
switch (proc) {
case 0:
return;
case 1:
return this.writeMntRequest(request);
case 2:
return;
case 3:
return this.writeUmntRequest(request);
case 4:
return;
case 5:
return;
default:
throw new errors_1.Nfsv3EncodingError(`Unknown MOUNT procedure: ${proc}`);
}
}
writeResponse(response, proc) {
switch (proc) {
case 0:
return;
case 1:
return this.writeMntResponse(response);
case 2:
return this.writeDumpResponse(response);
case 3:
return;
case 4:
return;
case 5:
return this.writeExportResponse(response);
default:
throw new errors_1.Nfsv3EncodingError(`Unknown MOUNT procedure: ${proc}`);
}
}
writeFhandle3(fh) {
const data = fh.data.uint8;
this.xdr.writeVarlenOpaque(data);
}
writeDirpath(path) {
this.xdr.writeStr(path);
}
writeMountBody(body) {
const xdr = this.xdr;
if (!body) {
xdr.writeBoolean(false);
return;
}
xdr.writeBoolean(true);
xdr.writeStr(body.hostname);
this.writeDirpath(body.directory);
this.writeMountBody(body.next);
}
writeGroupNode(group) {
const xdr = this.xdr;
if (!group) {
xdr.writeBoolean(false);
return;
}
xdr.writeBoolean(true);
xdr.writeStr(group.name);
this.writeGroupNode(group.next);
}
writeExportNode(exportNode) {
const xdr = this.xdr;
if (!exportNode) {
xdr.writeBoolean(false);
return;
}
xdr.writeBoolean(true);
this.writeDirpath(exportNode.dir);
this.writeGroupNode(exportNode.groups);
this.writeExportNode(exportNode.next);
}
writeMntRequest(req) {
this.writeDirpath(req.dirpath);
}
writeMntResponse(res) {
const xdr = this.xdr;
xdr.writeUnsignedInt(res.status);
if (res.status === 0 && res.mountinfo) {
this.writeFhandle3(res.mountinfo.fhandle);
xdr.writeUnsignedInt(res.mountinfo.authFlavors.length);
for (const flavor of res.mountinfo.authFlavors) {
xdr.writeUnsignedInt(flavor);
}
}
}
writeDumpResponse(res) {
this.writeMountBody(res.mountlist);
}
writeUmntRequest(req) {
this.writeDirpath(req.dirpath);
}
writeExportResponse(res) {
this.writeExportNode(res.exports);
}
}
exports.MountEncoder = MountEncoder;
//# sourceMappingURL=MountEncoder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MountEncoder.js","sourceRoot":"","sources":["../../../../src/nfs/v3/mount/MountEncoder.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,wDAAmD;AAEnD,sCAA6C;AAK7C,MAAa,YAAY;IAGvB,YAA4B,SAAY,IAAI,eAAM,EAAS;QAA/B,WAAM,GAAN,MAAM,CAAyB;QACzD,IAAI,CAAC,GAAG,GAAG,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAEM,aAAa,CAAC,OAAyB,EAAE,IAAe,EAAE,SAAkB;QACjF,IAAI,SAAS;YAAE,IAAI,CAAC,YAAY,CAAC,OAA2B,EAAE,IAAI,CAAC,CAAC;;YAC/D,IAAI,CAAC,aAAa,CAAC,OAA4B,EAAE,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAEM,YAAY,CAAC,OAAyB,EAAE,IAAe,EAAE,SAAkB;QAChF,IAAI,SAAS;YAAE,IAAI,CAAC,YAAY,CAAC,OAA2B,EAAE,IAAI,CAAC,CAAC;;YAC/D,IAAI,CAAC,aAAa,CAAC,OAA4B,EAAE,IAAI,CAAC,CAAC;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AAC,CAAC;QACjC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC1C,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACvD,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;gBAC/C,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAEO,iBAAiB,CAAC,GAA0B;QAClD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAEO,gBAAgB,CAAC,GAAyB;QAChD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAEO,mBAAmB,CAAC,GAA4B;QACtD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACF;AA/HD,oCA+HC"}

View File

@@ -0,0 +1,27 @@
export declare const enum MountConst {
PROGRAM = 100005,
VERSION = 3,
MNTPATHLEN = 1024,
MNTNAMLEN = 255,
FHSIZE3 = 64
}
export declare const enum MountProc {
NULL = 0,
MNT = 1,
DUMP = 2,
UMNT = 3,
UMNTALL = 4,
EXPORT = 5
}
export declare const enum MountStat {
MNT3_OK = 0,
MNT3ERR_PERM = 1,
MNT3ERR_NOENT = 2,
MNT3ERR_IO = 5,
MNT3ERR_ACCES = 13,
MNT3ERR_NOTDIR = 20,
MNT3ERR_INVAL = 22,
MNT3ERR_NAMETOOLONG = 63,
MNT3ERR_NOTSUPP = 10004,
MNT3ERR_SERVERFAULT = 10006
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/nfs/v3/mount/constants.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,37 @@
import { MountStat } from './constants';
import type * as stucts from './structs';
export type MountMessage = MountRequest | MountResponse;
export type MountRequest = MountMntRequest | MountUmntRequest | MountDumpRequest | MountUmntallRequest | MountExportRequest;
export type MountResponse = MountMntResponse | MountDumpResponse | MountExportResponse;
export declare class MountMntRequest {
readonly dirpath: string;
constructor(dirpath: string);
}
export declare class MountMntResOk {
readonly fhandle: stucts.MountFhandle3;
readonly authFlavors: number[];
constructor(fhandle: stucts.MountFhandle3, authFlavors: number[]);
}
export declare class MountMntResponse {
readonly status: MountStat;
readonly mountinfo?: MountMntResOk | undefined;
constructor(status: MountStat, mountinfo?: MountMntResOk | undefined);
}
export declare class MountDumpRequest {
}
export declare class MountDumpResponse {
readonly mountlist?: stucts.MountBody | undefined;
constructor(mountlist?: stucts.MountBody | undefined);
}
export declare class MountUmntRequest {
readonly dirpath: string;
constructor(dirpath: string);
}
export declare class MountUmntallRequest {
}
export declare class MountExportRequest {
}
export declare class MountExportResponse {
readonly exports?: stucts.MountExportNode | undefined;
constructor(exports?: stucts.MountExportNode | undefined);
}

View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MountExportResponse = exports.MountExportRequest = exports.MountUmntallRequest = exports.MountUmntRequest = exports.MountDumpResponse = exports.MountDumpRequest = exports.MountMntResponse = exports.MountMntResOk = exports.MountMntRequest = void 0;
class MountMntRequest {
constructor(dirpath) {
this.dirpath = dirpath;
}
}
exports.MountMntRequest = MountMntRequest;
class MountMntResOk {
constructor(fhandle, authFlavors) {
this.fhandle = fhandle;
this.authFlavors = authFlavors;
}
}
exports.MountMntResOk = MountMntResOk;
class MountMntResponse {
constructor(status, mountinfo) {
this.status = status;
this.mountinfo = mountinfo;
}
}
exports.MountMntResponse = MountMntResponse;
class MountDumpRequest {
}
exports.MountDumpRequest = MountDumpRequest;
class MountDumpResponse {
constructor(mountlist) {
this.mountlist = mountlist;
}
}
exports.MountDumpResponse = MountDumpResponse;
class MountUmntRequest {
constructor(dirpath) {
this.dirpath = dirpath;
}
}
exports.MountUmntRequest = MountUmntRequest;
class MountUmntallRequest {
}
exports.MountUmntallRequest = MountUmntallRequest;
class MountExportRequest {
}
exports.MountExportRequest = MountExportRequest;
class MountExportResponse {
constructor(exports) {
this.exports = exports;
}
}
exports.MountExportResponse = MountExportResponse;
//# sourceMappingURL=messages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/nfs/v3/mount/messages.ts"],"names":[],"mappings":";;;AAqBA,MAAa,eAAe;IAC1B,YAA4B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;CAChD;AAFD,0CAEC;AAKD,MAAa,aAAa;IACxB,YACkB,OAA6B,EAC7B,WAAqB;QADrB,YAAO,GAAP,OAAO,CAAsB;QAC7B,gBAAW,GAAX,WAAW,CAAU;IACpC,CAAC;CACL;AALD,sCAKC;AAKD,MAAa,gBAAgB;IAC3B,YACkB,MAAiB,EACjB,SAAyB;QADzB,WAAM,GAAN,MAAM,CAAW;QACjB,cAAS,GAAT,SAAS,CAAgB;IACxC,CAAC;CACL;AALD,4CAKC;AAKD,MAAa,gBAAgB;CAAG;AAAhC,4CAAgC;AAKhC,MAAa,iBAAiB;IAC5B,YAA4B,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;CAC7D;AAFD,8CAEC;AAKD,MAAa,gBAAgB;IAC3B,YAA4B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;CAChD;AAFD,4CAEC;AAKD,MAAa,mBAAmB;CAAG;AAAnC,kDAAmC;AAKnC,MAAa,kBAAkB;CAAG;AAAlC,gDAAkC;AAKlC,MAAa,mBAAmB;IAC9B,YAA4B,OAAgC;QAAhC,YAAO,GAAP,OAAO,CAAyB;IAAG,CAAC;CACjE;AAFD,kDAEC"}

View File

@@ -0,0 +1,22 @@
import type { Reader } from '@jsonjoy.com/buffers/lib/Reader';
export declare class MountFhandle3 {
readonly data: Reader;
constructor(data: Reader);
}
export declare class MountBody {
readonly hostname: string;
readonly directory: string;
readonly next?: MountBody | undefined;
constructor(hostname: string, directory: string, next?: MountBody | undefined);
}
export declare class MountGroupNode {
readonly name: string;
readonly next?: MountGroupNode | undefined;
constructor(name: string, next?: MountGroupNode | undefined);
}
export declare class MountExportNode {
readonly dir: string;
readonly groups?: MountGroupNode | undefined;
readonly next?: MountExportNode | undefined;
constructor(dir: string, groups?: MountGroupNode | undefined, next?: MountExportNode | undefined);
}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MountExportNode = exports.MountGroupNode = exports.MountBody = exports.MountFhandle3 = void 0;
class MountFhandle3 {
constructor(data) {
this.data = data;
}
}
exports.MountFhandle3 = MountFhandle3;
class MountBody {
constructor(hostname, directory, next) {
this.hostname = hostname;
this.directory = directory;
this.next = next;
}
}
exports.MountBody = MountBody;
class MountGroupNode {
constructor(name, next) {
this.name = name;
this.next = next;
}
}
exports.MountGroupNode = MountGroupNode;
class MountExportNode {
constructor(dir, groups, next) {
this.dir = dir;
this.groups = groups;
this.next = next;
}
}
exports.MountExportNode = MountExportNode;
//# sourceMappingURL=structs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../src/nfs/v3/mount/structs.ts"],"names":[],"mappings":";;;AASA,MAAa,aAAa;IACxB,YAA4B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CAC7C;AAFD,sCAEC;AAKD,MAAa,SAAS;IACpB,YACkB,QAAgB,EAChB,SAAiB,EACjB,IAAgB;QAFhB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QACjB,SAAI,GAAJ,IAAI,CAAY;IAC/B,CAAC;CACL;AAND,8BAMC;AAKD,MAAa,cAAc;IACzB,YACkB,IAAY,EACZ,IAAqB;QADrB,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAiB;IACpC,CAAC;CACL;AALD,wCAKC;AAKD,MAAa,eAAe;IAC1B,YACkB,GAAW,EACX,MAAuB,EACvB,IAAsB;QAFtB,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAiB;QACvB,SAAI,GAAJ,IAAI,CAAkB;IACrC,CAAC;CACL;AAND,0CAMC"}

View File

@@ -0,0 +1,155 @@
import type { Nfsv3FType, Nfsv3TimeHow, Nfsv3StableHow, Nfsv3CreateMode } from './constants';
export declare class Nfsv3Time {
readonly seconds: number;
readonly nseconds: number;
constructor(seconds: number, nseconds: number);
}
export declare class Nfsv3SpecData {
readonly specdata1: number;
readonly specdata2: number;
constructor(specdata1: number, specdata2: number);
}
export declare class Nfsv3Fh {
readonly data: Uint8Array;
constructor(data: Uint8Array);
}
export declare class Nfsv3SetMode {
readonly set: boolean;
readonly mode?: number | undefined;
constructor(set: boolean, mode?: number | undefined);
}
export declare class Nfsv3SetUid {
readonly set: boolean;
readonly uid?: number | undefined;
constructor(set: boolean, uid?: number | undefined);
}
export declare class Nfsv3SetGid {
readonly set: boolean;
readonly gid?: number | undefined;
constructor(set: boolean, gid?: number | undefined);
}
export declare class Nfsv3SetSize {
readonly set: boolean;
readonly size?: bigint | undefined;
constructor(set: boolean, size?: bigint | undefined);
}
export declare class Nfsv3SetAtime {
readonly how: Nfsv3TimeHow;
readonly atime?: Nfsv3Time | undefined;
constructor(how: Nfsv3TimeHow, atime?: Nfsv3Time | undefined);
}
export declare class Nfsv3SetMtime {
readonly how: Nfsv3TimeHow;
readonly mtime?: Nfsv3Time | undefined;
constructor(how: Nfsv3TimeHow, mtime?: Nfsv3Time | undefined);
}
export declare class Nfsv3Sattr {
readonly mode: Nfsv3SetMode;
readonly uid: Nfsv3SetUid;
readonly gid: Nfsv3SetGid;
readonly size: Nfsv3SetSize;
readonly atime: Nfsv3SetAtime;
readonly mtime: Nfsv3SetMtime;
constructor(mode: Nfsv3SetMode, uid: Nfsv3SetUid, gid: Nfsv3SetGid, size: Nfsv3SetSize, atime: Nfsv3SetAtime, mtime: Nfsv3SetMtime);
}
export declare class Nfsv3SattrGuard {
readonly check: boolean;
readonly objCtime?: Nfsv3Time | undefined;
constructor(check: boolean, objCtime?: Nfsv3Time | undefined);
}
export declare class Nfsv3DirOpArgs {
readonly dir: Nfsv3Fh;
readonly name: string;
constructor(dir: Nfsv3Fh, name: string);
}
export declare class Nfsv3WccAttr {
readonly size: bigint;
readonly mtime: Nfsv3Time;
readonly ctime: Nfsv3Time;
constructor(size: bigint, mtime: Nfsv3Time, ctime: Nfsv3Time);
}
export declare class Nfsv3PreOpAttr {
readonly attributesFollow: boolean;
readonly attributes?: Nfsv3WccAttr | undefined;
constructor(attributesFollow: boolean, attributes?: Nfsv3WccAttr | undefined);
}
export declare class Nfsv3PostOpAttr {
readonly attributesFollow: boolean;
readonly attributes?: Nfsv3Fattr | undefined;
constructor(attributesFollow: boolean, attributes?: Nfsv3Fattr | undefined);
}
export declare class Nfsv3PostOpFh {
readonly handleFollows: boolean;
readonly handle?: Nfsv3Fh | undefined;
constructor(handleFollows: boolean, handle?: Nfsv3Fh | undefined);
}
export declare class Nfsv3WccData {
readonly before: Nfsv3PreOpAttr;
readonly after: Nfsv3PostOpAttr;
constructor(before: Nfsv3PreOpAttr, after: Nfsv3PostOpAttr);
}
export declare class Nfsv3Fattr {
readonly type: Nfsv3FType;
readonly mode: number;
readonly nlink: number;
readonly uid: number;
readonly gid: number;
readonly size: bigint;
readonly used: bigint;
readonly rdev: Nfsv3SpecData;
readonly fsid: bigint;
readonly fileid: bigint;
readonly atime: Nfsv3Time;
readonly mtime: Nfsv3Time;
readonly ctime: Nfsv3Time;
constructor(type: Nfsv3FType, mode: number, nlink: number, uid: number, gid: number, size: bigint, used: bigint, rdev: Nfsv3SpecData, fsid: bigint, fileid: bigint, atime: Nfsv3Time, mtime: Nfsv3Time, ctime: Nfsv3Time);
}
export declare class Nfsv3DeviceData {
readonly devAttributes: Nfsv3Sattr;
readonly spec: Nfsv3SpecData;
constructor(devAttributes: Nfsv3Sattr, spec: Nfsv3SpecData);
}
export declare class Nfsv3MknodData {
readonly type: Nfsv3FType;
readonly chr?: Nfsv3DeviceData | undefined;
readonly blk?: Nfsv3DeviceData | undefined;
readonly sock?: Nfsv3Sattr | undefined;
readonly pipe?: Nfsv3Sattr | undefined;
constructor(type: Nfsv3FType, chr?: Nfsv3DeviceData | undefined, blk?: Nfsv3DeviceData | undefined, sock?: Nfsv3Sattr | undefined, pipe?: Nfsv3Sattr | undefined);
}
export declare class Nfsv3CreateHow {
readonly mode: Nfsv3CreateMode;
readonly objAttributes?: Nfsv3Sattr | undefined;
readonly verf?: Uint8Array | undefined;
constructor(mode: Nfsv3CreateMode, objAttributes?: Nfsv3Sattr | undefined, verf?: Uint8Array | undefined);
}
export declare class Nfsv3WriteHow {
readonly stable: Nfsv3StableHow;
constructor(stable: Nfsv3StableHow);
}
export declare class Nfsv3Entry {
readonly fileid: bigint;
readonly name: string;
readonly cookie: bigint;
readonly nextentry?: Nfsv3Entry | undefined;
constructor(fileid: bigint, name: string, cookie: bigint, nextentry?: Nfsv3Entry | undefined);
}
export declare class Nfsv3EntryPlus {
readonly fileid: bigint;
readonly name: string;
readonly cookie: bigint;
readonly nameAttributes: Nfsv3PostOpAttr;
readonly nameHandle: Nfsv3PostOpFh;
readonly nextentry?: Nfsv3EntryPlus | undefined;
constructor(fileid: bigint, name: string, cookie: bigint, nameAttributes: Nfsv3PostOpAttr, nameHandle: Nfsv3PostOpFh, nextentry?: Nfsv3EntryPlus | undefined);
}
export declare class Nfsv3DirList {
readonly eof: boolean;
readonly entries?: Nfsv3Entry | undefined;
constructor(eof: boolean, entries?: Nfsv3Entry | undefined);
}
export declare class Nfsv3DirListPlus {
readonly eof: boolean;
readonly entries?: Nfsv3EntryPlus | undefined;
constructor(eof: boolean, entries?: Nfsv3EntryPlus | undefined);
}

View File

@@ -0,0 +1,210 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv3DirListPlus = exports.Nfsv3DirList = exports.Nfsv3EntryPlus = exports.Nfsv3Entry = exports.Nfsv3WriteHow = exports.Nfsv3CreateHow = exports.Nfsv3MknodData = exports.Nfsv3DeviceData = exports.Nfsv3Fattr = exports.Nfsv3WccData = exports.Nfsv3PostOpFh = exports.Nfsv3PostOpAttr = exports.Nfsv3PreOpAttr = exports.Nfsv3WccAttr = exports.Nfsv3DirOpArgs = exports.Nfsv3SattrGuard = exports.Nfsv3Sattr = exports.Nfsv3SetMtime = exports.Nfsv3SetAtime = exports.Nfsv3SetSize = exports.Nfsv3SetGid = exports.Nfsv3SetUid = exports.Nfsv3SetMode = exports.Nfsv3Fh = exports.Nfsv3SpecData = exports.Nfsv3Time = void 0;
class Nfsv3Time {
constructor(seconds, nseconds) {
this.seconds = seconds;
this.nseconds = nseconds;
}
}
exports.Nfsv3Time = Nfsv3Time;
class Nfsv3SpecData {
constructor(specdata1, specdata2) {
this.specdata1 = specdata1;
this.specdata2 = specdata2;
}
}
exports.Nfsv3SpecData = Nfsv3SpecData;
class Nfsv3Fh {
constructor(data) {
this.data = data;
}
}
exports.Nfsv3Fh = Nfsv3Fh;
class Nfsv3SetMode {
constructor(set, mode) {
this.set = set;
this.mode = mode;
}
}
exports.Nfsv3SetMode = Nfsv3SetMode;
class Nfsv3SetUid {
constructor(set, uid) {
this.set = set;
this.uid = uid;
}
}
exports.Nfsv3SetUid = Nfsv3SetUid;
class Nfsv3SetGid {
constructor(set, gid) {
this.set = set;
this.gid = gid;
}
}
exports.Nfsv3SetGid = Nfsv3SetGid;
class Nfsv3SetSize {
constructor(set, size) {
this.set = set;
this.size = size;
}
}
exports.Nfsv3SetSize = Nfsv3SetSize;
class Nfsv3SetAtime {
constructor(how, atime) {
this.how = how;
this.atime = atime;
}
}
exports.Nfsv3SetAtime = Nfsv3SetAtime;
class Nfsv3SetMtime {
constructor(how, mtime) {
this.how = how;
this.mtime = mtime;
}
}
exports.Nfsv3SetMtime = Nfsv3SetMtime;
class Nfsv3Sattr {
constructor(mode, uid, gid, size, atime, mtime) {
this.mode = mode;
this.uid = uid;
this.gid = gid;
this.size = size;
this.atime = atime;
this.mtime = mtime;
}
}
exports.Nfsv3Sattr = Nfsv3Sattr;
class Nfsv3SattrGuard {
constructor(check, objCtime) {
this.check = check;
this.objCtime = objCtime;
}
}
exports.Nfsv3SattrGuard = Nfsv3SattrGuard;
class Nfsv3DirOpArgs {
constructor(dir, name) {
this.dir = dir;
this.name = name;
}
}
exports.Nfsv3DirOpArgs = Nfsv3DirOpArgs;
class Nfsv3WccAttr {
constructor(size, mtime, ctime) {
this.size = size;
this.mtime = mtime;
this.ctime = ctime;
}
}
exports.Nfsv3WccAttr = Nfsv3WccAttr;
class Nfsv3PreOpAttr {
constructor(attributesFollow, attributes) {
this.attributesFollow = attributesFollow;
this.attributes = attributes;
}
}
exports.Nfsv3PreOpAttr = Nfsv3PreOpAttr;
class Nfsv3PostOpAttr {
constructor(attributesFollow, attributes) {
this.attributesFollow = attributesFollow;
this.attributes = attributes;
}
}
exports.Nfsv3PostOpAttr = Nfsv3PostOpAttr;
class Nfsv3PostOpFh {
constructor(handleFollows, handle) {
this.handleFollows = handleFollows;
this.handle = handle;
}
}
exports.Nfsv3PostOpFh = Nfsv3PostOpFh;
class Nfsv3WccData {
constructor(before, after) {
this.before = before;
this.after = after;
}
}
exports.Nfsv3WccData = Nfsv3WccData;
class Nfsv3Fattr {
constructor(type, mode, nlink, uid, gid, size, used, rdev, fsid, fileid, atime, mtime, ctime) {
this.type = type;
this.mode = mode;
this.nlink = nlink;
this.uid = uid;
this.gid = gid;
this.size = size;
this.used = used;
this.rdev = rdev;
this.fsid = fsid;
this.fileid = fileid;
this.atime = atime;
this.mtime = mtime;
this.ctime = ctime;
}
}
exports.Nfsv3Fattr = Nfsv3Fattr;
class Nfsv3DeviceData {
constructor(devAttributes, spec) {
this.devAttributes = devAttributes;
this.spec = spec;
}
}
exports.Nfsv3DeviceData = Nfsv3DeviceData;
class Nfsv3MknodData {
constructor(type, chr, blk, sock, pipe) {
this.type = type;
this.chr = chr;
this.blk = blk;
this.sock = sock;
this.pipe = pipe;
}
}
exports.Nfsv3MknodData = Nfsv3MknodData;
class Nfsv3CreateHow {
constructor(mode, objAttributes, verf) {
this.mode = mode;
this.objAttributes = objAttributes;
this.verf = verf;
}
}
exports.Nfsv3CreateHow = Nfsv3CreateHow;
class Nfsv3WriteHow {
constructor(stable) {
this.stable = stable;
}
}
exports.Nfsv3WriteHow = Nfsv3WriteHow;
class Nfsv3Entry {
constructor(fileid, name, cookie, nextentry) {
this.fileid = fileid;
this.name = name;
this.cookie = cookie;
this.nextentry = nextentry;
}
}
exports.Nfsv3Entry = Nfsv3Entry;
class Nfsv3EntryPlus {
constructor(fileid, name, cookie, nameAttributes, nameHandle, nextentry) {
this.fileid = fileid;
this.name = name;
this.cookie = cookie;
this.nameAttributes = nameAttributes;
this.nameHandle = nameHandle;
this.nextentry = nextentry;
}
}
exports.Nfsv3EntryPlus = Nfsv3EntryPlus;
class Nfsv3DirList {
constructor(eof, entries) {
this.eof = eof;
this.entries = entries;
}
}
exports.Nfsv3DirList = Nfsv3DirList;
class Nfsv3DirListPlus {
constructor(eof, entries) {
this.eof = eof;
this.entries = entries;
}
}
exports.Nfsv3DirListPlus = Nfsv3DirListPlus;
//# sourceMappingURL=structs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../src/nfs/v3/structs.ts"],"names":[],"mappings":";;;AAKA,MAAa,SAAS;IACpB,YACkB,OAAe,EACf,QAAgB;QADhB,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAQ;IAC/B,CAAC;CACL;AALD,8BAKC;AAKD,MAAa,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AtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;CACvD;AAFD,sCAEC;AAKD,MAAa,UAAU;IACrB,YACkB,MAAc,EACd,IAAY,EACZ,MAAc,EACd,SAAsB;QAHtB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAa;IACrC,CAAC;CACL;AAPD,gCAOC;AAKD,MAAa,cAAc;IACzB,YACkB,MAAc,EACd,IAAY,EACZ,MAAc,EACd,cAA+B,EAC/B,UAAyB,EACzB,SAA0B;QAL1B,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,mBAAc,GAAd,cAAc,CAAiB;QAC/B,eAAU,GAAV,UAAU,CAAe;QACzB,cAAS,GAAT,SAAS,CAAiB;IACzC,CAAC;CACL;AATD,wCASC;AAKD,MAAa,YAAY;IACvB,YACkB,GAAY,EACZ,OAAoB;QADpB,QAAG,GAAH,GAAG,CAAS;QACZ,YAAO,GAAP,OAAO,CAAa;IACnC,CAAC;CACL;AALD,oCAKC;AAKD,MAAa,gBAAgB;IAC3B,YACkB,GAAY,EACZ,OAAwB;QADxB,QAAG,GAAH,GAAG,CAAS;QACZ,YAAO,GAAP,OAAO,CAAiB;IACvC,CAAC;CACL;AALD,4CAKC"}

View File

@@ -0,0 +1,110 @@
import { Reader } from '@jsonjoy.com/buffers/lib/Reader';
import { XdrDecoder } from '../../xdr/XdrDecoder';
import * as msg from './messages';
export declare class Nfsv4Decoder {
protected readonly xdr: XdrDecoder;
constructor(reader?: Reader);
decodeCompound(reader: Reader, isRequest: boolean): msg.Nfsv4CompoundRequest | msg.Nfsv4CompoundResponse | undefined;
decodeCompoundRequest(reader: Reader): msg.Nfsv4CompoundRequest;
decodeCompoundResponse(reader: Reader): msg.Nfsv4CompoundResponse;
private decodeRequest;
private decodeResponse;
private readFh;
private readVerifier;
private readStateid;
private readBitmap;
private readFattr;
private readChangeInfo;
private readClientAddr;
private readCbClient;
private readClientId;
private readOpenOwner;
private readLockOwner;
private readOpenToLockOwner;
private readLockOwnerInfo;
private readOpenClaim;
private readOpenHow;
private readOpenDelegation;
private readAce;
private readSecInfoFlavor;
private decodeAccessResponse;
private decodeCloseRequest;
private decodeCloseResponse;
private decodeCommitResponse;
private decodeCreateRequest;
private decodeCreateResponse;
private decodeDelegpurgeResponse;
private decodeDelegreturnResponse;
private decodeGetattrRequest;
private decodeGetattrResponse;
private decodeGetfhRequest;
private decodeGetfhResponse;
private decodeLinkRequest;
private decodeLinkResponse;
private decodeLockRequest;
private decodeLockResponse;
private decodeLocktRequest;
private decodeLocktResponse;
private decodeLockuRequest;
private decodeLockuResponse;
private decodeLookupRequest;
private decodeLookupResponse;
private decodeLookuppRequest;
private decodeLookuppResponse;
private decodeNverifyRequest;
private decodeNverifyResponse;
private decodeOpenRequest;
private decodeOpenResponse;
private decodeOpenattrRequest;
private decodeOpenattrResponse;
private decodeOpenConfirmRequest;
private decodeOpenConfirmResponse;
private decodeOpenDowngradeRequest;
private decodeOpenDowngradeResponse;
private decodePutfhRequest;
private decodePutfhResponse;
private decodePutrootfhResponse;
private decodeReadRequest;
private decodeReadResponse;
private decodeReaddirRequest;
private decodeReaddirResponse;
private decodeReadlinkRequest;
private decodeReadlinkResponse;
private decodeRemoveRequest;
private decodeRemoveResponse;
private decodeRenameRequest;
private decodeRenameResponse;
private decodeRenewRequest;
private decodeRenewResponse;
private decodeRestorefhRequest;
private decodeRestorefhResponse;
private decodeSavefhRequest;
private decodeSavefhResponse;
private decodeSecinfoRequest;
private decodeSecinfoResponse;
private decodeSetattrRequest;
private decodeSetattrResponse;
private decodeSetclientidRequest;
private decodeSetclientidResponse;
private decodeSetclientidConfirmRequest;
private decodeSetclientidConfirmResponse;
private decodeVerifyRequest;
private decodeVerifyResponse;
private decodeWriteRequest;
private decodeWriteResponse;
private decodeReleaseLockOwnerRequest;
private decodeReleaseLockOwnerResponse;
private decodeIllegalRequest;
private decodeIllegalResponse;
decodeCbCompound(reader: Reader, isRequest: boolean): msg.Nfsv4CbCompoundRequest | msg.Nfsv4CbCompoundResponse | undefined;
private decodeCbCompoundRequest;
private decodeCbCompoundResponse;
private decodeCbRequest;
private decodeCbResponse;
private decodeCbGetattrRequest;
private decodeCbGetattrResponse;
private decodeCbRecallRequest;
private decodeCbRecallResponse;
private decodeCbIllegalRequest;
private decodeCbIllegalResponse;
}

View File

@@ -0,0 +1,966 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv4Decoder = void 0;
const tslib_1 = require("tslib");
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
const XdrDecoder_1 = require("../../xdr/XdrDecoder");
const errors_1 = require("./errors");
const msg = tslib_1.__importStar(require("./messages"));
const structs = tslib_1.__importStar(require("./structs"));
class Nfsv4Decoder {
constructor(reader = new Reader_1.Reader()) {
this.xdr = new XdrDecoder_1.XdrDecoder(reader);
}
decodeCompound(reader, isRequest) {
if (isRequest) {
return this.decodeCompoundRequest(reader);
}
else {
return this.decodeCompoundResponse(reader);
}
}
decodeCompoundRequest(reader) {
const xdr = this.xdr;
xdr.reader = reader;
const tag = xdr.readString();
const minorversion = xdr.readUnsignedInt();
const argarray = [];
const count = xdr.readUnsignedInt();
for (let i = 0; i < count; i++) {
const op = xdr.readUnsignedInt();
const request = this.decodeRequest(op);
if (request)
argarray.push(request);
}
return new msg.Nfsv4CompoundRequest(tag, minorversion, argarray);
}
decodeCompoundResponse(reader) {
const xdr = this.xdr;
xdr.reader = reader;
const status = xdr.readUnsignedInt();
const tag = xdr.readString();
const resarray = [];
const count = xdr.readUnsignedInt();
for (let i = 0; i < count; i++) {
const op = xdr.readUnsignedInt();
const response = this.decodeResponse(op);
if (response)
resarray.push(response);
}
return new msg.Nfsv4CompoundResponse(status, tag, resarray);
}
decodeRequest(op) {
const xdr = this.xdr;
switch (op) {
case 3:
return msg.Nfsv4AccessRequest.decode(xdr);
case 4:
return msg.Nfsv4CloseRequest.decode(xdr);
case 5:
return msg.Nfsv4CommitRequest.decode(xdr);
case 6:
return this.decodeCreateRequest();
case 7:
return msg.Nfsv4DelegpurgeRequest.decode(xdr);
case 8:
return msg.Nfsv4DelegreturnRequest.decode(xdr);
case 9:
return this.decodeGetattrRequest();
case 10:
return this.decodeGetfhRequest();
case 11:
return this.decodeLinkRequest();
case 12:
return this.decodeLockRequest();
case 13:
return this.decodeLocktRequest();
case 14:
return this.decodeLockuRequest();
case 15:
return this.decodeLookupRequest();
case 16:
return this.decodeLookuppRequest();
case 17:
return this.decodeNverifyRequest();
case 18:
return this.decodeOpenRequest();
case 19:
return this.decodeOpenattrRequest();
case 20:
return this.decodeOpenConfirmRequest();
case 21:
return this.decodeOpenDowngradeRequest();
case 22:
return this.decodePutfhRequest();
case 23:
return new msg.Nfsv4PutpubfhRequest();
case 24:
return new msg.Nfsv4PutrootfhRequest();
case 25:
return this.decodeReadRequest();
case 26:
return this.decodeReaddirRequest();
case 27:
return this.decodeReadlinkRequest();
case 28:
return this.decodeRemoveRequest();
case 29:
return this.decodeRenameRequest();
case 30:
return this.decodeRenewRequest();
case 31:
return this.decodeRestorefhRequest();
case 32:
return new msg.Nfsv4SavefhRequest();
case 33:
return this.decodeSecinfoRequest();
case 34:
return this.decodeSetattrRequest();
case 35:
return this.decodeSetclientidRequest();
case 36:
return this.decodeSetclientidConfirmRequest();
case 37:
return this.decodeVerifyRequest();
case 38:
return this.decodeWriteRequest();
case 39:
return this.decodeReleaseLockOwnerRequest();
case 10044:
return this.decodeIllegalRequest();
default:
return this.decodeIllegalRequest();
}
}
decodeResponse(op) {
const xdr = this.xdr;
switch (op) {
case 3:
return this.decodeAccessResponse();
case 4:
return this.decodeCloseResponse();
case 5:
return this.decodeCommitResponse();
case 6:
return this.decodeCreateResponse();
case 7:
return this.decodeDelegpurgeResponse();
case 8:
return this.decodeDelegreturnResponse();
case 9:
return this.decodeGetattrResponse();
case 10:
return this.decodeGetfhResponse();
case 11:
return this.decodeLinkResponse();
case 12:
return this.decodeLockResponse();
case 13:
return this.decodeLocktResponse();
case 14:
return this.decodeLockuResponse();
case 15:
return this.decodeLookupResponse();
case 16:
return this.decodeLookuppResponse();
case 17:
return this.decodeNverifyResponse();
case 18:
return this.decodeOpenResponse();
case 19:
return this.decodeOpenattrResponse();
case 20:
return this.decodeOpenConfirmResponse();
case 21:
return this.decodeOpenDowngradeResponse();
case 22:
return this.decodePutfhResponse();
case 23:
return msg.Nfsv4PutpubfhResponse.decode(xdr);
case 24:
return this.decodePutrootfhResponse();
case 25:
return this.decodeReadResponse();
case 26:
return this.decodeReaddirResponse();
case 27:
return this.decodeReadlinkResponse();
case 28:
return this.decodeRemoveResponse();
case 29:
return this.decodeRenameResponse();
case 30:
return this.decodeRenewResponse();
case 31:
return this.decodeRestorefhResponse();
case 32:
return this.decodeSavefhResponse();
case 33:
return this.decodeSecinfoResponse();
case 34:
return this.decodeSetattrResponse();
case 35:
return this.decodeSetclientidResponse();
case 36:
return this.decodeSetclientidConfirmResponse();
case 37:
return this.decodeVerifyResponse();
case 38:
return this.decodeWriteResponse();
case 39:
return this.decodeReleaseLockOwnerResponse();
case 10044:
return this.decodeIllegalResponse();
default:
return this.decodeIllegalResponse();
}
}
readFh() {
const data = this.xdr.readVarlenOpaque();
return new structs.Nfsv4Fh(data);
}
readVerifier() {
const data = this.xdr.readOpaque(8);
return new structs.Nfsv4Verifier(data);
}
readStateid() {
return structs.Nfsv4Stateid.decode(this.xdr);
}
readBitmap() {
const xdr = this.xdr;
const count = xdr.readUnsignedInt();
if (count > 8)
throw 10036;
const mask = [];
for (let i = 0; i < count; i++)
mask.push(xdr.readUnsignedInt());
return new structs.Nfsv4Bitmap(mask);
}
readFattr() {
const attrmask = this.readBitmap();
const attrVals = this.xdr.readVarlenOpaque();
return new structs.Nfsv4Fattr(attrmask, attrVals);
}
readChangeInfo() {
const xdr = this.xdr;
const atomic = xdr.readBoolean();
const before = xdr.readUnsignedHyper();
const after = xdr.readUnsignedHyper();
return new structs.Nfsv4ChangeInfo(atomic, before, after);
}
readClientAddr() {
const xdr = this.xdr;
const rNetid = xdr.readString();
const rAddr = xdr.readString();
return new structs.Nfsv4ClientAddr(rNetid, rAddr);
}
readCbClient() {
const cbProgram = this.xdr.readUnsignedInt();
const cbLocation = this.readClientAddr();
return new structs.Nfsv4CbClient(cbProgram, cbLocation);
}
readClientId() {
const verifier = this.readVerifier();
const id = this.xdr.readVarlenOpaque();
return new structs.Nfsv4ClientId(verifier, id);
}
readOpenOwner() {
const xdr = this.xdr;
const clientid = xdr.readUnsignedHyper();
const owner = xdr.readVarlenOpaque();
return new structs.Nfsv4OpenOwner(clientid, owner);
}
readLockOwner() {
const xdr = this.xdr;
const clientid = xdr.readUnsignedHyper();
const owner = xdr.readVarlenOpaque();
return new structs.Nfsv4LockOwner(clientid, owner);
}
readOpenToLockOwner() {
const xdr = this.xdr;
const openSeqid = xdr.readUnsignedInt();
const openStateid = this.readStateid();
const lockSeqid = xdr.readUnsignedInt();
const lockOwner = this.readLockOwner();
return new structs.Nfsv4OpenToLockOwner(openSeqid, openStateid, lockSeqid, lockOwner);
}
readLockOwnerInfo() {
const xdr = this.xdr;
const newLockOwner = xdr.readBoolean();
if (newLockOwner) {
const openToLockOwner = this.readOpenToLockOwner();
return new structs.Nfsv4LockOwnerInfo(true, new structs.Nfsv4LockNewOwner(openToLockOwner));
}
else {
const lockStateid = this.readStateid();
const lockSeqid = xdr.readUnsignedInt();
return new structs.Nfsv4LockOwnerInfo(false, new structs.Nfsv4LockExistingOwner(lockStateid, lockSeqid));
}
}
readOpenClaim() {
const xdr = this.xdr;
const claimType = xdr.readUnsignedInt();
switch (claimType) {
case 0: {
const file = xdr.readString();
return new structs.Nfsv4OpenClaim(claimType, new structs.Nfsv4OpenClaimNull(file));
}
case 1: {
const delegateType = xdr.readUnsignedInt();
return new structs.Nfsv4OpenClaim(claimType, new structs.Nfsv4OpenClaimPrevious(delegateType));
}
case 2: {
const delegateStateid = this.readStateid();
const file = xdr.readString();
return new structs.Nfsv4OpenClaim(claimType, new structs.Nfsv4OpenClaimDelegateCur(delegateStateid, file));
}
case 3: {
const file = xdr.readString();
return new structs.Nfsv4OpenClaim(claimType, new structs.Nfsv4OpenClaimDelegatePrev(file));
}
default:
throw new errors_1.Nfsv4DecodingError(`Unknown open claim type: ${claimType}`);
}
}
readOpenHow() {
const xdr = this.xdr;
const opentype = xdr.readUnsignedInt();
if (opentype === 0)
return new structs.Nfsv4OpenHow(opentype);
const mode = xdr.readUnsignedInt();
switch (mode) {
case 0:
case 1: {
const createattrs = this.readFattr();
return new structs.Nfsv4OpenHow(opentype, new structs.Nfsv4CreateHow(mode, new structs.Nfsv4CreateAttrs(createattrs)));
}
case 2: {
const createverf = this.readVerifier();
return new structs.Nfsv4OpenHow(opentype, new structs.Nfsv4CreateHow(mode, new structs.Nfsv4CreateVerf(createverf)));
}
default:
throw new errors_1.Nfsv4DecodingError(`Unknown create mode: ${mode}`);
}
}
readOpenDelegation() {
const xdr = this.xdr;
const delegationType = xdr.readUnsignedInt();
switch (delegationType) {
case 0:
return new structs.Nfsv4OpenDelegation(delegationType);
case 1: {
const stateid = this.readStateid();
const recall = xdr.readBoolean();
const aceCount = xdr.readUnsignedInt();
const permissions = [];
for (let i = 0; i < aceCount; i++) {
permissions.push(this.readAce());
}
return new structs.Nfsv4OpenDelegation(delegationType, new structs.Nfsv4OpenReadDelegation(stateid, recall, permissions));
}
case 2: {
const stateid = this.readStateid();
const recall = xdr.readBoolean();
const spaceLimit = xdr.readUnsignedHyper();
const aceCount = xdr.readUnsignedInt();
const permissions = [];
for (let i = 0; i < aceCount; i++) {
permissions.push(this.readAce());
}
return new structs.Nfsv4OpenDelegation(delegationType, new structs.Nfsv4OpenWriteDelegation(stateid, recall, spaceLimit, permissions));
}
default:
throw new errors_1.Nfsv4DecodingError(`Unknown delegation type: ${delegationType}`);
}
}
readAce() {
const xdr = this.xdr;
const type = xdr.readUnsignedInt();
const flag = xdr.readUnsignedInt();
const accessMask = xdr.readUnsignedInt();
const who = xdr.readString();
return new structs.Nfsv4Ace(type, flag, accessMask, who);
}
readSecInfoFlavor() {
const xdr = this.xdr;
const flavor = xdr.readUnsignedInt();
if (flavor === 6) {
const oid = xdr.readVarlenOpaque();
const qop = xdr.readUnsignedInt();
const service = xdr.readUnsignedInt();
const flavorInfo = new structs.Nfsv4RpcSecGssInfo(oid, qop, service);
return new structs.Nfsv4SecInfoFlavor(flavor, flavorInfo);
}
return new structs.Nfsv4SecInfoFlavor(flavor);
}
decodeAccessResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const supported = xdr.readUnsignedInt();
const access = xdr.readUnsignedInt();
return new msg.Nfsv4AccessResponse(status, new msg.Nfsv4AccessResOk(supported, access));
}
return new msg.Nfsv4AccessResponse(status);
}
decodeCloseRequest() {
const xdr = this.xdr;
const seqid = xdr.readUnsignedInt();
const openStateid = this.readStateid();
return new msg.Nfsv4CloseRequest(seqid, openStateid);
}
decodeCloseResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const openStateid = this.readStateid();
return new msg.Nfsv4CloseResponse(status, new msg.Nfsv4CloseResOk(openStateid));
}
return new msg.Nfsv4CloseResponse(status);
}
decodeCommitResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const writeverf = this.readVerifier();
return new msg.Nfsv4CommitResponse(status, new msg.Nfsv4CommitResOk(writeverf));
}
return new msg.Nfsv4CommitResponse(status);
}
decodeCreateRequest() {
const xdr = this.xdr;
const type = xdr.readUnsignedInt();
let objtype;
switch (type) {
case 5: {
const linkdata = xdr.readString();
objtype = new structs.Nfsv4CreateType(type, new structs.Nfsv4CreateTypeLink(linkdata));
break;
}
case 3:
case 4: {
const specdata1 = xdr.readUnsignedInt();
const specdata2 = xdr.readUnsignedInt();
const devdata = new structs.Nfsv4SpecData(specdata1, specdata2);
objtype = new structs.Nfsv4CreateType(type, new structs.Nfsv4CreateTypeDevice(devdata));
break;
}
default: {
objtype = new structs.Nfsv4CreateType(type, new structs.Nfsv4CreateTypeVoid());
break;
}
}
const objname = xdr.readString();
const createattrs = this.readFattr();
return new msg.Nfsv4CreateRequest(objtype, objname, createattrs);
}
decodeCreateResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const cinfo = this.readChangeInfo();
const attrset = this.readBitmap();
return new msg.Nfsv4CreateResponse(status, new msg.Nfsv4CreateResOk(cinfo, attrset));
}
return new msg.Nfsv4CreateResponse(status);
}
decodeDelegpurgeResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4DelegpurgeResponse(status);
}
decodeDelegreturnResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4DelegreturnResponse(status);
}
decodeGetattrRequest() {
const attrRequest = this.readBitmap();
return new msg.Nfsv4GetattrRequest(attrRequest);
}
decodeGetattrResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const objAttributes = this.readFattr();
return new msg.Nfsv4GetattrResponse(status, new msg.Nfsv4GetattrResOk(objAttributes));
}
return new msg.Nfsv4GetattrResponse(status);
}
decodeGetfhRequest() {
return new msg.Nfsv4GetfhRequest();
}
decodeGetfhResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const object = this.readFh();
return new msg.Nfsv4GetfhResponse(status, new msg.Nfsv4GetfhResOk(object));
}
return new msg.Nfsv4GetfhResponse(status);
}
decodeLinkRequest() {
const newname = this.xdr.readString();
return new msg.Nfsv4LinkRequest(newname);
}
decodeLinkResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const cinfo = this.readChangeInfo();
return new msg.Nfsv4LinkResponse(status, new msg.Nfsv4LinkResOk(cinfo));
}
return new msg.Nfsv4LinkResponse(status);
}
decodeLockRequest() {
const xdr = this.xdr;
const locktype = xdr.readUnsignedInt();
const reclaim = xdr.readBoolean();
const offset = xdr.readUnsignedHyper();
const length = xdr.readUnsignedHyper();
const locker = this.readLockOwnerInfo();
return new msg.Nfsv4LockRequest(locktype, reclaim, offset, length, locker);
}
decodeLockResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const lockStateid = this.readStateid();
return new msg.Nfsv4LockResponse(status, new msg.Nfsv4LockResOk(lockStateid));
}
else if (status === 10010) {
const offset = xdr.readUnsignedHyper();
const length = xdr.readUnsignedHyper();
const locktype = xdr.readUnsignedInt();
const owner = this.readLockOwner();
return new msg.Nfsv4LockResponse(status, undefined, new msg.Nfsv4LockResDenied(offset, length, locktype, owner));
}
return new msg.Nfsv4LockResponse(status);
}
decodeLocktRequest() {
const xdr = this.xdr;
const locktype = xdr.readUnsignedInt();
const offset = xdr.readUnsignedHyper();
const length = xdr.readUnsignedHyper();
const owner = this.readLockOwner();
return new msg.Nfsv4LocktRequest(locktype, offset, length, owner);
}
decodeLocktResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 10010) {
const offset = xdr.readUnsignedHyper();
const length = xdr.readUnsignedHyper();
const locktype = xdr.readUnsignedInt();
const owner = this.readLockOwner();
return new msg.Nfsv4LocktResponse(status, new msg.Nfsv4LocktResDenied(offset, length, locktype, owner));
}
return new msg.Nfsv4LocktResponse(status);
}
decodeLockuRequest() {
const xdr = this.xdr;
const locktype = xdr.readUnsignedInt();
const seqid = xdr.readUnsignedInt();
const lockStateid = this.readStateid();
const offset = xdr.readUnsignedHyper();
const length = xdr.readUnsignedHyper();
return new msg.Nfsv4LockuRequest(locktype, seqid, lockStateid, offset, length);
}
decodeLockuResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const lockStateid = this.readStateid();
return new msg.Nfsv4LockuResponse(status, new msg.Nfsv4LockuResOk(lockStateid));
}
return new msg.Nfsv4LockuResponse(status);
}
decodeLookupRequest() {
const objname = this.xdr.readString();
return new msg.Nfsv4LookupRequest(objname);
}
decodeLookupResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4LookupResponse(status);
}
decodeLookuppRequest() {
return new msg.Nfsv4LookuppRequest();
}
decodeLookuppResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4LookuppResponse(status);
}
decodeNverifyRequest() {
const objAttributes = this.readFattr();
return new msg.Nfsv4NverifyRequest(objAttributes);
}
decodeNverifyResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4NverifyResponse(status);
}
decodeOpenRequest() {
const xdr = this.xdr;
const seqid = xdr.readUnsignedInt();
const shareAccess = xdr.readUnsignedInt();
const shareDeny = xdr.readUnsignedInt();
const owner = this.readOpenOwner();
const openhow = this.readOpenHow();
const claim = this.readOpenClaim();
return new msg.Nfsv4OpenRequest(seqid, shareAccess, shareDeny, owner, openhow, claim);
}
decodeOpenResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const stateid = this.readStateid();
const cinfo = this.readChangeInfo();
const rflags = xdr.readUnsignedInt();
const attrset = this.readBitmap();
const delegation = this.readOpenDelegation();
return new msg.Nfsv4OpenResponse(status, new msg.Nfsv4OpenResOk(stateid, cinfo, rflags, attrset, delegation));
}
return new msg.Nfsv4OpenResponse(status);
}
decodeOpenattrRequest() {
const createdir = this.xdr.readBoolean();
return new msg.Nfsv4OpenattrRequest(createdir);
}
decodeOpenattrResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4OpenattrResponse(status);
}
decodeOpenConfirmRequest() {
const openStateid = this.readStateid();
const seqid = this.xdr.readUnsignedInt();
return new msg.Nfsv4OpenConfirmRequest(openStateid, seqid);
}
decodeOpenConfirmResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const openStateid = this.readStateid();
return new msg.Nfsv4OpenConfirmResponse(status, new msg.Nfsv4OpenConfirmResOk(openStateid));
}
return new msg.Nfsv4OpenConfirmResponse(status);
}
decodeOpenDowngradeRequest() {
const xdr = this.xdr;
const openStateid = this.readStateid();
const seqid = xdr.readUnsignedInt();
const shareAccess = xdr.readUnsignedInt();
const shareDeny = xdr.readUnsignedInt();
return new msg.Nfsv4OpenDowngradeRequest(openStateid, seqid, shareAccess, shareDeny);
}
decodeOpenDowngradeResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const openStateid = this.readStateid();
return new msg.Nfsv4OpenDowngradeResponse(status, new msg.Nfsv4OpenDowngradeResOk(openStateid));
}
return new msg.Nfsv4OpenDowngradeResponse(status);
}
decodePutfhRequest() {
const object = this.readFh();
return new msg.Nfsv4PutfhRequest(object);
}
decodePutfhResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4PutfhResponse(status);
}
decodePutrootfhResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4PutrootfhResponse(status);
}
decodeReadRequest() {
const xdr = this.xdr;
const stateid = this.readStateid();
const offset = xdr.readUnsignedHyper();
const count = xdr.readUnsignedInt();
return new msg.Nfsv4ReadRequest(stateid, offset, count);
}
decodeReadResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const eof = xdr.readBoolean();
const data = xdr.readVarlenOpaque();
return new msg.Nfsv4ReadResponse(status, new msg.Nfsv4ReadResOk(eof, data));
}
return new msg.Nfsv4ReadResponse(status);
}
decodeReaddirRequest() {
const xdr = this.xdr;
const cookie = xdr.readUnsignedHyper();
const cookieverf = this.readVerifier();
const dircount = xdr.readUnsignedInt();
const maxcount = xdr.readUnsignedInt();
const attrRequest = this.readBitmap();
return new msg.Nfsv4ReaddirRequest(cookie, cookieverf, dircount, maxcount, attrRequest);
}
decodeReaddirResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const cookieverf = this.readVerifier();
const entries = [];
while (xdr.readBoolean()) {
const cookie = xdr.readUnsignedHyper();
const name = xdr.readString();
const attrs = this.readFattr();
entries.push(new structs.Nfsv4Entry(cookie, name, attrs));
}
const eof = xdr.readBoolean();
return new msg.Nfsv4ReaddirResponse(status, new msg.Nfsv4ReaddirResOk(cookieverf, entries, eof));
}
return new msg.Nfsv4ReaddirResponse(status);
}
decodeReadlinkRequest() {
return new msg.Nfsv4ReadlinkRequest();
}
decodeReadlinkResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const link = xdr.readString();
return new msg.Nfsv4ReadlinkResponse(status, new msg.Nfsv4ReadlinkResOk(link));
}
return new msg.Nfsv4ReadlinkResponse(status);
}
decodeRemoveRequest() {
const target = this.xdr.readString();
return new msg.Nfsv4RemoveRequest(target);
}
decodeRemoveResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const cinfo = this.readChangeInfo();
return new msg.Nfsv4RemoveResponse(status, new msg.Nfsv4RemoveResOk(cinfo));
}
return new msg.Nfsv4RemoveResponse(status);
}
decodeRenameRequest() {
const xdr = this.xdr;
const oldname = xdr.readString();
const newname = xdr.readString();
return new msg.Nfsv4RenameRequest(oldname, newname);
}
decodeRenameResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const sourceCinfo = this.readChangeInfo();
const targetCinfo = this.readChangeInfo();
return new msg.Nfsv4RenameResponse(status, new msg.Nfsv4RenameResOk(sourceCinfo, targetCinfo));
}
return new msg.Nfsv4RenameResponse(status);
}
decodeRenewRequest() {
const clientid = this.xdr.readUnsignedHyper();
return new msg.Nfsv4RenewRequest(clientid);
}
decodeRenewResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4RenewResponse(status);
}
decodeRestorefhRequest() {
return new msg.Nfsv4RestorefhRequest();
}
decodeRestorefhResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4RestorefhResponse(status);
}
decodeSavefhRequest() {
return new msg.Nfsv4SavefhRequest();
}
decodeSavefhResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4SavefhResponse(status);
}
decodeSecinfoRequest() {
const name = this.xdr.readString();
return new msg.Nfsv4SecinfoRequest(name);
}
decodeSecinfoResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const count = xdr.readUnsignedInt();
const flavors = [];
for (let i = 0; i < count; i++)
flavors.push(this.readSecInfoFlavor());
return new msg.Nfsv4SecinfoResponse(status, new msg.Nfsv4SecinfoResOk(flavors));
}
return new msg.Nfsv4SecinfoResponse(status);
}
decodeSetattrRequest() {
const stateid = this.readStateid();
const objAttributes = this.readFattr();
return new msg.Nfsv4SetattrRequest(stateid, objAttributes);
}
decodeSetattrResponse() {
const status = this.xdr.readUnsignedInt();
const attrset = this.readBitmap();
return new msg.Nfsv4SetattrResponse(status, new msg.Nfsv4SetattrResOk(attrset));
}
decodeSetclientidRequest() {
const client = this.readClientId();
const callback = this.readCbClient();
const callbackIdent = this.xdr.readUnsignedInt();
return new msg.Nfsv4SetclientidRequest(client, callback, callbackIdent);
}
decodeSetclientidResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const clientid = xdr.readUnsignedHyper();
const setclientidConfirm = this.readVerifier();
return new msg.Nfsv4SetclientidResponse(status, new msg.Nfsv4SetclientidResOk(clientid, setclientidConfirm));
}
return new msg.Nfsv4SetclientidResponse(status);
}
decodeSetclientidConfirmRequest() {
const clientid = this.xdr.readUnsignedHyper();
const setclientidConfirm = this.readVerifier();
return new msg.Nfsv4SetclientidConfirmRequest(clientid, setclientidConfirm);
}
decodeSetclientidConfirmResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4SetclientidConfirmResponse(status);
}
decodeVerifyRequest() {
const objAttributes = this.readFattr();
return new msg.Nfsv4VerifyRequest(objAttributes);
}
decodeVerifyResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4VerifyResponse(status);
}
decodeWriteRequest() {
const xdr = this.xdr;
const stateid = this.readStateid();
const offset = xdr.readUnsignedHyper();
const stable = xdr.readUnsignedInt();
const data = xdr.readVarlenOpaque();
return new msg.Nfsv4WriteRequest(stateid, offset, stable, data);
}
decodeWriteResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
if (status === 0) {
const count = xdr.readUnsignedInt();
const committed = xdr.readUnsignedInt();
const writeverf = this.readVerifier();
return new msg.Nfsv4WriteResponse(status, new msg.Nfsv4WriteResOk(count, committed, writeverf));
}
return new msg.Nfsv4WriteResponse(status);
}
decodeReleaseLockOwnerRequest() {
const lockOwner = this.readLockOwner();
return new msg.Nfsv4ReleaseLockOwnerRequest(lockOwner);
}
decodeReleaseLockOwnerResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4ReleaseLockOwnerResponse(status);
}
decodeIllegalRequest() {
return new msg.Nfsv4IllegalRequest();
}
decodeIllegalResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4IllegalResponse(status);
}
decodeCbCompound(reader, isRequest) {
this.xdr.reader = reader;
const startPos = reader.x;
try {
if (isRequest) {
return this.decodeCbCompoundRequest();
}
else {
return this.decodeCbCompoundResponse();
}
}
catch (err) {
if (err instanceof RangeError) {
reader.x = startPos;
return undefined;
}
throw err;
}
}
decodeCbCompoundRequest() {
const xdr = this.xdr;
const tag = xdr.readString();
const minorversion = xdr.readUnsignedInt();
const callbackIdent = xdr.readUnsignedInt();
const argarray = [];
const count = xdr.readUnsignedInt();
for (let i = 0; i < count; i++) {
const op = xdr.readUnsignedInt();
const request = this.decodeCbRequest(op);
if (request)
argarray.push(request);
}
return new msg.Nfsv4CbCompoundRequest(tag, minorversion, callbackIdent, argarray);
}
decodeCbCompoundResponse() {
const xdr = this.xdr;
const status = xdr.readUnsignedInt();
const tag = xdr.readString();
const resarray = [];
const count = xdr.readUnsignedInt();
for (let i = 0; i < count; i++) {
const op = xdr.readUnsignedInt();
const response = this.decodeCbResponse(op);
if (response)
resarray.push(response);
}
return new msg.Nfsv4CbCompoundResponse(status, tag, resarray);
}
decodeCbRequest(op) {
switch (op) {
case 3:
return this.decodeCbGetattrRequest();
case 4:
return this.decodeCbRecallRequest();
case 10044:
return this.decodeCbIllegalRequest();
default:
throw new errors_1.Nfsv4DecodingError(`Unknown callback operation: ${op}`);
}
}
decodeCbResponse(op) {
switch (op) {
case 3:
return this.decodeCbGetattrResponse();
case 4:
return this.decodeCbRecallResponse();
case 10044:
return this.decodeCbIllegalResponse();
default:
throw new errors_1.Nfsv4DecodingError(`Unknown callback operation: ${op}`);
}
}
decodeCbGetattrRequest() {
const fh = this.readFh();
const attrRequest = this.readBitmap();
return new msg.Nfsv4CbGetattrRequest(fh, attrRequest);
}
decodeCbGetattrResponse() {
const status = this.xdr.readUnsignedInt();
if (status === 0) {
const objAttributes = this.readFattr();
return new msg.Nfsv4CbGetattrResponse(status, new msg.Nfsv4CbGetattrResOk(objAttributes));
}
return new msg.Nfsv4CbGetattrResponse(status);
}
decodeCbRecallRequest() {
const stateid = this.readStateid();
const truncate = this.xdr.readBoolean();
const fh = this.readFh();
return new msg.Nfsv4CbRecallRequest(stateid, truncate, fh);
}
decodeCbRecallResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4CbRecallResponse(status);
}
decodeCbIllegalRequest() {
return new msg.Nfsv4CbIllegalRequest();
}
decodeCbIllegalResponse() {
const status = this.xdr.readUnsignedInt();
return new msg.Nfsv4CbIllegalResponse(status);
}
}
exports.Nfsv4Decoder = Nfsv4Decoder;
//# sourceMappingURL=Nfsv4Decoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
import { XdrEncoder } from '../../xdr/XdrEncoder';
import * as msg from './messages';
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
export declare class Nfsv4Encoder<W extends IWriter & IWriterGrowable = IWriter & IWriterGrowable> {
readonly writer: W;
readonly xdr: XdrEncoder;
constructor(writer?: W);
encodeCompound(compound: msg.Nfsv4CompoundRequest | msg.Nfsv4CompoundResponse, isRequest?: boolean): Uint8Array;
writeCompound(compound: msg.Nfsv4CompoundRequest | msg.Nfsv4CompoundResponse, isRequest: boolean): void;
encodeCbCompound(compound: msg.Nfsv4CbCompoundRequest | msg.Nfsv4CbCompoundResponse, isRequest?: boolean): Uint8Array;
writeCbCompound(compound: msg.Nfsv4CbCompoundRequest | msg.Nfsv4CbCompoundResponse, isRequest: boolean): void;
}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv4Encoder = void 0;
const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
const XdrEncoder_1 = require("../../xdr/XdrEncoder");
class Nfsv4Encoder {
constructor(writer = new Writer_1.Writer()) {
this.writer = writer;
this.xdr = new XdrEncoder_1.XdrEncoder(writer);
}
encodeCompound(compound, isRequest) {
compound.encode(this.xdr);
return this.writer.flush();
}
writeCompound(compound, isRequest) {
compound.encode(this.xdr);
}
encodeCbCompound(compound, isRequest) {
compound.encode(this.xdr);
return this.writer.flush();
}
writeCbCompound(compound, isRequest) {
compound.encode(this.xdr);
}
}
exports.Nfsv4Encoder = Nfsv4Encoder;
//# sourceMappingURL=Nfsv4Encoder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Nfsv4Encoder.js","sourceRoot":"","sources":["../../../src/nfs/v4/Nfsv4Encoder.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,qDAAgD;AAIhD,MAAa,YAAY;IAGvB,YAA4B,SAAY,IAAI,eAAM,EAAS;QAA/B,WAAM,GAAN,MAAM,CAAyB;QACzD,IAAI,CAAC,GAAG,GAAG,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAEM,cAAc,CACnB,QAA8D,EAC9D,SAAmB;QAEnB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAEM,aAAa,CAAC,QAA8D,EAAE,SAAkB;QACrG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,gBAAgB,CACrB,QAAkE,EAClE,SAAmB;QAEnB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAEM,eAAe,CAAC,QAAkE,EAAE,SAAkB;QAC3G,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF;AA9BD,oCA8BC"}

View File

@@ -0,0 +1,32 @@
import { Nfsv4Encoder } from './Nfsv4Encoder';
import { RpcMessageEncoder } from '../../rpc/RpcMessageEncoder';
import { RmRecordEncoder } from '../../rm/RmRecordEncoder';
import { Nfsv4Proc, Nfsv4CbProc } from './constants';
import { RpcOpaqueAuth } from '../../rpc/messages';
import { XdrEncoder } from '../../xdr';
import type * as msg from './messages';
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
export declare class Nfsv4FullEncoder<W extends IWriter & IWriterGrowable = IWriter & IWriterGrowable> {
readonly writer: W;
readonly nfsEncoder: Nfsv4Encoder<W>;
readonly rpcEncoder: RpcMessageEncoder<W>;
readonly rmEncoder: RmRecordEncoder<W>;
readonly xdr: XdrEncoder;
constructor(writer?: W);
encodeCall(xid: number, proc: Nfsv4Proc, cred: RpcOpaqueAuth, verf: RpcOpaqueAuth, request: msg.Nfsv4CompoundRequest): Uint8Array;
writeCall(xid: number, proc: Nfsv4Proc, cred: RpcOpaqueAuth, verf: RpcOpaqueAuth, request: msg.Nfsv4CompoundRequest): void;
encodeAcceptedCompoundReply(xid: number, proc: Nfsv4Proc, verf: RpcOpaqueAuth, response: msg.Nfsv4CompoundResponse): Uint8Array;
writeAcceptedCompoundReply(xid: number, verf: RpcOpaqueAuth, compound: msg.Nfsv4CompoundResponse): void;
encodeRejectedReply(xid: number, rejectStat: number, mismatchInfo?: {
low: number;
high: number;
}, authStat?: number): Uint8Array;
writeRejectedReply(xid: number, rejectStat: number, mismatchInfo?: {
low: number;
high: number;
}, authStat?: number): void;
encodeCbCall(xid: number, cbProgram: number, proc: Nfsv4CbProc, cred: RpcOpaqueAuth, verf: RpcOpaqueAuth, request: msg.Nfsv4CbCompoundRequest): Uint8Array;
writeCbCall(xid: number, cbProgram: number, proc: Nfsv4CbProc, cred: RpcOpaqueAuth, verf: RpcOpaqueAuth, request: msg.Nfsv4CbCompoundRequest): void;
encodeCbAcceptedReply(xid: number, proc: Nfsv4CbProc, verf: RpcOpaqueAuth, response: msg.Nfsv4CbCompoundResponse): Uint8Array;
writeCbAcceptedReply(xid: number, proc: Nfsv4CbProc, verf: RpcOpaqueAuth, response: msg.Nfsv4CbCompoundResponse): void;
}

View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv4FullEncoder = void 0;
const Writer_1 = require("@jsonjoy.com/buffers/lib/Writer");
const Nfsv4Encoder_1 = require("./Nfsv4Encoder");
const RpcMessageEncoder_1 = require("../../rpc/RpcMessageEncoder");
const RmRecordEncoder_1 = require("../../rm/RmRecordEncoder");
class Nfsv4FullEncoder {
constructor(writer = new Writer_1.Writer()) {
this.writer = writer;
this.nfsEncoder = new Nfsv4Encoder_1.Nfsv4Encoder(writer);
this.rpcEncoder = new RpcMessageEncoder_1.RpcMessageEncoder(writer);
this.rmEncoder = new RmRecordEncoder_1.RmRecordEncoder(writer);
this.xdr = this.nfsEncoder.xdr;
}
encodeCall(xid, proc, cred, verf, request) {
this.writeCall(xid, proc, cred, verf, request);
return this.writer.flush();
}
writeCall(xid, proc, cred, verf, request) {
const rm = this.rmEncoder;
const state = rm.startRecord();
this.rpcEncoder.writeCall(xid, 100003, 4, proc, cred, verf);
this.nfsEncoder.writeCompound(request, true);
rm.endRecord(state);
}
encodeAcceptedCompoundReply(xid, proc, verf, response) {
this.writeAcceptedCompoundReply(xid, verf, response);
return this.writer.flush();
}
writeAcceptedCompoundReply(xid, verf, compound) {
const rm = this.rmEncoder;
const state = rm.startRecord();
this.rpcEncoder.writeAcceptedReply(xid, verf, 0);
compound.encode(this.xdr);
rm.endRecord(state);
}
encodeRejectedReply(xid, rejectStat, mismatchInfo, authStat) {
this.writeRejectedReply(xid, rejectStat, mismatchInfo, authStat);
return this.writer.flush();
}
writeRejectedReply(xid, rejectStat, mismatchInfo, authStat) {
const rm = this.rmEncoder;
const state = rm.startRecord();
this.rpcEncoder.writeRejectedReply(xid, rejectStat, mismatchInfo, authStat);
rm.endRecord(state);
}
encodeCbCall(xid, cbProgram, proc, cred, verf, request) {
this.writeCbCall(xid, cbProgram, proc, cred, verf, request);
return this.writer.flush();
}
writeCbCall(xid, cbProgram, proc, cred, verf, request) {
const rm = this.rmEncoder;
const state = rm.startRecord();
this.rpcEncoder.writeCall(xid, cbProgram, 4, proc, cred, verf);
this.nfsEncoder.writeCbCompound(request, true);
rm.endRecord(state);
}
encodeCbAcceptedReply(xid, proc, verf, response) {
this.writeCbAcceptedReply(xid, proc, verf, response);
return this.writer.flush();
}
writeCbAcceptedReply(xid, proc, verf, response) {
const rm = this.rmEncoder;
const state = rm.startRecord();
this.rpcEncoder.writeAcceptedReply(xid, verf, 0);
this.nfsEncoder.writeCbCompound(response, false);
rm.endRecord(state);
}
}
exports.Nfsv4FullEncoder = Nfsv4FullEncoder;
//# sourceMappingURL=Nfsv4FullEncoder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Nfsv4FullEncoder.js","sourceRoot":"","sources":["../../../src/nfs/v4/Nfsv4FullEncoder.ts"],"names":[],"mappings":";;;AAAA,4DAAuD;AACvD,iDAA4C;AAC5C,mEAA8D;AAC9D,8DAAyD;AAQzD,MAAa,gBAAgB;IAM3B,YAA4B,SAAY,IAAI,eAAM,EAAS;QAA/B,WAAM,GAAN,MAAM,CAAyB;QACzD,IAAI,CAAC,UAAU,GAAG,IAAI,2BAAY,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAiB,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAe,CAAC,MAAM,CAAC,CAAC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O,EAAE,IAAI,CAAC,CAAC;QAC/C,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAEM,qBAAqB,CAC1B,GAAW,EACX,IAAiB,EACjB,IAAmB,EACnB,QAAqC;QAErC,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAEM,oBAAoB,CACzB,GAAW,EACX,IAAiB,EACjB,IAAmB,EACnB,QAAqC;QAErC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAI,IAAwB,CAAC;QACrE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjD,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;CACF;AA/HD,4CA+HC"}

View File

@@ -0,0 +1,17 @@
import { Nfsv4Attr } from './constants';
export declare const PER_SERVER_ATTRS: Set<Nfsv4Attr>;
export declare const PER_FS_ATTRS: Set<Nfsv4Attr>;
export declare const HOMOGENEOUS_ATTRS: Set<Nfsv4Attr>;
export declare const GET_ONLY_ATTRS: Set<Nfsv4Attr>;
export declare const SET_ONLY_ATTRS: Set<Nfsv4Attr>;
export declare const REQUIRED_ATTRS: Set<Nfsv4Attr>;
export declare const RECOMMENDED_ATTRS: Set<Nfsv4Attr>;
export declare const STAT_ATTRS: Set<Nfsv4Attr>;
export declare const FS_ATTRS: Set<Nfsv4Attr>;
export declare const parseBitmask: (mask: number[]) => Set<number>;
export declare const overlaps: <T>(a: Set<T>, b: Set<T>) => boolean;
export declare const containsSetOnlyAttr: (requestedAttrs: Set<number>) => boolean;
export declare const requiresLstat: (requestedAttrs: Set<number>) => boolean;
export declare const requiresFsStats: (requestedAttrs: Set<number>) => boolean;
export declare const setBit: (mask: number[], attrNum: Nfsv4Attr) => void;
export declare const attrNumsToBitmap: (attrNums: Nfsv4Attr[]) => number[];

View File

@@ -0,0 +1,203 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.attrNumsToBitmap = exports.setBit = exports.requiresFsStats = exports.requiresLstat = exports.containsSetOnlyAttr = exports.overlaps = exports.parseBitmask = exports.FS_ATTRS = exports.STAT_ATTRS = exports.RECOMMENDED_ATTRS = exports.REQUIRED_ATTRS = exports.SET_ONLY_ATTRS = exports.GET_ONLY_ATTRS = exports.HOMOGENEOUS_ATTRS = exports.PER_FS_ATTRS = exports.PER_SERVER_ATTRS = void 0;
exports.PER_SERVER_ATTRS = new Set([10]);
exports.PER_FS_ATTRS = new Set([
0,
2,
5,
6,
9,
13,
15,
16,
17,
18,
21,
22,
23,
24,
26,
27,
29,
30,
31,
34,
42,
43,
44,
51,
]);
exports.HOMOGENEOUS_ATTRS = new Set([
0,
8,
26,
5,
6,
]);
exports.GET_ONLY_ATTRS = new Set([
0,
1,
2,
3,
5,
6,
7,
8,
9,
10,
11,
19,
13,
15,
16,
17,
18,
20,
21,
22,
23,
24,
26,
27,
28,
29,
30,
31,
55,
34,
35,
38,
39,
40,
41,
42,
43,
44,
45,
47,
51,
52,
53,
]);
exports.SET_ONLY_ATTRS = new Set([48, 54]);
exports.REQUIRED_ATTRS = new Set([
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
19,
]);
exports.RECOMMENDED_ATTRS = new Set([
12,
13,
14,
15,
16,
17,
18,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
55,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
]);
exports.STAT_ATTRS = new Set([
1,
3,
4,
20,
33,
35,
41,
45,
47,
52,
53,
]);
exports.FS_ATTRS = new Set([
21,
22,
23,
42,
43,
44,
]);
const parseBitmask = (mask) => {
const attrs = new Set();
const length = mask.length;
for (let i = 0, word = mask[0], base = 0; i < length; i++, word = mask[i], base = i * 32)
for (let bit = 0; word; bit++, word >>>= 1)
if (word & 1)
attrs.add(base + bit);
return attrs;
};
exports.parseBitmask = parseBitmask;
const overlaps = (a, b) => {
for (const element of b)
if (a.has(element))
return true;
return false;
};
exports.overlaps = overlaps;
const containsSetOnlyAttr = (requestedAttrs) => (0, exports.overlaps)(requestedAttrs, exports.SET_ONLY_ATTRS);
exports.containsSetOnlyAttr = containsSetOnlyAttr;
const requiresLstat = (requestedAttrs) => (0, exports.overlaps)(requestedAttrs, exports.STAT_ATTRS);
exports.requiresLstat = requiresLstat;
const requiresFsStats = (requestedAttrs) => (0, exports.overlaps)(requestedAttrs, exports.FS_ATTRS);
exports.requiresFsStats = requiresFsStats;
const setBit = (mask, attrNum) => {
const wordIndex = Math.floor(attrNum / 32);
const bitIndex = attrNum % 32;
while (mask.length <= wordIndex)
mask.push(0);
mask[wordIndex] |= 1 << bitIndex;
};
exports.setBit = setBit;
const attrNumsToBitmap = (attrNums) => {
const mask = [];
for (const attrNum of attrNums)
(0, exports.setBit)(mask, attrNum);
return mask;
};
exports.attrNumsToBitmap = attrNumsToBitmap;
//# sourceMappingURL=attributes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../src/nfs/v4/attributes.ts"],"names":[],"mappings":";;;AAWa,QAAA,gBAAgB,GAAG,IAAI,GAAG,CAAY,IAA6B,CAAC,CAAC;AAMrE,QAAA,YAAY,GAAG,IAAI,GAAG,CAAY;;;;;;;;;;;;;;;;;;;;;;;;;CAyB9C,CAAC,CAAC;AAMU,QAAA,iBAAiB,GAAG,IAAI,GAAG,CAAY;;;;;;CAMnD,CAAC,CAAC;AAOU,QAAA,cAAc,GAAG,IAAI,GAAG,CAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAHW,QAAA,QAAQ,YAGnB;AAKK,MAAM,mBAAmB,GAAG,CAAC,cAA2B,EAAW,EAAE,CAAC,IAAA,gBAAQ,EAAC,cAAc,EAAE,sBAAc,CAAC,CAAC;AAAzG,QAAA,mBAAmB,uBAAsF;AAK/G,MAAM,aAAa,GAAG,CAAC,cAA2B,EAAW,EAAE,CAAC,IAAA,gBAAQ,EAAC,cAAc,EAAE,kBAAU,CAAC,CAAC;AAA/F,QAAA,aAAa,iBAAkF;AAErG,MAAM,eAAe,GAAG,CAAC,cAA2B,EAAW,EAAE,CAAC,IAAA,gBAAQ,EAAC,cAAc,EAAE,gBAAQ,CAAC,CAAC;AAA/F,QAAA,eAAe,mBAAgF;AAErG,MAAM,MAAM,GAAG,CAAC,IAAc,EAAE,OAAkB,EAAQ,EAAE;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,OAAO,GAAG,EAAE,CAAC;IAC9B,OAAO,IAAI,CAAC,MAAM,IAAI,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC;AACnC,CAAC,CAAC;AALW,QAAA,MAAM,UAKjB;AAOK,MAAM,gBAAgB,GAAG,CAAC,QAAqB,EAAY,EAAE;IAClE,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,IAAA,cAAM,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B"}

View File

@@ -0,0 +1,60 @@
import * as msg from './messages';
import * as structs from './structs';
import { Nfsv4LockType } from './constants';
export declare const nfs: {
PUTROOTFH(): msg.Nfsv4PutrootfhRequest;
PUTFH(fh: structs.Nfsv4Fh): msg.Nfsv4PutfhRequest;
PUTPUBFH(): msg.Nfsv4PutpubfhRequest;
GETFH(): msg.Nfsv4GetfhRequest;
LOOKUP(name: string): msg.Nfsv4LookupRequest;
LOOKUPP(): msg.Nfsv4LookuppRequest;
GETATTR(attrBitmap: number[]): msg.Nfsv4GetattrRequest;
READDIR(attrBitmap: number | number[], cookieverf?: Uint8Array, cookie?: bigint, dircount?: number, maxcount?: number): msg.Nfsv4ReaddirRequest;
ACCESS(accessMask?: number): msg.Nfsv4AccessRequest;
READ(offset: bigint, count: number, stateid?: structs.Nfsv4Stateid): msg.Nfsv4ReadRequest;
WRITE(stateid: structs.Nfsv4Stateid, offset: bigint, stable: number, data: Uint8Array): msg.Nfsv4WriteRequest;
COMMIT(offset: bigint, count: number): msg.Nfsv4CommitRequest;
CREATE(objtype: structs.Nfsv4CreateType, objname: string, createattrs: structs.Nfsv4Fattr): msg.Nfsv4CreateRequest;
LINK(newname: string): msg.Nfsv4LinkRequest;
READLINK(): msg.Nfsv4ReadlinkRequest;
SAVEFH(): msg.Nfsv4SavefhRequest;
RESTOREFH(): msg.Nfsv4RestorefhRequest;
SETATTR(stateid: structs.Nfsv4Stateid, attrs: structs.Nfsv4Fattr): msg.Nfsv4SetattrRequest;
VERIFY(attrs: structs.Nfsv4Fattr): msg.Nfsv4VerifyRequest;
NVERIFY(attrs: structs.Nfsv4Fattr): msg.Nfsv4NverifyRequest;
REMOVE(name: string): msg.Nfsv4RemoveRequest;
RENAME(oldname: string, newname: string): msg.Nfsv4RenameRequest;
RENEW(clientid: bigint): msg.Nfsv4RenewRequest;
SETCLIENTID(client: structs.Nfsv4ClientId, callback: structs.Nfsv4CbClient, callbackIdent: number): msg.Nfsv4SetclientidRequest;
SETCLIENTID_CONFIRM(clientid: bigint, verifier: structs.Nfsv4Verifier): msg.Nfsv4SetclientidConfirmRequest;
OPEN(seqid: number, shareAccess: number, shareDeny: number, owner: structs.Nfsv4OpenOwner, openhow: structs.Nfsv4OpenHow, claim: structs.Nfsv4OpenClaim): msg.Nfsv4OpenRequest;
CLOSE(seqid: number, openStateid: structs.Nfsv4Stateid): msg.Nfsv4CloseRequest;
OPEN_CONFIRM(openStateid: structs.Nfsv4Stateid, seqid: number): msg.Nfsv4OpenConfirmRequest;
OPEN_DOWNGRADE(openStateid: structs.Nfsv4Stateid, seqid: number, shareAccess: number, shareDeny: number): msg.Nfsv4OpenDowngradeRequest;
OPENATTR(createdir?: boolean): msg.Nfsv4OpenattrRequest;
SECINFO(name: string): msg.Nfsv4SecinfoRequest;
DELEGPURGE(clientid: bigint): msg.Nfsv4DelegpurgeRequest;
DELEGRETURN(stateid: structs.Nfsv4Stateid): msg.Nfsv4DelegreturnRequest;
LOCK(locktype: Nfsv4LockType, reclaim: boolean, offset: bigint, length: bigint, locker: structs.Nfsv4LockOwnerInfo): msg.Nfsv4LockRequest;
LOCKT(locktype: number, offset: bigint, length: bigint, owner: structs.Nfsv4LockOwner): msg.Nfsv4LocktRequest;
LOCKU(locktype: number, seqid: number, lockStateid: structs.Nfsv4Stateid, offset: bigint, length: bigint): msg.Nfsv4LockuRequest;
RELEASE_LOCKOWNER(lockOwner: structs.Nfsv4LockOwner): msg.Nfsv4ReleaseLockOwnerRequest;
Verifier(data?: Uint8Array): structs.Nfsv4Verifier;
Stateid(seqid?: number, other?: Uint8Array): structs.Nfsv4Stateid;
Fattr(attrNums: number[], attrVals: Uint8Array): structs.Nfsv4Fattr;
ClientId(verifier: structs.Nfsv4Verifier, id: Uint8Array): structs.Nfsv4ClientId;
CbClient(cbProgram: number, rNetid: string, rAddr: string): structs.Nfsv4CbClient;
Bitmap(attrNums: number[]): structs.Nfsv4Bitmap;
CreateTypeFile(): structs.Nfsv4CreateType;
CreateTypeDir(): structs.Nfsv4CreateType;
OpenOwner(clientid: bigint, owner: Uint8Array): structs.Nfsv4OpenOwner;
OpenClaimNull(filename: string): structs.Nfsv4OpenClaim;
OpenHowNoCreate(): structs.Nfsv4OpenHow;
OpenHowCreateUnchecked(createattrs?: structs.Nfsv4Fattr): structs.Nfsv4OpenHow;
OpenHowCreateGuarded(createattrs?: structs.Nfsv4Fattr): structs.Nfsv4OpenHow;
OpenHowCreateExclusive(verifier: structs.Nfsv4Verifier): structs.Nfsv4OpenHow;
LockOwner(clientid: bigint, owner: Uint8Array): structs.Nfsv4LockOwner;
NewLockOwner(openSeqid: number, openStateid: structs.Nfsv4Stateid, lockSeqid: number, lockOwner: structs.Nfsv4LockOwner): structs.Nfsv4LockOwnerInfo;
ExistingLockOwner(lockStateid: structs.Nfsv4Stateid, lockSeqid: number): structs.Nfsv4LockOwnerInfo;
ILLEGAL(): msg.Nfsv4IllegalRequest;
};

View File

@@ -0,0 +1,187 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nfs = void 0;
const tslib_1 = require("tslib");
const attributes_1 = require("./attributes");
const msg = tslib_1.__importStar(require("./messages"));
const structs = tslib_1.__importStar(require("./structs"));
exports.nfs = {
PUTROOTFH() {
return new msg.Nfsv4PutrootfhRequest();
},
PUTFH(fh) {
return new msg.Nfsv4PutfhRequest(fh);
},
PUTPUBFH() {
return new msg.Nfsv4PutpubfhRequest();
},
GETFH() {
return new msg.Nfsv4GetfhRequest();
},
LOOKUP(name) {
return new msg.Nfsv4LookupRequest(name);
},
LOOKUPP() {
return new msg.Nfsv4LookuppRequest();
},
GETATTR(attrBitmap) {
return new msg.Nfsv4GetattrRequest(new structs.Nfsv4Bitmap(attrBitmap));
},
READDIR(attrBitmap, cookieverf, cookie, dircount, maxcount) {
const bitmap = Array.isArray(attrBitmap) ? attrBitmap : [attrBitmap];
const verifier = cookieverf || new Uint8Array(8);
return new msg.Nfsv4ReaddirRequest(cookie ?? BigInt(0), new structs.Nfsv4Verifier(verifier), dircount ?? 1000, maxcount ?? 8192, new structs.Nfsv4Bitmap(bitmap));
},
ACCESS(accessMask = 0x0000003f) {
return new msg.Nfsv4AccessRequest(accessMask);
},
READ(offset, count, stateid) {
const sid = stateid || new structs.Nfsv4Stateid(0, new Uint8Array(12));
return new msg.Nfsv4ReadRequest(sid, offset, count);
},
WRITE(stateid, offset, stable, data) {
return new msg.Nfsv4WriteRequest(stateid, offset, stable, data);
},
COMMIT(offset, count) {
return new msg.Nfsv4CommitRequest(offset, count);
},
CREATE(objtype, objname, createattrs) {
return new msg.Nfsv4CreateRequest(objtype, objname, createattrs);
},
LINK(newname) {
return new msg.Nfsv4LinkRequest(newname);
},
READLINK() {
return new msg.Nfsv4ReadlinkRequest();
},
SAVEFH() {
return new msg.Nfsv4SavefhRequest();
},
RESTOREFH() {
return new msg.Nfsv4RestorefhRequest();
},
SETATTR(stateid, attrs) {
return new msg.Nfsv4SetattrRequest(stateid, attrs);
},
VERIFY(attrs) {
return new msg.Nfsv4VerifyRequest(attrs);
},
NVERIFY(attrs) {
return new msg.Nfsv4NverifyRequest(attrs);
},
REMOVE(name) {
return new msg.Nfsv4RemoveRequest(name);
},
RENAME(oldname, newname) {
return new msg.Nfsv4RenameRequest(oldname, newname);
},
RENEW(clientid) {
return new msg.Nfsv4RenewRequest(clientid);
},
SETCLIENTID(client, callback, callbackIdent) {
return new msg.Nfsv4SetclientidRequest(client, callback, callbackIdent);
},
SETCLIENTID_CONFIRM(clientid, verifier) {
return new msg.Nfsv4SetclientidConfirmRequest(clientid, verifier);
},
OPEN(seqid, shareAccess, shareDeny, owner, openhow, claim) {
return new msg.Nfsv4OpenRequest(seqid, shareAccess, shareDeny, owner, openhow, claim);
},
CLOSE(seqid, openStateid) {
return new msg.Nfsv4CloseRequest(seqid, openStateid);
},
OPEN_CONFIRM(openStateid, seqid) {
return new msg.Nfsv4OpenConfirmRequest(openStateid, seqid);
},
OPEN_DOWNGRADE(openStateid, seqid, shareAccess, shareDeny) {
return new msg.Nfsv4OpenDowngradeRequest(openStateid, seqid, shareAccess, shareDeny);
},
OPENATTR(createdir = false) {
return new msg.Nfsv4OpenattrRequest(createdir);
},
SECINFO(name) {
return new msg.Nfsv4SecinfoRequest(name);
},
DELEGPURGE(clientid) {
return new msg.Nfsv4DelegpurgeRequest(clientid);
},
DELEGRETURN(stateid) {
return new msg.Nfsv4DelegreturnRequest(stateid);
},
LOCK(locktype, reclaim, offset, length, locker) {
return new msg.Nfsv4LockRequest(locktype, reclaim, offset, length, locker);
},
LOCKT(locktype, offset, length, owner) {
return new msg.Nfsv4LocktRequest(locktype, offset, length, owner);
},
LOCKU(locktype, seqid, lockStateid, offset, length) {
return new msg.Nfsv4LockuRequest(locktype, seqid, lockStateid, offset, length);
},
RELEASE_LOCKOWNER(lockOwner) {
return new msg.Nfsv4ReleaseLockOwnerRequest(lockOwner);
},
Verifier(data) {
return new structs.Nfsv4Verifier(data || new Uint8Array(8));
},
Stateid(seqid = 0, other) {
return new structs.Nfsv4Stateid(seqid, other || new Uint8Array(12));
},
Fattr(attrNums, attrVals) {
const bitmap = new structs.Nfsv4Bitmap((0, attributes_1.attrNumsToBitmap)(attrNums));
return new structs.Nfsv4Fattr(bitmap, attrVals);
},
ClientId(verifier, id) {
return new structs.Nfsv4ClientId(verifier, id);
},
CbClient(cbProgram, rNetid, rAddr) {
const cbLocation = new structs.Nfsv4ClientAddr(rNetid, rAddr);
return new structs.Nfsv4CbClient(cbProgram, cbLocation);
},
Bitmap(attrNums) {
return new structs.Nfsv4Bitmap((0, attributes_1.attrNumsToBitmap)(attrNums));
},
CreateTypeFile() {
return new structs.Nfsv4CreateType(1, new structs.Nfsv4CreateTypeVoid());
},
CreateTypeDir() {
return new structs.Nfsv4CreateType(2, new structs.Nfsv4CreateTypeVoid());
},
OpenOwner(clientid, owner) {
return new structs.Nfsv4OpenOwner(clientid, owner);
},
OpenClaimNull(filename) {
return new structs.Nfsv4OpenClaim(0, new structs.Nfsv4OpenClaimNull(filename));
},
OpenHowNoCreate() {
return new structs.Nfsv4OpenHow(0);
},
OpenHowCreateUnchecked(createattrs) {
const attrs = createattrs || new structs.Nfsv4Fattr(new structs.Nfsv4Bitmap([]), new Uint8Array(0));
const how = new structs.Nfsv4CreateHow(0, new structs.Nfsv4CreateAttrs(attrs));
return new structs.Nfsv4OpenHow(1, how);
},
OpenHowCreateGuarded(createattrs) {
const attrs = createattrs || new structs.Nfsv4Fattr(new structs.Nfsv4Bitmap([]), new Uint8Array(0));
const how = new structs.Nfsv4CreateHow(1, new structs.Nfsv4CreateAttrs(attrs));
return new structs.Nfsv4OpenHow(1, how);
},
OpenHowCreateExclusive(verifier) {
const how = new structs.Nfsv4CreateHow(2, new structs.Nfsv4CreateVerf(verifier));
return new structs.Nfsv4OpenHow(1, how);
},
LockOwner(clientid, owner) {
return new structs.Nfsv4LockOwner(clientid, owner);
},
NewLockOwner(openSeqid, openStateid, lockSeqid, lockOwner) {
const openToLockOwner = new structs.Nfsv4OpenToLockOwner(openSeqid, openStateid, lockSeqid, lockOwner);
return new structs.Nfsv4LockOwnerInfo(true, new structs.Nfsv4LockNewOwner(openToLockOwner));
},
ExistingLockOwner(lockStateid, lockSeqid) {
const owner = new structs.Nfsv4LockExistingOwner(lockStateid, lockSeqid);
return new structs.Nfsv4LockOwnerInfo(false, owner);
},
ILLEGAL() {
return new msg.Nfsv4IllegalRequest();
},
};
//# sourceMappingURL=builder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import type * as misc from 'memfs/lib/node/types/misc';
import type { Nfsv4Client } from './types';
import * as msg from '../messages';
export declare class NfsFsDir implements misc.IDir {
readonly path: string;
private readonly nfs;
private readonly operations;
private entries;
private position;
private closed;
constructor(path: string, nfs: Nfsv4Client, operations: msg.Nfsv4Request[]);
private ensureLoaded;
close(): Promise<void>;
close(callback?: (err?: Error) => void): Promise<void>;
closeSync(): void;
read(): Promise<misc.IDirent | null>;
read(callback?: (err: Error | null, dir?: misc.IDirent | null) => void): Promise<misc.IDirent | null>;
readSync(): misc.IDirent | null;
[Symbol.asyncIterator](): AsyncIterableIterator<misc.IDirent>;
}

View File

@@ -0,0 +1,129 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NfsFsDir = void 0;
const NfsFsDirent_1 = require("./NfsFsDirent");
const builder_1 = require("../builder");
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
const XdrDecoder_1 = require("../../../xdr/XdrDecoder");
class NfsFsDir {
constructor(path, nfs, operations) {
this.path = path;
this.nfs = nfs;
this.operations = operations;
this.entries = [];
this.position = 0;
this.closed = false;
}
async ensureLoaded() {
if (this.entries.length > 0 || this.closed)
return;
const attrNums = [1];
const attrMask = [];
for (const attrNum of attrNums) {
const wordIndex = Math.floor(attrNum / 32);
const bitIndex = attrNum % 32;
while (attrMask.length <= wordIndex)
attrMask.push(0);
attrMask[wordIndex] |= 1 << bitIndex;
}
const operations = [...this.operations];
operations.push(builder_1.nfs.READDIR(attrMask));
const response = await this.nfs.compound(operations);
if (response.status !== 0)
throw new Error(`Failed to read directory: ${response.status}`);
const readdirRes = response.resarray[response.resarray.length - 1];
if (readdirRes.status !== 0 || !readdirRes.resok)
throw new Error(`Failed to read directory: ${readdirRes.status}`);
const entryList = readdirRes.resok.entries;
for (let i = 0; i < entryList.length; i++) {
const entry = entryList[i];
const name = entry.name;
const fattr = entry.attrs;
const reader = new Reader_1.Reader();
reader.reset(fattr.attrVals);
const xdr = new XdrDecoder_1.XdrDecoder(reader);
let fileType = 1;
const returnedMask = fattr.attrmask.mask;
for (let i = 0; i < returnedMask.length; i++) {
const word = returnedMask[i];
if (!word)
continue;
for (let bit = 0; bit < 32; bit++) {
if (!(word & (1 << bit)))
continue;
const attrNum = i * 32 + bit;
if (attrNum === 1) {
fileType = xdr.readUnsignedInt();
}
}
}
this.entries.push(new NfsFsDirent_1.NfsFsDirent(name, fileType));
}
}
async close(callback) {
this.closed = true;
this.entries = [];
this.position = 0;
if (callback) {
try {
callback();
}
catch (err) {
callback(err);
}
}
}
closeSync() {
this.closed = true;
this.entries = [];
this.position = 0;
}
async read(callback) {
try {
if (this.closed) {
const err = new Error('Directory is closed');
if (callback) {
callback(err, null);
return null;
}
throw err;
}
await this.ensureLoaded();
if (this.position >= this.entries.length) {
if (callback) {
callback(null, null);
}
return null;
}
const entry = this.entries[this.position++];
if (callback) {
callback(null, entry);
}
return entry;
}
catch (err) {
if (callback) {
callback(err, null);
return null;
}
throw err;
}
}
readSync() {
if (this.closed) {
throw new Error('Directory is closed');
}
if (this.position >= this.entries.length) {
return null;
}
return this.entries[this.position++];
}
async *[Symbol.asyncIterator]() {
await this.ensureLoaded();
for (const entry of this.entries) {
yield entry;
}
}
}
exports.NfsFsDir = NfsFsDir;
//# sourceMappingURL=NfsFsDir.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NfsFsDir.js","sourceRoot":"","sources":["../../../../src/nfs/v4/client/NfsFsDir.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAC1C,wCAA+B;AAG/B,4DAAuD;AACvD,wDAAmD;AAKnD,MAAa,QAAQ;IAKnB,YACkB,IAAY,EACX,GAAgB,EAChB,UAA8B;QAF/B,SAAI,GAAJ,IAAI,CAAQ;QACX,QAAG,GAAH,GAAG,CAAa;QAChB,eAAU,GAAV,UAAU,CAAoB;QAPzC,YAAO,GAAkB,EAAE,CAAC;QAC5B,aAAQ,GAAW,CAAC,CAAC;QACrB,WAAM,GAAY,KAAK,CAAC;IAM7B,CAAC;IAEI,KAAK,CAAC,YAAY;QACxB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACnD,MAAM,QAAQ,GAAG,GAAuB,CAAC;QACzC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;YAC3C,MAAM,QAAQ,GAAG,OAAO,GAAG,EAAE,CAAC;YAC9B,OAAO,QAAQ,CAAC,MAAM,IAAI,SAAS;gBAAE,QAAQ,CAAC,IA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OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAClC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA3HD,4BA2HC"}

View File

@@ -0,0 +1,14 @@
import type * as misc from 'memfs/lib/node/types/misc';
import { Nfsv4FType } from '../constants';
export declare class NfsFsDirent implements misc.IDirent {
name: string;
private type;
constructor(name: string, type: Nfsv4FType);
isDirectory(): boolean;
isFile(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
}

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NfsFsDirent = void 0;
class NfsFsDirent {
constructor(name, type) {
this.name = name;
this.type = type;
}
isDirectory() {
return this.type === 2;
}
isFile() {
return this.type === 1;
}
isBlockDevice() {
return this.type === 3;
}
isCharacterDevice() {
return this.type === 4;
}
isSymbolicLink() {
return this.type === 5;
}
isFIFO() {
return this.type === 7;
}
isSocket() {
return this.type === 6;
}
}
exports.NfsFsDirent = NfsFsDirent;
//# sourceMappingURL=NfsFsDirent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NfsFsDirent.js","sourceRoot":"","sources":["../../../../src/nfs/v4/client/NfsFsDirent.ts"],"names":[],"mappings":";;;AAMA,MAAa,WAAW;IACtB,YACS,IAAY,EACX,IAAgB;QADjB,SAAI,GAAJ,IAAI,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAY;IACvB,CAAC;IAEJ,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,MAAuB,CAAC;IAC1C,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,MAAuB,CAAC;IAC1C,CAAC;CACF;AAjCD,kCAiCC"}

View File

@@ -0,0 +1,34 @@
/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from 'events';
import * as structs from '../structs';
import type * as misc from 'memfs/lib/node/types/misc';
import type * as opts from 'memfs/lib/node/types/options';
import type { Nfsv4FsClient } from './Nfsv4FsClient';
export declare class NfsFsFileHandle extends EventEmitter implements misc.IFileHandle {
readonly path: string;
private readonly client;
private readonly stateid;
private readonly openOwner;
readonly fd: number;
private closed;
constructor(fd: number, path: string, client: Nfsv4FsClient, stateid: structs.Nfsv4Stateid, openOwner: structs.Nfsv4OpenOwner);
getAsyncId(): number;
close(): Promise<void>;
stat(options?: opts.IStatOptions): Promise<misc.IStats>;
appendFile(data: misc.TData, options?: opts.IAppendFileOptions | string): Promise<void>;
chmod(mode: misc.TMode): Promise<void>;
chown(uid: number, gid: number): Promise<void>;
datasync(): Promise<void>;
read(buffer: Buffer | Uint8Array, offset: number, length: number, position?: number | null): Promise<misc.TFileHandleReadResult>;
readFile(options?: opts.IReadFileOptions | string): Promise<misc.TDataOut>;
truncate(len?: number): Promise<void>;
utimes(atime: misc.TTime, mtime: misc.TTime): Promise<void>;
write(buffer: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number | null): Promise<misc.TFileHandleWriteResult>;
writeFile(data: misc.TData, options?: opts.IWriteFileOptions): Promise<void>;
readv(buffers: ArrayBufferView[], position?: number | null): Promise<misc.TFileHandleReadvResult>;
writev(buffers: ArrayBufferView[], position?: number | null): Promise<misc.TFileHandleWritevResult>;
readableWebStream(options?: opts.IReadableWebStreamOptions): ReadableStream;
createReadStream(options?: opts.IFileHandleReadStreamOptions): misc.IReadStream;
createWriteStream(options?: opts.IFileHandleWriteStreamOptions): misc.IWriteStream;
}

View File

@@ -0,0 +1,268 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NfsFsFileHandle = void 0;
const events_1 = require("events");
const stream_1 = require("stream");
const builder_1 = require("../builder");
class NfsFsFileHandle extends events_1.EventEmitter {
constructor(fd, path, client, stateid, openOwner) {
super();
this.path = path;
this.client = client;
this.stateid = stateid;
this.openOwner = openOwner;
this.closed = false;
this.fd = fd;
}
getAsyncId() {
return this.fd;
}
async close() {
if (this.closed)
return;
this.closed = true;
await this.client.closeStateid(this.openOwner, this.stateid);
this.emit('close');
}
async stat(options) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.stat(this.path, options);
}
async appendFile(data, options) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.appendFile(this.path, data, options);
}
async chmod(mode) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.chmod(this.path, mode);
}
async chown(uid, gid) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.chown(this.path, uid, gid);
}
async datasync() {
if (this.closed)
throw new Error('File handle is closed');
}
async read(buffer, offset, length, position) {
if (this.closed)
throw new Error('File handle is closed');
const readPos = position !== null && position !== undefined ? BigInt(position) : BigInt(0);
const readOps = [builder_1.nfs.READ(readPos, length, this.stateid)];
const response = await this.client.fs.compound(readOps);
if (response.status !== 0) {
throw new Error(`Failed to read file: ${response.status}`);
}
const readRes = response.resarray[0];
if (readRes.status !== 0 || !readRes.resok) {
throw new Error(`Failed to read file: ${readRes.status}`);
}
const data = readRes.resok.data;
const bytesToCopy = Math.min(data.length, length);
for (let i = 0; i < bytesToCopy; i++) {
buffer[offset + i] = data[i];
}
return { bytesRead: bytesToCopy, buffer };
}
async readFile(options) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.readFile(this.path, options);
}
async truncate(len) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.truncate(this.path, len);
}
async utimes(atime, mtime) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.utimes(this.path, atime, mtime);
}
async write(buffer, offset, length, position) {
if (this.closed)
throw new Error('File handle is closed');
const actualOffset = offset ?? 0;
const actualLength = length ?? buffer.byteLength - actualOffset;
const writePos = position !== null && position !== undefined ? BigInt(position) : BigInt(0);
let data;
if (buffer instanceof Uint8Array) {
data = Uint8Array.prototype.slice.call(buffer, actualOffset, actualOffset + actualLength);
}
else if (Buffer.isBuffer(buffer)) {
data = new Uint8Array(buffer.buffer, buffer.byteOffset + actualOffset, actualLength);
}
else if (buffer instanceof DataView) {
data = new Uint8Array(buffer.buffer, buffer.byteOffset + actualOffset, actualLength);
}
else {
data = new Uint8Array(buffer.buffer, buffer.byteOffset + actualOffset, actualLength);
}
const writeOps = [builder_1.nfs.WRITE(this.stateid, writePos, 2, data)];
const response = await this.client.fs.compound(writeOps);
if (response.status !== 0) {
throw new Error(`Failed to write file: ${response.status}`);
}
const writeRes = response.resarray[0];
if (writeRes.status !== 0 || !writeRes.resok) {
throw new Error(`Failed to write file: ${writeRes.status}`);
}
const resultBuffer = buffer instanceof Uint8Array || Buffer.isBuffer(buffer) ? buffer : new Uint8Array(buffer.buffer);
return { bytesWritten: writeRes.resok.count, buffer: resultBuffer };
}
async writeFile(data, options) {
if (this.closed)
throw new Error('File handle is closed');
return this.client.writeFile(this.path, data, options);
}
async readv(buffers, position) {
if (this.closed)
throw new Error('File handle is closed');
let currentPosition = position !== null && position !== undefined ? BigInt(position) : BigInt(0);
let totalBytesRead = 0;
for (const buffer of buffers) {
const readOps = [builder_1.nfs.READ(currentPosition, buffer.byteLength, this.stateid)];
const response = await this.client.fs.compound(readOps);
if (response.status !== 0) {
throw new Error(`Failed to read file: ${response.status}`);
}
const readRes = response.resarray[0];
if (readRes.status !== 0 || !readRes.resok) {
throw new Error(`Failed to read file: ${readRes.status}`);
}
const data = readRes.resok.data;
const bytesToCopy = Math.min(data.length, buffer.byteLength);
const uint8View = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
for (let i = 0; i < bytesToCopy; i++) {
uint8View[i] = data[i];
}
totalBytesRead += bytesToCopy;
currentPosition += BigInt(bytesToCopy);
if (readRes.resok.eof || bytesToCopy < buffer.byteLength)
break;
}
return { bytesRead: totalBytesRead, buffers };
}
async writev(buffers, position) {
if (this.closed)
throw new Error('File handle is closed');
let currentPosition = position !== null && position !== undefined ? BigInt(position) : BigInt(0);
let totalBytesWritten = 0;
for (const buffer of buffers) {
const data = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
const writeOps = [builder_1.nfs.WRITE(this.stateid, currentPosition, 2, data)];
const response = await this.client.fs.compound(writeOps);
if (response.status !== 0) {
throw new Error(`Failed to write file: ${response.status}`);
}
const writeRes = response.resarray[0];
if (writeRes.status !== 0 || !writeRes.resok) {
throw new Error(`Failed to write file: ${writeRes.status}`);
}
totalBytesWritten += writeRes.resok.count;
currentPosition += BigInt(writeRes.resok.count);
}
return { bytesWritten: totalBytesWritten, buffers };
}
readableWebStream(options) {
if (this.closed)
throw new Error('File handle is closed');
const stream = this.createReadStream(options);
return stream_1.Readable.toWeb(stream);
}
createReadStream(options) {
if (this.closed)
throw new Error('File handle is closed');
const start = options?.start ?? 0;
const end = options?.end;
const highWaterMark = options?.highWaterMark ?? 64 * 1024;
let position = typeof start === 'number' ? start : 0;
const endPosition = typeof end === 'number' ? end : Infinity;
let reading = false;
const self = this;
const stream = new stream_1.Readable({
highWaterMark,
async read(size) {
if (reading)
return;
reading = true;
try {
while (true) {
if (position >= endPosition) {
this.push(null);
break;
}
const bytesToRead = Math.min(size, endPosition - position);
if (bytesToRead <= 0) {
this.push(null);
break;
}
const buffer = Buffer.alloc(bytesToRead);
const result = await self.read(buffer, 0, bytesToRead, position);
if (result.bytesRead === 0) {
this.push(null);
break;
}
position += result.bytesRead;
const chunk = buffer.slice(0, result.bytesRead);
if (!this.push(chunk))
break;
if (result.bytesRead < bytesToRead) {
this.push(null);
break;
}
}
}
catch (err) {
this.destroy(err);
}
finally {
reading = false;
}
},
});
stream.path = this.path;
return stream;
}
createWriteStream(options) {
if (this.closed)
throw new Error('File handle is closed');
const start = options?.start ?? 0;
const highWaterMark = options?.highWaterMark ?? 64 * 1024;
let position = typeof start === 'number' ? start : 0;
const self = this;
const stream = new stream_1.Writable({
highWaterMark,
async write(chunk, encoding, callback) {
try {
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
const result = await self.write(buffer, 0, buffer.length, position);
position += result.bytesWritten;
callback();
}
catch (err) {
callback(err);
}
},
async writev(chunks, callback) {
try {
const buffers = chunks.map(({ chunk }) => (Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
const result = await self.writev(buffers, position);
position += result.bytesWritten;
callback();
}
catch (err) {
callback(err);
}
},
});
stream.path = this.path;
return stream;
}
}
exports.NfsFsFileHandle = NfsFsFileHandle;
//# sourceMappingURL=NfsFsFileHandle.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,31 @@
import type * as misc from 'memfs/lib/node/types/misc';
import { Nfsv4FType } from '../constants';
export declare class NfsFsStats implements misc.IStats<number> {
uid: number;
gid: number;
rdev: number;
blksize: number;
ino: number;
size: number;
blocks: number;
atime: Date;
mtime: Date;
ctime: Date;
birthtime: Date;
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
birthtimeMs: number;
dev: number;
mode: number;
nlink: number;
private type;
constructor(uid: number, gid: number, rdev: number, blksize: number, ino: number, size: number, blocks: number, atime: Date, mtime: Date, ctime: Date, birthtime: Date, atimeMs: number, mtimeMs: number, ctimeMs: number, birthtimeMs: number, dev: number, mode: number, nlink: number, type: Nfsv4FType);
isDirectory(): boolean;
isFile(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
}

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NfsFsStats = void 0;
class NfsFsStats {
constructor(uid, gid, rdev, blksize, ino, size, blocks, atime, mtime, ctime, birthtime, atimeMs, mtimeMs, ctimeMs, birthtimeMs, dev, mode, nlink, type) {
this.uid = uid;
this.gid = gid;
this.rdev = rdev;
this.blksize = blksize;
this.ino = ino;
this.size = size;
this.blocks = blocks;
this.atime = atime;
this.mtime = mtime;
this.ctime = ctime;
this.birthtime = birthtime;
this.atimeMs = atimeMs;
this.mtimeMs = mtimeMs;
this.ctimeMs = ctimeMs;
this.birthtimeMs = birthtimeMs;
this.dev = dev;
this.mode = mode;
this.nlink = nlink;
this.type = type;
}
isDirectory() {
return this.type === 2;
}
isFile() {
return this.type === 1;
}
isBlockDevice() {
return this.type === 3;
}
isCharacterDevice() {
return this.type === 4;
}
isSymbolicLink() {
return this.type === 5;
}
isFIFO() {
return this.type === 7;
}
isSocket() {
return this.type === 6;
}
}
exports.NfsFsStats = NfsFsStats;
//# sourceMappingURL=NfsFsStats.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NfsFsStats.js","sourceRoot":"","sources":["../../../../src/nfs/v4/client/NfsFsStats.ts"],"names":[],"mappings":";;;AAMA,MAAa,UAAU;IACrB,YACS,GAAW,EACX,GAAW,EACX,IAAY,EACZ,OAAe,EACf,GAAW,EACX,IAAY,EACZ,MAAc,EACd,KAAW,EACX,KAAW,EACX,KAAW,EACX,SAAe,EACf,OAAe,EACf,OAAe,EACf,OAAe,EACf,WAAmB,EACnB,GAAW,EACX,IAAY,EACZ,KAAa,EACZ,IAAgB;QAlBjB,QAAG,GAAH,GAAG,CAAQ;QACX,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAM;QACX,UAAK,GAAL,KAAK,CAAM;QACX,UAAK,GAAL,KAAK,CAAM;QACX,cAAS,GAAT,SAAS,CAAM;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;QACnB,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAY;IACvB,CAAC;IAEJ,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,MAAsB,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,MAAuB,CAAC;IAC1C,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,MAAuB,CAAC;IAC1C,CAAC;CACF;AAlDD,gCAkDC"}

View File

@@ -0,0 +1,54 @@
/// <reference types="node" />
import type { NfsFsClient, Nfsv4Client } from './types';
import * as misc from 'memfs/lib/node/types/misc';
import * as opts from 'memfs/lib/node/types/options';
import * as structs from '../structs';
export declare class Nfsv4FsClient implements NfsFsClient {
readonly fs: Nfsv4Client;
constructor(fs: Nfsv4Client);
private readonly openOwnerSeqids;
private readonly defaultOpenOwnerId;
private makeOpenOwnerKey;
private nextOpenOwnerSeqid;
private createDefaultOpenOwner;
private attrNumsToBitmap;
private parsePath;
private navigateToParent;
private navigateToPath;
private encodeData;
private decodeData;
readonly closeStateid: (openOwner: structs.Nfsv4OpenOwner, stateid: structs.Nfsv4Stateid) => Promise<void>;
readonly readFile: (id: misc.TFileHandle, options?: opts.IReadFileOptions | string) => Promise<misc.TDataOut>;
readonly writeFile: (id: misc.TFileHandle, data: misc.TPromisesData, options?: opts.IWriteFileOptions) => Promise<void>;
readonly stat: (path: misc.PathLike, options?: opts.IStatOptions) => Promise<misc.IStats>;
readonly lstat: (path: misc.PathLike, options?: opts.IStatOptions) => Promise<misc.IStats>;
readonly mkdir: (path: misc.PathLike, options?: misc.TMode | opts.IMkdirOptions) => Promise<string | undefined>;
readonly readdir: (path: misc.PathLike, options?: opts.IReaddirOptions | string) => Promise<misc.TDataOut[] | misc.IDirent[]>;
readonly appendFile: (path: misc.TFileHandle, data: misc.TData, options?: opts.IAppendFileOptions | string) => Promise<void>;
readonly truncate: (path: misc.PathLike, len?: number) => Promise<void>;
readonly unlink: (path: misc.PathLike) => Promise<void>;
readonly rmdir: (path: misc.PathLike, options?: opts.IRmdirOptions) => Promise<void>;
readonly rm: (path: misc.PathLike, options?: opts.IRmOptions) => Promise<void>;
readonly access: (path: misc.PathLike, mode?: number) => Promise<void>;
readonly rename: (oldPath: misc.PathLike, newPath: misc.PathLike) => Promise<void>;
readonly copyFile: (src: misc.PathLike, dest: misc.PathLike, flags?: misc.TFlagsCopy) => Promise<void>;
readonly realpath: (path: misc.PathLike, options?: opts.IRealpathOptions | string) => Promise<misc.TDataOut>;
readonly link: (existingPath: misc.PathLike, newPath: misc.PathLike) => Promise<void>;
readonly symlink: (target: misc.PathLike, path: misc.PathLike, type?: misc.symlink.Type) => Promise<void>;
readonly utimes: (path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime) => Promise<void>;
readonly readlink: (path: misc.PathLike, options?: opts.IOptions) => Promise<misc.TDataOut>;
readonly opendir: (path: misc.PathLike, options?: opts.IOpendirOptions) => Promise<misc.IDir>;
readonly mkdtemp: (prefix: string, options?: opts.IOptions) => Promise<misc.TDataOut>;
readonly chmod: (path: misc.PathLike, mode: misc.TMode) => Promise<void>;
readonly chown: (path: misc.PathLike, uid: number, gid: number) => Promise<void>;
readonly lchmod: (path: misc.PathLike, mode: misc.TMode) => Promise<void>;
readonly lchown: (path: misc.PathLike, uid: number, gid: number) => Promise<void>;
readonly lutimes: (path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime) => Promise<void>;
readonly open: (path: misc.PathLike, flags?: misc.TFlags, mode?: misc.TMode) => Promise<misc.IFileHandle>;
readonly statfs: (path: misc.PathLike, options?: opts.IStatOptions) => Promise<misc.IStatFs>;
readonly watch: (filename: misc.PathLike, options?: opts.IWatchOptions) => AsyncIterableIterator<{
eventType: string;
filename: string | Buffer;
}>;
readonly glob: (pattern: string, options?: opts.IGlobOptions) => Promise<string[]>;
}

View File

@@ -0,0 +1,812 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv4FsClient = void 0;
const tslib_1 = require("tslib");
const builder_1 = require("../builder");
const structs = tslib_1.__importStar(require("../structs"));
const Writer_1 = require("@jsonjoy.com/buffers/lib/Writer");
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
const XdrEncoder_1 = require("../../../xdr/XdrEncoder");
const XdrDecoder_1 = require("../../../xdr/XdrDecoder");
const NfsFsStats_1 = require("./NfsFsStats");
const NfsFsDir_1 = require("./NfsFsDir");
const NfsFsDirent_1 = require("./NfsFsDirent");
const NfsFsFileHandle_1 = require("./NfsFsFileHandle");
class Nfsv4FsClient {
constructor(fs) {
this.fs = fs;
this.openOwnerSeqids = new Map();
this.defaultOpenOwnerId = new Uint8Array([1, 2, 3, 4]);
this.closeStateid = async (openOwner, stateid) => {
const key = this.makeOpenOwnerKey(openOwner);
const previousSeqid = this.openOwnerSeqids.get(key);
const seqid = this.nextOpenOwnerSeqid(openOwner);
const response = await this.fs.compound([builder_1.nfs.CLOSE(seqid, stateid)]);
if (response.status !== 0) {
if (previousSeqid !== undefined) {
this.openOwnerSeqids.set(key, previousSeqid);
}
else {
this.openOwnerSeqids.delete(key);
}
throw new Error(`Failed to close file: ${response.status}`);
}
};
this.readFile = async (id, options) => {
const encoding = typeof options === 'string' ? options : options?.encoding;
const path = typeof id === 'string' ? id : id.toString();
const parts = this.parsePath(path);
const operations = this.navigateToParent(parts);
const filename = parts[parts.length - 1];
const openOwner = this.createDefaultOpenOwner();
const claim = builder_1.nfs.OpenClaimNull(filename);
const openSeqid = this.nextOpenOwnerSeqid(openOwner);
operations.push(builder_1.nfs.OPEN(openSeqid, 1, 0, openOwner, builder_1.nfs.OpenHowNoCreate(), claim));
const openResponse = await this.fs.compound(operations);
if (openResponse.status !== 0) {
throw new Error(`Failed to open file: ${openResponse.status}`);
}
const openRes = openResponse.resarray[openResponse.resarray.length - 1];
if (openRes.status !== 0 || !openRes.resok) {
throw new Error(`Failed to open file: ${openRes.status}`);
}
const stateid = openRes.resok.stateid;
const chunks = [];
let offset = BigInt(0);
const chunkSize = 65536;
try {
while (true) {
const readResponse = await this.fs.compound([builder_1.nfs.READ(offset, chunkSize, stateid)]);
if (readResponse.status !== 0) {
throw new Error(`Failed to read file: ${readResponse.status}`);
}
const readRes = readResponse.resarray[0];
if (readRes.status !== 0 || !readRes.resok) {
throw new Error(`Failed to read file: ${readRes.status}`);
}
if (readRes.resok.data.length > 0) {
chunks.push(readRes.resok.data);
offset += BigInt(readRes.resok.data.length);
}
if (readRes.resok.eof)
break;
}
}
finally {
await this.closeStateid(openOwner, stateid);
}
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
const result = new Uint8Array(totalLength);
let position = 0;
for (const chunk of chunks) {
result.set(chunk, position);
position += chunk.length;
}
return this.decodeData(result, encoding);
};
this.writeFile = async (id, data, options) => {
const path = typeof id === 'string' ? id : id.toString();
const parts = this.parsePath(path);
const operations = this.navigateToParent(parts);
const filename = parts[parts.length - 1];
const openOwner = this.createDefaultOpenOwner();
const claim = builder_1.nfs.OpenClaimNull(filename);
const openSeqid = this.nextOpenOwnerSeqid(openOwner);
operations.push(builder_1.nfs.OPEN(openSeqid, 2, 0, openOwner, builder_1.nfs.OpenHowCreateUnchecked(), claim));
const writer = new Writer_1.Writer(16);
const xdr = new XdrEncoder_1.XdrEncoder(writer);
xdr.writeUnsignedHyper(BigInt(0));
const attrVals = writer.flush();
const truncateAttrs = builder_1.nfs.Fattr([4], attrVals);
const stateid = builder_1.nfs.Stateid(0, new Uint8Array(12));
operations.push(builder_1.nfs.SETATTR(stateid, truncateAttrs));
const openResponse = await this.fs.compound(operations);
if (openResponse.status !== 0) {
throw new Error(`Failed to open file: ${openResponse.status}`);
}
const openRes = openResponse.resarray[openResponse.resarray.length - 2];
if (openRes.status !== 0 || !openRes.resok) {
throw new Error(`Failed to open file: ${openRes.status}`);
}
const openStateid = openRes.resok.stateid;
const buffer = this.encodeData(data);
const chunkSize = 65536;
try {
let offset = BigInt(0);
for (let i = 0; i < buffer.length; i += chunkSize) {
const chunk = buffer.slice(i, Math.min(i + chunkSize, buffer.length));
const writeResponse = await this.fs.compound([
builder_1.nfs.WRITE(openStateid, offset, 2, chunk),
]);
if (writeResponse.status !== 0) {
throw new Error(`Failed to write file: ${writeResponse.status}`);
}
const writeRes = writeResponse.resarray[0];
if (writeRes.status !== 0 || !writeRes.resok) {
throw new Error(`Failed to write file: ${writeRes.status}`);
}
offset += BigInt(writeRes.resok.count);
}
}
finally {
await this.closeStateid(openOwner, openStateid);
}
};
this.stat = async (path, options) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
const attrNums = [
1,
4,
20,
33,
35,
45,
47,
53,
52,
];
const attrMask = this.attrNumsToBitmap(attrNums);
operations.push(builder_1.nfs.GETATTR(attrMask));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to stat file: ${response.status}`);
}
const getattrRes = response.resarray[response.resarray.length - 1];
if (getattrRes.status !== 0 || !getattrRes.resok) {
throw new Error(`Failed to get attributes: ${getattrRes.status}`);
}
const fattr = getattrRes.resok.objAttributes;
const reader = new Reader_1.Reader();
reader.reset(fattr.attrVals);
const xdr = new XdrDecoder_1.XdrDecoder(reader);
let fileType = 1;
let size = 0;
let fileid = 0;
let mode = 0;
let nlink = 1;
let spaceUsed = 0;
let atime = new Date(0);
let mtime = new Date(0);
let ctime = new Date(0);
const returnedMask = fattr.attrmask.mask;
for (let i = 0; i < returnedMask.length; i++) {
const word = returnedMask[i];
if (!word)
continue;
for (let bit = 0; bit < 32; bit++) {
if (!(word & (1 << bit)))
continue;
const attrNum = i * 32 + bit;
switch (attrNum) {
case 1:
fileType = xdr.readUnsignedInt();
break;
case 4:
size = Number(xdr.readUnsignedHyper());
break;
case 20:
fileid = Number(xdr.readUnsignedHyper());
break;
case 33:
mode = xdr.readUnsignedInt();
break;
case 35:
nlink = xdr.readUnsignedInt();
break;
case 45:
spaceUsed = Number(xdr.readUnsignedHyper());
break;
case 47: {
const seconds = Number(xdr.readHyper());
const nseconds = xdr.readUnsignedInt();
atime = new Date(seconds * 1000 + nseconds / 1000000);
break;
}
case 53: {
const seconds = Number(xdr.readHyper());
const nseconds = xdr.readUnsignedInt();
mtime = new Date(seconds * 1000 + nseconds / 1000000);
break;
}
case 52: {
const seconds = Number(xdr.readHyper());
const nseconds = xdr.readUnsignedInt();
ctime = new Date(seconds * 1000 + nseconds / 1000000);
break;
}
}
}
}
const blocks = Math.ceil(spaceUsed / 512);
return new NfsFsStats_1.NfsFsStats(0, 0, 0, 4096, fileid, size, blocks, atime, mtime, ctime, mtime, atime.getTime(), mtime.getTime(), ctime.getTime(), mtime.getTime(), 0, mode, nlink, fileType);
};
this.lstat = async (path, options) => {
return this.stat(path, options);
};
this.mkdir = async (path, options) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
if (parts.length === 0) {
throw new Error('Cannot create root directory');
}
const operations = this.navigateToParent(parts);
const dirname = parts[parts.length - 1];
const createType = builder_1.nfs.CreateTypeDir();
const emptyAttrs = builder_1.nfs.Fattr([], new Uint8Array(0));
operations.push(builder_1.nfs.CREATE(createType, dirname, emptyAttrs));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to create directory: ${response.status}`);
}
const createRes = response.resarray[response.resarray.length - 1];
if (createRes.status !== 0) {
throw new Error(`Failed to create directory: ${createRes.status}`);
}
return undefined;
};
this.readdir = async (path, options) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const withFileTypes = typeof options === 'object' && options?.withFileTypes;
const encoding = typeof options === 'string' ? options : options?.encoding;
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
const attrNums = withFileTypes ? [1] : [];
const attrMask = this.attrNumsToBitmap(attrNums);
operations.push(builder_1.nfs.READDIR(attrMask));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to read directory: ${response.status}`);
}
const readdirRes = response.resarray[response.resarray.length - 1];
if (readdirRes.status !== 0 || !readdirRes.resok) {
throw new Error(`Failed to read directory: ${readdirRes.status}`);
}
const entries = [];
const dirents = [];
const entryList = readdirRes.resok.entries;
for (let i = 0; i < entryList.length; i++) {
const entry = entryList[i];
const name = entry.name;
if (withFileTypes) {
const fattr = entry.attrs;
const reader = new Reader_1.Reader();
reader.reset(fattr.attrVals);
const xdr = new XdrDecoder_1.XdrDecoder(reader);
let fileType = 1;
const returnedMask = fattr.attrmask.mask;
for (let i = 0; i < returnedMask.length; i++) {
const word = returnedMask[i];
if (!word)
continue;
for (let bit = 0; bit < 32; bit++) {
if (!(word & (1 << bit)))
continue;
const attrNum = i * 32 + bit;
if (attrNum === 1) {
fileType = xdr.readUnsignedInt();
}
}
}
dirents.push(new NfsFsDirent_1.NfsFsDirent(name, fileType));
}
else {
entries.push(name);
}
}
if (withFileTypes) {
return dirents;
}
if (encoding && encoding !== 'utf8') {
return entries.map((name) => Buffer.from(name, 'utf8'));
}
return entries;
};
this.appendFile = async (path, data, options) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToParent(parts);
const filename = parts[parts.length - 1];
const openOwner = this.createDefaultOpenOwner();
const claim = builder_1.nfs.OpenClaimNull(filename);
const openSeqid = this.nextOpenOwnerSeqid(openOwner);
operations.push(builder_1.nfs.OPEN(openSeqid, 2, 0, openOwner, builder_1.nfs.OpenHowNoCreate(), claim));
const attrNums = [4];
const attrMask = this.attrNumsToBitmap(attrNums);
operations.push(builder_1.nfs.GETATTR(attrMask));
const openResponse = await this.fs.compound(operations);
if (openResponse.status !== 0) {
throw new Error(`Failed to open file: ${openResponse.status}`);
}
const openRes = openResponse.resarray[openResponse.resarray.length - 2];
if (openRes.status !== 0 || !openRes.resok) {
throw new Error(`Failed to open file: ${openRes.status}`);
}
const getattrRes = openResponse.resarray[openResponse.resarray.length - 1];
if (getattrRes.status !== 0 || !getattrRes.resok) {
throw new Error(`Failed to get attributes: ${getattrRes.status}`);
}
const fattr = getattrRes.resok.objAttributes;
const reader = new Reader_1.Reader();
reader.reset(fattr.attrVals);
const xdr = new XdrDecoder_1.XdrDecoder(reader);
const currentSize = Number(xdr.readUnsignedHyper());
const openStateid = openRes.resok.stateid;
const buffer = this.encodeData(data);
const chunkSize = 65536;
try {
let offset = BigInt(currentSize);
for (let i = 0; i < buffer.length; i += chunkSize) {
const chunk = buffer.slice(i, Math.min(i + chunkSize, buffer.length));
const writeResponse = await this.fs.compound([
builder_1.nfs.WRITE(openStateid, offset, 2, chunk),
]);
if (writeResponse.status !== 0) {
throw new Error(`Failed to write file: ${writeResponse.status}`);
}
const writeRes = writeResponse.resarray[0];
if (writeRes.status !== 0 || !writeRes.resok) {
throw new Error(`Failed to write file: ${writeRes.status}`);
}
offset += BigInt(writeRes.resok.count);
}
}
finally {
await this.closeStateid(openOwner, openStateid);
}
};
this.truncate = async (path, len = 0) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
const writer = new Writer_1.Writer(16);
const xdr = new XdrEncoder_1.XdrEncoder(writer);
xdr.writeUnsignedHyper(BigInt(len));
const attrVals = writer.flush();
const sizeAttrs = builder_1.nfs.Fattr([4], attrVals);
const stateid = builder_1.nfs.Stateid(0, new Uint8Array(12));
operations.push(builder_1.nfs.SETATTR(stateid, sizeAttrs));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to truncate file: ${response.status}`);
}
const setattrRes = response.resarray[response.resarray.length - 1];
if (setattrRes.status !== 0) {
throw new Error(`Failed to truncate file: ${setattrRes.status}`);
}
};
this.unlink = async (path) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
if (parts.length === 0) {
throw new Error('Cannot unlink root directory');
}
const operations = this.navigateToParent(parts);
const filename = parts[parts.length - 1];
operations.push(builder_1.nfs.REMOVE(filename));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to unlink file: ${response.status}`);
}
const removeRes = response.resarray[response.resarray.length - 1];
if (removeRes.status !== 0) {
throw new Error(`Failed to unlink file: ${removeRes.status}`);
}
};
this.rmdir = async (path, options) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
if (parts.length === 0) {
throw new Error('Cannot remove root directory');
}
const operations = this.navigateToParent(parts);
const dirname = parts[parts.length - 1];
operations.push(builder_1.nfs.REMOVE(dirname));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to remove directory: ${response.status}`);
}
const removeRes = response.resarray[response.resarray.length - 1];
if (removeRes.status !== 0) {
throw new Error(`Failed to remove directory: ${removeRes.status}`);
}
};
this.rm = async (path, options) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
if (parts.length === 0) {
throw new Error('Cannot remove root directory');
}
const force = options?.force ?? false;
const recursive = options?.recursive ?? false;
if (recursive) {
try {
const stats = await this.stat(path);
if (stats.isDirectory()) {
const entries = await this.readdir(path);
for (const entry of entries) {
const entryPath = pathStr + '/' + entry;
await this.rm(entryPath, options);
}
}
}
catch (err) {
if (!force)
throw err;
return;
}
}
try {
const operations = this.navigateToParent(parts);
const name = parts[parts.length - 1];
operations.push(builder_1.nfs.REMOVE(name));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
if (!force)
throw new Error(`Failed to remove: ${response.status}`);
return;
}
const removeRes = response.resarray[response.resarray.length - 1];
if (removeRes.status !== 0) {
if (!force)
throw new Error(`Failed to remove: ${removeRes.status}`);
}
}
catch (err) {
if (!force)
throw err;
}
};
this.access = async (path, mode = 0) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
let accessMask = 0;
if (mode === 0) {
accessMask = 1;
}
else {
if (mode & 4)
accessMask |= 1;
if (mode & 2)
accessMask |= 4;
if (mode & 1)
accessMask |= 32;
}
operations.push(builder_1.nfs.ACCESS(accessMask));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Access denied: ${response.status}`);
}
const accessRes = response.resarray[response.resarray.length - 1];
if (accessRes.status !== 0) {
throw new Error(`Access denied: ${accessRes.status}`);
}
};
this.rename = async (oldPath, newPath) => {
const oldPathStr = typeof oldPath === 'string' ? oldPath : oldPath.toString();
const newPathStr = typeof newPath === 'string' ? newPath : newPath.toString();
const oldParts = this.parsePath(oldPathStr);
const newParts = this.parsePath(newPathStr);
if (oldParts.length === 0 || newParts.length === 0) {
throw new Error('Cannot rename root directory');
}
const operations = [];
operations.push(builder_1.nfs.PUTROOTFH());
for (const part of oldParts.slice(0, -1)) {
operations.push(builder_1.nfs.LOOKUP(part));
}
operations.push(builder_1.nfs.SAVEFH());
operations.push(builder_1.nfs.PUTROOTFH());
for (const part of newParts.slice(0, -1)) {
operations.push(builder_1.nfs.LOOKUP(part));
}
const oldname = oldParts[oldParts.length - 1];
const newname = newParts[newParts.length - 1];
operations.push(builder_1.nfs.RENAME(oldname, newname));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to rename: ${response.status}`);
}
const renameRes = response.resarray[response.resarray.length - 1];
if (renameRes.status !== 0) {
throw new Error(`Failed to rename: ${renameRes.status}`);
}
};
this.copyFile = async (src, dest, flags) => {
const data = await this.readFile(src);
await this.writeFile(dest, data);
};
this.realpath = async (path, options) => {
const encoding = typeof options === 'string' ? options : options?.encoding;
const pathStr = typeof path === 'string' ? path : path.toString();
const normalized = '/' + this.parsePath(pathStr).join('/');
if (!encoding || encoding === 'utf8') {
return normalized;
}
return Buffer.from(normalized, 'utf8');
};
this.link = async (existingPath, newPath) => {
const existingPathStr = typeof existingPath === 'string' ? existingPath : existingPath.toString();
const newPathStr = typeof newPath === 'string' ? newPath : newPath.toString();
const existingParts = this.parsePath(existingPathStr);
const newParts = this.parsePath(newPathStr);
if (newParts.length === 0) {
throw new Error('Cannot create link at root');
}
const operations = this.navigateToPath(existingParts);
operations.push(builder_1.nfs.SAVEFH());
operations.push(builder_1.nfs.PUTROOTFH());
for (const part of newParts.slice(0, -1)) {
operations.push(builder_1.nfs.LOOKUP(part));
}
const newname = newParts[newParts.length - 1];
operations.push(builder_1.nfs.LINK(newname));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to create link: ${response.status}`);
}
const linkRes = response.resarray[response.resarray.length - 1];
if (linkRes.status !== 0) {
throw new Error(`Failed to create link: ${linkRes.status}`);
}
};
this.symlink = async (target, path, type) => {
const targetStr = typeof target === 'string' ? target : target.toString();
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
if (parts.length === 0) {
throw new Error('Cannot create symlink at root');
}
const operations = this.navigateToParent(parts);
const linkname = parts[parts.length - 1];
const createType = new structs.Nfsv4CreateType(5, new structs.Nfsv4CreateTypeLink(targetStr));
const emptyAttrs = builder_1.nfs.Fattr([], new Uint8Array(0));
operations.push(builder_1.nfs.CREATE(createType, linkname, emptyAttrs));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to create symlink: ${response.status}`);
}
const createRes = response.resarray[response.resarray.length - 1];
if (createRes.status !== 0) {
throw new Error(`Failed to create symlink: ${createRes.status}`);
}
};
this.utimes = async (path, atime, mtime) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
const atimeMs = typeof atime === 'number' ? atime : atime instanceof Date ? atime.getTime() : Date.now();
const mtimeMs = typeof mtime === 'number' ? mtime : mtime instanceof Date ? mtime.getTime() : Date.now();
const writer = new Writer_1.Writer(64);
const xdr = new XdrEncoder_1.XdrEncoder(writer);
xdr.writeUnsignedInt(1);
xdr.writeHyper(BigInt(Math.floor(atimeMs / 1000)));
xdr.writeUnsignedInt((atimeMs % 1000) * 1000000);
xdr.writeUnsignedInt(1);
xdr.writeHyper(BigInt(Math.floor(mtimeMs / 1000)));
xdr.writeUnsignedInt((mtimeMs % 1000) * 1000000);
const attrVals = writer.flush();
const timeAttrs = builder_1.nfs.Fattr([48, 54], attrVals);
const stateid = builder_1.nfs.Stateid(0, new Uint8Array(12));
operations.push(builder_1.nfs.SETATTR(stateid, timeAttrs));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to set times: ${response.status}`);
}
const setattrRes = response.resarray[response.resarray.length - 1];
if (setattrRes.status !== 0) {
throw new Error(`Failed to set times: ${setattrRes.status}`);
}
};
this.readlink = async (path, options) => {
const encoding = typeof options === 'string' ? options : options?.encoding;
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
operations.push(builder_1.nfs.READLINK());
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to read link: ${response.status}`);
}
const readlinkRes = response.resarray[response.resarray.length - 1];
if (readlinkRes.status !== 0 || !readlinkRes.resok) {
throw new Error(`Failed to read link: ${readlinkRes.status}`);
}
if (!encoding || encoding === 'utf8') {
return readlinkRes.resok.link;
}
return Buffer.from(readlinkRes.resok.link, 'utf8');
};
this.opendir = async (path, options) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
return new NfsFsDir_1.NfsFsDir(pathStr, this.fs, operations);
};
this.mkdtemp = async (prefix, options) => {
const encoding = typeof options === 'string' ? options : options?.encoding;
const randomSuffix = Math.random().toString(36).substring(2, 8);
const dirName = prefix + randomSuffix;
await this.mkdir(dirName);
if (!encoding || encoding === 'utf8')
return dirName;
return Buffer.from(dirName, 'utf8');
};
this.chmod = async (path, mode) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
const modeValue = typeof mode === 'number' ? mode : parseInt(mode.toString(), 8);
const writer = new Writer_1.Writer(8);
const xdr = new XdrEncoder_1.XdrEncoder(writer);
xdr.writeUnsignedInt(modeValue);
const attrVals = writer.flush();
const attrs = builder_1.nfs.Fattr([33], attrVals);
const stateid = builder_1.nfs.Stateid(0, new Uint8Array(12));
operations.push(builder_1.nfs.SETATTR(stateid, attrs));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to chmod: ${response.status}`);
}
const setattrRes = response.resarray[response.resarray.length - 1];
if (setattrRes.status !== 0) {
throw new Error(`Failed to chmod: ${setattrRes.status}`);
}
};
this.chown = async (path, uid, gid) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToPath(parts);
const writer = new Writer_1.Writer(64);
const xdr = new XdrEncoder_1.XdrEncoder(writer);
xdr.writeStr(uid.toString());
xdr.writeStr(gid.toString());
const attrVals = writer.flush();
const attrs = builder_1.nfs.Fattr([36, 37], attrVals);
const stateid = builder_1.nfs.Stateid(0, new Uint8Array(12));
operations.push(builder_1.nfs.SETATTR(stateid, attrs));
const response = await this.fs.compound(operations);
if (response.status !== 0) {
throw new Error(`Failed to chown: ${response.status}`);
}
const setattrRes = response.resarray[response.resarray.length - 1];
if (setattrRes.status !== 0) {
throw new Error(`Failed to chown: ${setattrRes.status}`);
}
};
this.lchmod = async (path, mode) => {
return this.chmod(path, mode);
};
this.lchown = async (path, uid, gid) => {
return this.chown(path, uid, gid);
};
this.lutimes = async (path, atime, mtime) => {
return this.utimes(path, atime, mtime);
};
this.open = async (path, flags, mode) => {
const pathStr = typeof path === 'string' ? path : path.toString();
const parts = this.parsePath(pathStr);
const operations = this.navigateToParent(parts);
const filename = parts[parts.length - 1];
const openOwner = this.createDefaultOpenOwner();
const claim = builder_1.nfs.OpenClaimNull(filename);
let access = 1;
const openSeqid = this.nextOpenOwnerSeqid(openOwner);
if (typeof flags === 'string') {
if (flags.includes('r') && flags.includes('+')) {
access = 3;
}
else if (flags.includes('w') || flags.includes('a')) {
access = 2;
if (flags.includes('+')) {
access = 3;
}
}
}
else if (typeof flags === 'number') {
const O_RDONLY = 0;
const O_WRONLY = 1;
const O_RDWR = 2;
const O_ACCMODE = 3;
const accessMode = flags & O_ACCMODE;
switch (accessMode) {
case O_RDONLY:
access = 1;
break;
case O_WRONLY:
access = 2;
break;
case O_RDWR:
access = 3;
break;
}
}
operations.push(builder_1.nfs.OPEN(openSeqid, access, 0, openOwner, builder_1.nfs.OpenHowNoCreate(), claim));
const openResponse = await this.fs.compound(operations);
if (openResponse.status !== 0) {
throw new Error(`Failed to open file: ${openResponse.status}`);
}
const openRes = openResponse.resarray[openResponse.resarray.length - 1];
if (openRes.status !== 0 || !openRes.resok) {
throw new Error(`Failed to open file: ${openRes.status}`);
}
const stateid = openRes.resok.stateid;
const fd = Math.floor(Math.random() * 1000000);
return new NfsFsFileHandle_1.NfsFsFileHandle(fd, pathStr, this, stateid, openOwner);
};
this.statfs = (path, options) => {
throw new Error('Not implemented.');
};
this.watch = (filename, options) => {
throw new Error('Not implemented.');
};
this.glob = (pattern, options) => {
throw new Error('Not implemented.');
};
}
makeOpenOwnerKey(owner) {
return `${owner.clientid}:${Buffer.from(owner.owner).toString('hex')}`;
}
nextOpenOwnerSeqid(owner) {
const key = this.makeOpenOwnerKey(owner);
const last = this.openOwnerSeqids.get(key);
const next = last === undefined ? 0 : last === 0xffffffff ? 1 : (last + 1) >>> 0;
this.openOwnerSeqids.set(key, next);
return next;
}
createDefaultOpenOwner() {
return builder_1.nfs.OpenOwner(BigInt(1), new Uint8Array(this.defaultOpenOwnerId));
}
attrNumsToBitmap(attrNums) {
const bitmap = [];
for (const attrNum of attrNums) {
const wordIndex = Math.floor(attrNum / 32);
const bitIndex = attrNum % 32;
while (bitmap.length <= wordIndex) {
bitmap.push(0);
}
bitmap[wordIndex] |= 1 << bitIndex;
}
return bitmap;
}
parsePath(path) {
const normalized = path.replace(/^\/+/, '').replace(/\/+$/, '');
if (!normalized)
return [];
return normalized.split('/').filter((part) => part.length > 0);
}
navigateToParent(parts) {
const operations = [builder_1.nfs.PUTROOTFH()];
for (const part of parts.slice(0, -1)) {
operations.push(builder_1.nfs.LOOKUP(part));
}
return operations;
}
navigateToPath(parts) {
const operations = [builder_1.nfs.PUTROOTFH()];
for (const part of parts) {
operations.push(builder_1.nfs.LOOKUP(part));
}
return operations;
}
encodeData(data) {
if (data instanceof Uint8Array)
return data;
if (data instanceof ArrayBuffer)
return new Uint8Array(data);
if (typeof data === 'string')
return new TextEncoder().encode(data);
if (Buffer.isBuffer(data))
return new Uint8Array(data);
throw new Error('Unsupported data type');
}
decodeData(data, encoding) {
if (!encoding || encoding === 'buffer')
return Buffer.from(data);
return new TextDecoder(encoding).decode(data);
}
}
exports.Nfsv4FsClient = Nfsv4FsClient;
//# sourceMappingURL=Nfsv4FsClient.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
/// <reference types="node" />
import * as stream from 'node:stream';
import { Nfsv4CompoundRequest, Nfsv4CompoundResponse, Nfsv4Request } from '../messages';
import type { Nfsv4Client } from './types';
export interface Nfsv4TcpClientOpts {
host?: string;
port?: number;
timeout?: number;
debug?: boolean;
logger?: Pick<typeof console, 'log' | 'error'>;
}
export declare class Nfsv4TcpClient implements Nfsv4Client {
static fromDuplex(duplex: stream.Duplex, opts?: Nfsv4TcpClientOpts): Nfsv4TcpClient;
readonly host: string;
readonly port: number;
readonly timeout: number;
debug: boolean;
logger: Pick<typeof console, 'log' | 'error'>;
private socket;
private connected;
private connecting;
private xid;
private seqid;
private pendingRequests;
private readonly rmDecoder;
private readonly rpcDecoder;
private readonly nfsDecoder;
private readonly nfsEncoder;
constructor(opts?: Nfsv4TcpClientOpts);
private nextXid;
connect(): Promise<void>;
protected setSocket(socket: stream.Duplex): void;
private onData;
private onRpcMessage;
private onClose;
compound(request: Nfsv4CompoundRequest): Promise<Nfsv4CompoundResponse>;
compound(operations: Nfsv4Request[], tag?: string, minorversion?: number): Promise<Nfsv4CompoundResponse>;
null(): Promise<void>;
close(): void;
isConnected(): boolean;
}

View File

@@ -0,0 +1,216 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv4TcpClient = void 0;
const tslib_1 = require("tslib");
const net = tslib_1.__importStar(require("node:net"));
const Nfsv4Decoder_1 = require("../Nfsv4Decoder");
const Nfsv4FullEncoder_1 = require("../Nfsv4FullEncoder");
const rm_1 = require("../../../rm");
const rpc_1 = require("../../../rpc");
const constants_1 = require("../constants");
const messages_1 = require("../messages");
class Nfsv4TcpClient {
static fromDuplex(duplex, opts = {}) {
const client = new Nfsv4TcpClient(opts);
client.setSocket(duplex);
return client;
}
constructor(opts = {}) {
this.socket = null;
this.connected = false;
this.connecting = false;
this.xid = 0;
this.seqid = 0;
this.pendingRequests = new Map();
this.host = opts.host || '127.0.0.1';
this.port = opts.port || 2049;
this.timeout = opts.timeout || 30000;
this.debug = !!opts.debug;
this.logger = opts.logger || console;
this.rmDecoder = new rm_1.RmRecordDecoder();
this.rpcDecoder = new rpc_1.RpcMessageDecoder();
this.nfsDecoder = new Nfsv4Decoder_1.Nfsv4Decoder();
this.nfsEncoder = new Nfsv4FullEncoder_1.Nfsv4FullEncoder();
}
nextXid() {
this.xid = (this.xid + 1) >>> 0;
if (this.xid === 0)
this.xid = 1;
return this.xid;
}
async connect() {
if (this.connected)
return;
if (this.connecting)
throw new Error('Connection already in progress');
return new Promise((resolve, reject) => {
this.connecting = true;
const onError = (err) => {
this.connecting = false;
this.connected = false;
if (this.debug)
this.logger.error('Socket error:', err);
reject(err);
};
const socket = net.connect({ host: this.host, port: this.port }, () => {
if (this.debug)
this.logger.log(`Connected to NFSv4 server at ${this.host}:${this.port}`);
socket.removeListener('error', onError);
resolve();
this.setSocket(socket);
});
socket.once('error', onError);
});
}
setSocket(socket) {
socket.on('data', this.onData.bind(this));
socket.on('close', this.onClose.bind(this));
socket.on('error', (err) => {
this.connecting = false;
this.connected = false;
if (this.debug)
this.logger.error('Socket error:', err);
});
this.connected = true;
this.connecting = false;
this.socket = socket;
}
onData(data) {
const { rmDecoder, rpcDecoder } = this;
rmDecoder.push(data);
let record = rmDecoder.readRecord();
while (record) {
if (record.size()) {
const rpcMessage = rpcDecoder.decodeMessage(record);
if (rpcMessage)
this.onRpcMessage(rpcMessage);
else if (this.debug)
this.logger.error('Failed to decode RPC message');
}
record = rmDecoder.readRecord();
}
}
onRpcMessage(msg) {
if (msg instanceof rpc_1.RpcAcceptedReplyMessage) {
const pending = this.pendingRequests.get(msg.xid);
if (!pending) {
if (this.debug)
this.logger.error(`No pending request for XID ${msg.xid}`);
return;
}
this.pendingRequests.delete(msg.xid);
if (pending.timeout)
clearTimeout(pending.timeout);
if (msg.stat !== 0) {
pending.reject(new Error(`RPC accepted reply error: stat=${msg.stat}`));
return;
}
if (!msg.results) {
if (pending.resolve.length === 0) {
pending.resolve();
return;
}
pending.reject(new Error('No results in accepted reply'));
return;
}
const response = this.nfsDecoder.decodeCompoundResponse(msg.results);
if (!response) {
pending.reject(new Error('Failed to decode COMPOUND response'));
return;
}
pending.resolve(response);
}
else if (msg instanceof rpc_1.RpcRejectedReplyMessage) {
const pending = this.pendingRequests.get(msg.xid);
if (!pending) {
if (this.debug)
this.logger.error(`No pending request for XID ${msg.xid}`);
return;
}
this.pendingRequests.delete(msg.xid);
if (pending.timeout)
clearTimeout(pending.timeout);
pending.reject(new Error(`RPC rejected reply: stat=${msg.stat}`));
}
else {
if (this.debug)
this.logger.error('Unexpected RPC message type:', msg);
}
}
onClose() {
this.connected = false;
this.connecting = false;
if (this.debug)
this.logger.log('Connection closed');
const error = new Error('Connection closed');
this.pendingRequests.forEach((pending, xid) => {
if (pending.timeout)
clearTimeout(pending.timeout);
pending.reject(error);
});
this.pendingRequests.clear();
}
async compound(requestOrOps, tag = '', minorversion = 0) {
if (!this.connected)
throw new Error('Not connected');
const request = requestOrOps instanceof messages_1.Nfsv4CompoundRequest
? requestOrOps
: new messages_1.Nfsv4CompoundRequest(tag, minorversion, requestOrOps);
const xid = this.nextXid();
const cred = new rpc_1.RpcOpaqueAuth(0, constants_1.EMPTY_READER);
const verf = new rpc_1.RpcOpaqueAuth(0, constants_1.EMPTY_READER);
const encoded = this.nfsEncoder.encodeCall(xid, 1, cred, verf, request);
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
this.pendingRequests.delete(xid);
reject(new Error(`Request timeout (XID ${xid})`));
}, this.timeout);
this.pendingRequests.set(xid, { resolve, reject, timeout });
this.socket.write(encoded);
if (this.debug) {
this.logger.log(`Sent COMPOUND request (XID ${xid}): ${request.argarray.length} operations`);
}
});
}
async null() {
if (!this.connected)
throw new Error('Not connected');
const xid = this.nextXid();
const cred = new rpc_1.RpcOpaqueAuth(0, constants_1.EMPTY_READER);
const verf = new rpc_1.RpcOpaqueAuth(0, constants_1.EMPTY_READER);
const writer = this.nfsEncoder.writer;
const rmEncoder = this.nfsEncoder.rmEncoder;
const rpcEncoder = this.nfsEncoder.rpcEncoder;
const state = rmEncoder.startRecord();
rpcEncoder.writeCall(xid, 100003, 4, 0, cred, verf);
rmEncoder.endRecord(state);
const encoded = writer.flush();
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
this.pendingRequests.delete(xid);
reject(new Error(`NULL request timeout (XID ${xid})`));
}, this.timeout);
this.pendingRequests.set(xid, {
resolve: () => resolve(),
reject,
timeout,
});
this.socket.write(encoded);
if (this.debug)
this.logger.log(`Sent NULL request (XID ${xid})`);
});
}
close() {
if (this.socket) {
this.socket.end();
this.socket = null;
}
this.connected = false;
this.connecting = false;
}
isConnected() {
return this.connected;
}
}
exports.Nfsv4TcpClient = Nfsv4TcpClient;
//# sourceMappingURL=Nfsv4TcpClient.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { FsPromisesApi } from 'memfs/lib/node/types';
import * as msg from '../messages';
export interface Nfsv4Client {
compound(request: msg.Nfsv4CompoundRequest): Promise<msg.Nfsv4CompoundResponse>;
compound(operations: msg.Nfsv4Request[], tag?: string, minorversion?: number): Promise<msg.Nfsv4CompoundResponse>;
null(): Promise<void>;
}
export interface NfsFsClient extends Pick<FsPromisesApi, 'readFile' | 'writeFile' | 'readdir' | 'mkdir' | 'access' | 'appendFile' | 'copyFile' | 'link' | 'realpath' | 'rename' | 'rmdir' | 'truncate' | 'unlink' | 'utimes' | 'symlink' | 'stat' | 'readlink' | 'opendir' | 'open' | 'chmod' | 'rm' | 'chown' | 'lchmod' | 'lchown' | 'lutimes' | 'lstat' | 'mkdtemp' | 'statfs' | 'watch' | 'glob'> {
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/nfs/v4/client/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,316 @@
import { Reader } from '@jsonjoy.com/buffers/lib/Reader';
export declare const EMPY_U8: Uint8Array;
export declare const EMPTY_READER: Reader;
export declare const enum Nfsv4Const {
PROGRAM = 100003,
VERSION = 4,
FHSIZE = 128,
VERIFIER_SIZE = 8,
OPAQUE_LIMIT = 1024,
OTHER_SIZE = 12
}
export declare const enum Nfsv4Proc {
NULL = 0,
COMPOUND = 1
}
export declare const enum Nfsv4CbProc {
CB_NULL = 0,
CB_COMPOUND = 1
}
export declare const enum Nfsv4Op {
ACCESS = 3,
CLOSE = 4,
COMMIT = 5,
CREATE = 6,
DELEGPURGE = 7,
DELEGRETURN = 8,
GETATTR = 9,
GETFH = 10,
LINK = 11,
LOCK = 12,
LOCKT = 13,
LOCKU = 14,
LOOKUP = 15,
LOOKUPP = 16,
NVERIFY = 17,
OPEN = 18,
OPENATTR = 19,
OPEN_CONFIRM = 20,
OPEN_DOWNGRADE = 21,
PUTFH = 22,
PUTPUBFH = 23,
PUTROOTFH = 24,
READ = 25,
READDIR = 26,
READLINK = 27,
REMOVE = 28,
RENAME = 29,
RENEW = 30,
RESTOREFH = 31,
SAVEFH = 32,
SECINFO = 33,
SETATTR = 34,
SETCLIENTID = 35,
SETCLIENTID_CONFIRM = 36,
VERIFY = 37,
WRITE = 38,
RELEASE_LOCKOWNER = 39,
ILLEGAL = 10044
}
export declare const enum Nfsv4CbOp {
CB_GETATTR = 3,
CB_RECALL = 4,
CB_ILLEGAL = 10044
}
export declare const enum Nfsv4Stat {
NFS4_OK = 0,
NFS4ERR_PERM = 1,
NFS4ERR_NOENT = 2,
NFS4ERR_IO = 5,
NFS4ERR_NXIO = 6,
NFS4ERR_ACCESS = 13,
NFS4ERR_EXIST = 17,
NFS4ERR_XDEV = 18,
NFS4ERR_NOTDIR = 20,
NFS4ERR_ISDIR = 21,
NFS4ERR_INVAL = 22,
NFS4ERR_FBIG = 27,
NFS4ERR_NOSPC = 28,
NFS4ERR_ROFS = 30,
NFS4ERR_MLINK = 31,
NFS4ERR_NAMETOOLONG = 63,
NFS4ERR_NOTEMPTY = 66,
NFS4ERR_DQUOT = 69,
NFS4ERR_STALE = 70,
NFS4ERR_BADHANDLE = 10001,
NFS4ERR_BAD_COOKIE = 10003,
NFS4ERR_NOTSUPP = 10004,
NFS4ERR_TOOSMALL = 10005,
NFS4ERR_SERVERFAULT = 10006,
NFS4ERR_BADTYPE = 10007,
NFS4ERR_DELAY = 10008,
NFS4ERR_SAME = 10009,
NFS4ERR_DENIED = 10010,
NFS4ERR_EXPIRED = 10011,
NFS4ERR_LOCKED = 10012,
NFS4ERR_GRACE = 10013,
NFS4ERR_FHEXPIRED = 10014,
NFS4ERR_SHARE_DENIED = 10015,
NFS4ERR_WRONGSEC = 10016,
NFS4ERR_CLID_INUSE = 10017,
NFS4ERR_RESOURCE = 10018,
NFS4ERR_MOVED = 10019,
NFS4ERR_NOFILEHANDLE = 10020,
NFS4ERR_MINOR_VERS_MISMATCH = 10021,
NFS4ERR_STALE_CLIENTID = 10022,
NFS4ERR_STALE_STATEID = 10023,
NFS4ERR_OLD_STATEID = 10024,
NFS4ERR_BAD_STATEID = 10025,
NFS4ERR_BAD_SEQID = 10026,
NFS4ERR_NOT_SAME = 10027,
NFS4ERR_LOCK_RANGE = 10028,
NFS4ERR_SYMLINK = 10029,
NFS4ERR_RESTOREFH = 10030,
NFS4ERR_LEASE_MOVED = 10031,
NFS4ERR_ATTRNOTSUPP = 10032,
NFS4ERR_NO_GRACE = 10033,
NFS4ERR_RECLAIM_BAD = 10034,
NFS4ERR_RECLAIM_CONFLICT = 10035,
NFS4ERR_BADXDR = 10036,
NFS4ERR_LOCKS_HELD = 10037,
NFS4ERR_OPENMODE = 10038,
NFS4ERR_BADOWNER = 10039,
NFS4ERR_BADCHAR = 10040,
NFS4ERR_BADNAME = 10041,
NFS4ERR_BAD_RANGE = 10042,
NFS4ERR_LOCK_NOTSUPP = 10043,
NFS4ERR_OP_ILLEGAL = 10044,
NFS4ERR_DEADLOCK = 10045,
NFS4ERR_FILE_OPEN = 10046,
NFS4ERR_ADMIN_REVOKED = 10047,
NFS4ERR_CB_PATH_DOWN = 10048
}
export declare const enum Nfsv4FType {
NF4REG = 1,
NF4DIR = 2,
NF4BLK = 3,
NF4CHR = 4,
NF4LNK = 5,
NF4SOCK = 6,
NF4FIFO = 7,
NF4ATTRDIR = 8,
NF4NAMEDATTR = 9
}
export declare const enum Nfsv4TimeHow {
SET_TO_SERVER_TIME4 = 0,
SET_TO_CLIENT_TIME4 = 1
}
export declare const enum Nfsv4StableHow {
UNSTABLE4 = 0,
DATA_SYNC4 = 1,
FILE_SYNC4 = 2
}
export declare const enum Nfsv4CreateMode {
UNCHECKED4 = 0,
GUARDED4 = 1,
EXCLUSIVE4 = 2
}
export declare const enum Nfsv4OpenFlags {
OPEN4_NOCREATE = 0,
OPEN4_CREATE = 1
}
export declare const enum Nfsv4OpenAccess {
OPEN4_SHARE_ACCESS_READ = 1,
OPEN4_SHARE_ACCESS_WRITE = 2,
OPEN4_SHARE_ACCESS_BOTH = 3
}
export declare const enum Nfsv4OpenDeny {
OPEN4_SHARE_DENY_NONE = 0,
OPEN4_SHARE_DENY_READ = 1,
OPEN4_SHARE_DENY_WRITE = 2,
OPEN4_SHARE_DENY_BOTH = 3
}
export declare const enum Nfsv4OpenClaimType {
CLAIM_NULL = 0,
CLAIM_PREVIOUS = 1,
CLAIM_DELEGATE_CUR = 2,
CLAIM_DELEGATE_PREV = 3
}
export declare const enum Nfsv4DelegType {
OPEN_DELEGATE_NONE = 0,
OPEN_DELEGATE_READ = 1,
OPEN_DELEGATE_WRITE = 2
}
export declare const enum Nfsv4LockType {
READ_LT = 1,
WRITE_LT = 2,
READW_LT = 3,
WRITEW_LT = 4
}
export declare const enum Nfsv4Access {
ACCESS4_READ = 1,
ACCESS4_LOOKUP = 2,
ACCESS4_MODIFY = 4,
ACCESS4_EXTEND = 8,
ACCESS4_DELETE = 16,
ACCESS4_EXECUTE = 32
}
export declare const enum Nfsv4AceType {
ACE4_ACCESS_ALLOWED_ACE_TYPE = 0,
ACE4_ACCESS_DENIED_ACE_TYPE = 1,
ACE4_SYSTEM_AUDIT_ACE_TYPE = 2,
ACE4_SYSTEM_ALARM_ACE_TYPE = 3
}
export declare const enum Nfsv4AceFlag {
ACE4_FILE_INHERIT_ACE = 1,
ACE4_DIRECTORY_INHERIT_ACE = 2,
ACE4_NO_PROPAGATE_INHERIT_ACE = 4,
ACE4_INHERIT_ONLY_ACE = 8,
ACE4_SUCCESSFUL_ACCESS_ACE_FLAG = 16,
ACE4_FAILED_ACCESS_ACE_FLAG = 32,
ACE4_IDENTIFIER_GROUP = 64
}
export declare const enum Nfsv4AceMask {
ACE4_READ_DATA = 1,
ACE4_LIST_DIRECTORY = 1,
ACE4_WRITE_DATA = 2,
ACE4_ADD_FILE = 2,
ACE4_APPEND_DATA = 4,
ACE4_ADD_SUBDIRECTORY = 4,
ACE4_READ_NAMED_ATTRS = 8,
ACE4_WRITE_NAMED_ATTRS = 16,
ACE4_EXECUTE = 32,
ACE4_DELETE_CHILD = 64,
ACE4_READ_ATTRIBUTES = 128,
ACE4_WRITE_ATTRIBUTES = 256,
ACE4_DELETE = 65536,
ACE4_READ_ACL = 131072,
ACE4_WRITE_ACL = 262144,
ACE4_WRITE_OWNER = 524288,
ACE4_SYNCHRONIZE = 1048576
}
export declare const enum Nfsv4AclSupport {
ACL4_SUPPORT_ALLOW_ACL = 1,
ACL4_SUPPORT_DENY_ACL = 2,
ACL4_SUPPORT_AUDIT_ACL = 4,
ACL4_SUPPORT_ALARM_ACL = 8
}
export declare const enum Nfsv4Mode {
MODE4_SUID = 2048,
MODE4_SGID = 1024,
MODE4_SVTX = 512,
MODE4_RUSR = 256,
MODE4_WUSR = 128,
MODE4_XUSR = 64,
MODE4_RGRP = 32,
MODE4_WGRP = 16,
MODE4_XGRP = 8,
MODE4_ROTH = 4,
MODE4_WOTH = 2,
MODE4_XOTH = 1
}
export declare const enum Nfsv4FhExpireType {
FH4_PERSISTENT = 0,
FH4_NOEXPIRE_WITH_OPEN = 1,
FH4_VOLATILE_ANY = 2,
FH4_VOL_MIGRATION = 4,
FH4_VOL_RENAME = 8
}
export declare const enum Nfsv4Attr {
FATTR4_SUPPORTED_ATTRS = 0,
FATTR4_TYPE = 1,
FATTR4_FH_EXPIRE_TYPE = 2,
FATTR4_CHANGE = 3,
FATTR4_SIZE = 4,
FATTR4_LINK_SUPPORT = 5,
FATTR4_SYMLINK_SUPPORT = 6,
FATTR4_NAMED_ATTR = 7,
FATTR4_FSID = 8,
FATTR4_UNIQUE_HANDLES = 9,
FATTR4_LEASE_TIME = 10,
FATTR4_RDATTR_ERROR = 11,
FATTR4_ACL = 12,
FATTR4_ACLSUPPORT = 13,
FATTR4_ARCHIVE = 14,
FATTR4_CANSETTIME = 15,
FATTR4_CASE_INSENSITIVE = 16,
FATTR4_CASE_PRESERVING = 17,
FATTR4_CHOWN_RESTRICTED = 18,
FATTR4_FILEHANDLE = 19,
FATTR4_FILEID = 20,
FATTR4_FILES_AVAIL = 21,
FATTR4_FILES_FREE = 22,
FATTR4_FILES_TOTAL = 23,
FATTR4_FS_LOCATIONS = 24,
FATTR4_HIDDEN = 25,
FATTR4_HOMOGENEOUS = 26,
FATTR4_MAXFILESIZE = 27,
FATTR4_MAXLINK = 28,
FATTR4_MAXNAME = 29,
FATTR4_MAXREAD = 30,
FATTR4_MAXWRITE = 31,
FATTR4_MIMETYPE = 32,
FATTR4_MODE = 33,
FATTR4_NO_TRUNC = 34,
FATTR4_NUMLINKS = 35,
FATTR4_OWNER = 36,
FATTR4_OWNER_GROUP = 37,
FATTR4_QUOTA_AVAIL_HARD = 38,
FATTR4_QUOTA_AVAIL_SOFT = 39,
FATTR4_QUOTA_USED = 40,
FATTR4_RAWDEV = 41,
FATTR4_SPACE_AVAIL = 42,
FATTR4_SPACE_FREE = 43,
FATTR4_SPACE_TOTAL = 44,
FATTR4_SPACE_USED = 45,
FATTR4_SYSTEM = 46,
FATTR4_TIME_ACCESS = 47,
FATTR4_TIME_ACCESS_SET = 48,
FATTR4_TIME_BACKUP = 49,
FATTR4_TIME_CREATE = 50,
FATTR4_TIME_DELTA = 51,
FATTR4_TIME_METADATA = 52,
FATTR4_TIME_MODIFY = 53,
FATTR4_TIME_MODIFY_SET = 54,
FATTR4_MOUNTED_ON_FILEID = 55
}

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EMPTY_READER = exports.EMPY_U8 = void 0;
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
exports.EMPY_U8 = new Uint8Array(0);
exports.EMPTY_READER = new Reader_1.Reader(exports.EMPY_U8);
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/nfs/v4/constants.ts"],"names":[],"mappings":";;;AAAA,4DAAuD;AAE1C,QAAA,OAAO,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AAC5B,QAAA,YAAY,GAAG,IAAI,eAAM,CAAC,eAAO,CAAC,CAAC"}

View File

@@ -0,0 +1,6 @@
export declare class Nfsv4DecodingError extends Error {
constructor(message?: string);
}
export declare class Nfsv4EncodingError extends Error {
constructor(message?: string);
}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nfsv4EncodingError = exports.Nfsv4DecodingError = void 0;
class Nfsv4DecodingError extends Error {
constructor(message) {
super(message ? 'NFSv4_DECODING: ' + message : 'NFSv4_DECODING');
}
}
exports.Nfsv4DecodingError = Nfsv4DecodingError;
class Nfsv4EncodingError extends Error {
constructor(message) {
super(message ? 'NFSv4_ENCODING: ' + message : 'NFSv4_ENCODING');
}
}
exports.Nfsv4EncodingError = Nfsv4EncodingError;
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/nfs/v4/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACnE,CAAC;CACF;AAJD,gDAIC;AAED,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACnE,CAAC;CACF;AAJD,gDAIC"}

View File

@@ -0,0 +1,23 @@
import * as constants from './constants';
import * as structs from './structs';
import * as msg from './messages';
export declare const formatNfsv4Stat: (stat: constants.Nfsv4Stat) => string;
export declare const formatNfsv4Op: (op: constants.Nfsv4Op) => string;
export declare const formatNfsv4Attr: (attr: constants.Nfsv4Attr) => string;
export declare const formatNfsv4FType: (ftype: constants.Nfsv4FType) => string;
export declare const formatNfsv4TimeHow: (how: constants.Nfsv4TimeHow) => string;
export declare const formatNfsv4StableHow: (stable: constants.Nfsv4StableHow) => string;
export declare const formatNfsv4CreateMode: (mode: constants.Nfsv4CreateMode) => string;
export declare const formatNfsv4OpenFlags: (flags: constants.Nfsv4OpenFlags) => string;
export declare const formatNfsv4OpenAccess: (access: constants.Nfsv4OpenAccess) => string;
export declare const formatNfsv4OpenDeny: (deny: constants.Nfsv4OpenDeny) => string;
export declare const formatNfsv4OpenClaimType: (claim: constants.Nfsv4OpenClaimType) => string;
export declare const formatNfsv4DelegType: (deleg: constants.Nfsv4DelegType) => string;
export declare const formatNfsv4LockType: (locktype: constants.Nfsv4LockType) => string;
export declare const formatNfsv4Access: (access: number) => string;
export declare const formatNfsv4Mode: (mode: number) => string;
export declare const formatNfsv4Bitmap: (bitmap: structs.Nfsv4Bitmap) => string;
export declare const formatNfsv4Request: (req: msg.Nfsv4Request, tab?: string) => string;
export declare const formatNfsv4Response: (res: msg.Nfsv4Response, tab?: string) => string;
export declare const formatNfsv4CompoundRequest: (req: msg.Nfsv4CompoundRequest, tab?: string) => string;
export declare const formatNfsv4CompoundResponse: (res: msg.Nfsv4CompoundResponse, tab?: string) => string;

View File

@@ -0,0 +1,870 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatNfsv4CompoundResponse = exports.formatNfsv4CompoundRequest = exports.formatNfsv4Response = exports.formatNfsv4Request = exports.formatNfsv4Bitmap = exports.formatNfsv4Mode = exports.formatNfsv4Access = exports.formatNfsv4LockType = exports.formatNfsv4DelegType = exports.formatNfsv4OpenClaimType = exports.formatNfsv4OpenDeny = exports.formatNfsv4OpenAccess = exports.formatNfsv4OpenFlags = exports.formatNfsv4CreateMode = exports.formatNfsv4StableHow = exports.formatNfsv4TimeHow = exports.formatNfsv4FType = exports.formatNfsv4Attr = exports.formatNfsv4Op = exports.formatNfsv4Stat = void 0;
const tslib_1 = require("tslib");
const msg = tslib_1.__importStar(require("./messages"));
const attributes_1 = require("./attributes");
const printTree_1 = require("tree-dump/lib/printTree");
const formatNfsv4Stat = (stat) => {
switch (stat) {
case 0:
return 'NFS4_OK';
case 1:
return 'NFS4ERR_PERM';
case 2:
return 'NFS4ERR_NOENT';
case 5:
return 'NFS4ERR_IO';
case 6:
return 'NFS4ERR_NXIO';
case 13:
return 'NFS4ERR_ACCESS';
case 17:
return 'NFS4ERR_EXIST';
case 18:
return 'NFS4ERR_XDEV';
case 20:
return 'NFS4ERR_NOTDIR';
case 21:
return 'NFS4ERR_ISDIR';
case 22:
return 'NFS4ERR_INVAL';
case 27:
return 'NFS4ERR_FBIG';
case 28:
return 'NFS4ERR_NOSPC';
case 30:
return 'NFS4ERR_ROFS';
case 31:
return 'NFS4ERR_MLINK';
case 63:
return 'NFS4ERR_NAMETOOLONG';
case 66:
return 'NFS4ERR_NOTEMPTY';
case 69:
return 'NFS4ERR_DQUOT';
case 70:
return 'NFS4ERR_STALE';
case 10001:
return 'NFS4ERR_BADHANDLE';
case 10003:
return 'NFS4ERR_BAD_COOKIE';
case 10004:
return 'NFS4ERR_NOTSUPP';
case 10005:
return 'NFS4ERR_TOOSMALL';
case 10006:
return 'NFS4ERR_SERVERFAULT';
case 10007:
return 'NFS4ERR_BADTYPE';
case 10008:
return 'NFS4ERR_DELAY';
case 10009:
return 'NFS4ERR_SAME';
case 10010:
return 'NFS4ERR_DENIED';
case 10011:
return 'NFS4ERR_EXPIRED';
case 10012:
return 'NFS4ERR_LOCKED';
case 10013:
return 'NFS4ERR_GRACE';
case 10014:
return 'NFS4ERR_FHEXPIRED';
case 10015:
return 'NFS4ERR_SHARE_DENIED';
case 10016:
return 'NFS4ERR_WRONGSEC';
case 10017:
return 'NFS4ERR_CLID_INUSE';
case 10018:
return 'NFS4ERR_RESOURCE';
case 10019:
return 'NFS4ERR_MOVED';
case 10020:
return 'NFS4ERR_NOFILEHANDLE';
case 10021:
return 'NFS4ERR_MINOR_VERS_MISMATCH';
case 10022:
return 'NFS4ERR_STALE_CLIENTID';
case 10023:
return 'NFS4ERR_STALE_STATEID';
case 10024:
return 'NFS4ERR_OLD_STATEID';
case 10025:
return 'NFS4ERR_BAD_STATEID';
case 10026:
return 'NFS4ERR_BAD_SEQID';
case 10027:
return 'NFS4ERR_NOT_SAME';
case 10028:
return 'NFS4ERR_LOCK_RANGE';
case 10029:
return 'NFS4ERR_SYMLINK';
case 10030:
return 'NFS4ERR_RESTOREFH';
case 10031:
return 'NFS4ERR_LEASE_MOVED';
case 10032:
return 'NFS4ERR_ATTRNOTSUPP';
case 10033:
return 'NFS4ERR_NO_GRACE';
case 10034:
return 'NFS4ERR_RECLAIM_BAD';
case 10035:
return 'NFS4ERR_RECLAIM_CONFLICT';
case 10036:
return 'NFS4ERR_BADXDR';
case 10037:
return 'NFS4ERR_LOCKS_HELD';
case 10038:
return 'NFS4ERR_OPENMODE';
case 10039:
return 'NFS4ERR_BADOWNER';
case 10040:
return 'NFS4ERR_BADCHAR';
case 10041:
return 'NFS4ERR_BADNAME';
case 10042:
return 'NFS4ERR_BAD_RANGE';
case 10043:
return 'NFS4ERR_LOCK_NOTSUPP';
case 10044:
return 'NFS4ERR_OP_ILLEGAL';
case 10045:
return 'NFS4ERR_DEADLOCK';
case 10046:
return 'NFS4ERR_FILE_OPEN';
case 10047:
return 'NFS4ERR_ADMIN_REVOKED';
case 10048:
return 'NFS4ERR_CB_PATH_DOWN';
default:
return `Unknown(${stat})`;
}
};
exports.formatNfsv4Stat = formatNfsv4Stat;
const formatNfsv4Op = (op) => {
switch (op) {
case 3:
return 'ACCESS';
case 4:
return 'CLOSE';
case 5:
return 'COMMIT';
case 6:
return 'CREATE';
case 7:
return 'DELEGPURGE';
case 8:
return 'DELEGRETURN';
case 9:
return 'GETATTR';
case 10:
return 'GETFH';
case 11:
return 'LINK';
case 12:
return 'LOCK';
case 13:
return 'LOCKT';
case 14:
return 'LOCKU';
case 15:
return 'LOOKUP';
case 16:
return 'LOOKUPP';
case 17:
return 'NVERIFY';
case 18:
return 'OPEN';
case 19:
return 'OPENATTR';
case 20:
return 'OPEN_CONFIRM';
case 21:
return 'OPEN_DOWNGRADE';
case 22:
return 'PUTFH';
case 23:
return 'PUTPUBFH';
case 24:
return 'PUTROOTFH';
case 25:
return 'READ';
case 26:
return 'READDIR';
case 27:
return 'READLINK';
case 28:
return 'REMOVE';
case 29:
return 'RENAME';
case 30:
return 'RENEW';
case 31:
return 'RESTOREFH';
case 32:
return 'SAVEFH';
case 33:
return 'SECINFO';
case 34:
return 'SETATTR';
case 35:
return 'SETCLIENTID';
case 36:
return 'SETCLIENTID_CONFIRM';
case 37:
return 'VERIFY';
case 38:
return 'WRITE';
case 39:
return 'RELEASE_LOCKOWNER';
case 10044:
return 'ILLEGAL';
default:
return `Unknown(${op})`;
}
};
exports.formatNfsv4Op = formatNfsv4Op;
const formatNfsv4Attr = (attr) => {
switch (attr) {
case 0:
return 'supported_attrs';
case 1:
return 'type';
case 2:
return 'fh_expire_type';
case 3:
return 'change';
case 4:
return 'size';
case 5:
return 'link_support';
case 6:
return 'symlink_support';
case 7:
return 'named_attr';
case 8:
return 'fsid';
case 9:
return 'unique_handles';
case 10:
return 'lease_time';
case 11:
return 'rdattr_error';
case 12:
return 'acl';
case 13:
return 'aclsupport';
case 14:
return 'archive';
case 15:
return 'can_set_time';
case 16:
return 'case_insensitive';
case 17:
return 'case_preserving';
case 18:
return 'chown_restricted';
case 19:
return 'filehandle';
case 20:
return 'fileid';
case 21:
return 'files_avail';
case 22:
return 'files_free';
case 23:
return 'files_total';
case 24:
return 'fs_locations';
case 25:
return 'hidden';
case 26:
return 'homogeneous';
case 27:
return 'maxfilesize';
case 28:
return 'maxlink';
case 29:
return 'maxname';
case 30:
return 'maxread';
case 31:
return 'maxwrite';
case 32:
return 'mimetype';
case 33:
return 'mode';
case 34:
return 'no_trunc';
case 35:
return 'numlinks';
case 36:
return 'owner';
case 37:
return 'owner_group';
case 38:
return 'quota_avail_hard';
case 39:
return 'quota_avail_soft';
case 40:
return 'quota_used';
case 41:
return 'rawdev';
case 42:
return 'space_avail';
case 43:
return 'space_free';
case 44:
return 'space_total';
case 45:
return 'space_used';
case 46:
return 'system';
case 47:
return 'time_access';
case 48:
return 'time_access_set';
case 49:
return 'time_backup';
case 50:
return 'time_create';
case 51:
return 'time_delta';
case 52:
return 'time_metadata';
case 53:
return 'time_modify';
case 54:
return 'time_modify_set';
case 55:
return 'mounted_on_fileid';
default:
return `Unknown(${attr})`;
}
};
exports.formatNfsv4Attr = formatNfsv4Attr;
const formatNfsv4FType = (ftype) => {
switch (ftype) {
case 1:
return 'NF4REG';
case 2:
return 'NF4DIR';
case 3:
return 'NF4BLK';
case 4:
return 'NF4CHR';
case 5:
return 'NF4LNK';
case 6:
return 'NF4SOCK';
case 7:
return 'NF4FIFO';
case 8:
return 'NF4ATTRDIR';
case 9:
return 'NF4NAMEDATTR';
default:
return `Unknown(${ftype})`;
}
};
exports.formatNfsv4FType = formatNfsv4FType;
const formatNfsv4TimeHow = (how) => {
switch (how) {
case 0:
return 'SET_TO_SERVER_TIME4';
case 1:
return 'SET_TO_CLIENT_TIME4';
default:
return `Unknown(${how})`;
}
};
exports.formatNfsv4TimeHow = formatNfsv4TimeHow;
const formatNfsv4StableHow = (stable) => {
switch (stable) {
case 0:
return 'UNSTABLE4';
case 1:
return 'DATA_SYNC4';
case 2:
return 'FILE_SYNC4';
default:
return `Unknown(${stable})`;
}
};
exports.formatNfsv4StableHow = formatNfsv4StableHow;
const formatNfsv4CreateMode = (mode) => {
switch (mode) {
case 0:
return 'UNCHECKED4';
case 1:
return 'GUARDED4';
case 2:
return 'EXCLUSIVE4';
default:
return `Unknown(${mode})`;
}
};
exports.formatNfsv4CreateMode = formatNfsv4CreateMode;
const formatNfsv4OpenFlags = (flags) => {
switch (flags) {
case 0:
return 'OPEN4_NOCREATE';
case 1:
return 'OPEN4_CREATE';
default:
return `Unknown(${flags})`;
}
};
exports.formatNfsv4OpenFlags = formatNfsv4OpenFlags;
const formatNfsv4OpenAccess = (access) => {
switch (access) {
case 1:
return 'OPEN4_SHARE_ACCESS_READ';
case 2:
return 'OPEN4_SHARE_ACCESS_WRITE';
case 3:
return 'OPEN4_SHARE_ACCESS_BOTH';
default:
return `Unknown(${access})`;
}
};
exports.formatNfsv4OpenAccess = formatNfsv4OpenAccess;
const formatNfsv4OpenDeny = (deny) => {
switch (deny) {
case 0:
return 'OPEN4_SHARE_DENY_NONE';
case 1:
return 'OPEN4_SHARE_DENY_READ';
case 2:
return 'OPEN4_SHARE_DENY_WRITE';
case 3:
return 'OPEN4_SHARE_DENY_BOTH';
default:
return `Unknown(${deny})`;
}
};
exports.formatNfsv4OpenDeny = formatNfsv4OpenDeny;
const formatNfsv4OpenClaimType = (claim) => {
switch (claim) {
case 0:
return 'CLAIM_NULL';
case 1:
return 'CLAIM_PREVIOUS';
case 2:
return 'CLAIM_DELEGATE_CUR';
case 3:
return 'CLAIM_DELEGATE_PREV';
default:
return `Unknown(${claim})`;
}
};
exports.formatNfsv4OpenClaimType = formatNfsv4OpenClaimType;
const formatNfsv4DelegType = (deleg) => {
switch (deleg) {
case 0:
return 'OPEN_DELEGATE_NONE';
case 1:
return 'OPEN_DELEGATE_READ';
case 2:
return 'OPEN_DELEGATE_WRITE';
default:
return `Unknown(${deleg})`;
}
};
exports.formatNfsv4DelegType = formatNfsv4DelegType;
const formatNfsv4LockType = (locktype) => {
switch (locktype) {
case 1:
return 'READ_LT';
case 2:
return 'WRITE_LT';
case 3:
return 'READW_LT';
case 4:
return 'WRITEW_LT';
default:
return `Unknown(${locktype})`;
}
};
exports.formatNfsv4LockType = formatNfsv4LockType;
const formatNfsv4Access = (access) => {
const flags = [];
if (access & 1)
flags.push('READ');
if (access & 2)
flags.push('LOOKUP');
if (access & 4)
flags.push('MODIFY');
if (access & 8)
flags.push('EXTEND');
if (access & 16)
flags.push('DELETE');
if (access & 32)
flags.push('EXECUTE');
return flags.length > 0 ? flags.join('|') : `0x${access.toString(16)}`;
};
exports.formatNfsv4Access = formatNfsv4Access;
const formatNfsv4Mode = (mode) => {
const flags = [];
if (mode & 2048)
flags.push('SUID');
if (mode & 1024)
flags.push('SGID');
if (mode & 512)
flags.push('SVTX');
if (mode & 256)
flags.push('RUSR');
if (mode & 128)
flags.push('WUSR');
if (mode & 64)
flags.push('XUSR');
if (mode & 32)
flags.push('RGRP');
if (mode & 16)
flags.push('WGRP');
if (mode & 8)
flags.push('XGRP');
if (mode & 4)
flags.push('ROTH');
if (mode & 2)
flags.push('WOTH');
if (mode & 1)
flags.push('XOTH');
const octal = mode.toString(8).padStart(4, '0');
return flags.length > 0 ? `${octal} (${flags.join('|')})` : octal;
};
exports.formatNfsv4Mode = formatNfsv4Mode;
const formatNfsv4Bitmap = (bitmap) => {
const attrs = [];
const attrNums = (0, attributes_1.parseBitmask)(bitmap.mask);
for (const num of attrNums)
attrs.push((0, exports.formatNfsv4Attr)(num));
return attrs.length > 0 ? `[${attrs.join(', ')}]` : '[]';
};
exports.formatNfsv4Bitmap = formatNfsv4Bitmap;
const formatBytes = (data, maxLen = 32) => {
if (data.length === 0)
return '[]';
const hex = Array.from(data.slice(0, maxLen), (b) => b.toString(16).padStart(2, '0')).join(' ');
return data.length > maxLen ? `[${hex}... (${data.length} bytes)]` : `[${hex}]`;
};
const formatStateid = (stateid, tab = '') => {
return `Stateid { seqid = ${stateid.seqid}, other = ${formatBytes(stateid.other)} }`;
};
const formatFileHandle = (fh) => {
return formatBytes(fh.data, 16);
};
const formatNfsv4Request = (req, tab = '') => {
if (req instanceof msg.Nfsv4AccessRequest) {
return `ACCESS access = ${(0, exports.formatNfsv4Access)(req.access)}`;
}
else if (req instanceof msg.Nfsv4CloseRequest) {
return `CLOSE seqid = ${req.seqid}, stateid = ${formatStateid(req.openStateid, tab)}`;
}
else if (req instanceof msg.Nfsv4CommitRequest) {
return `COMMIT offset = ${req.offset}, count = ${req.count}`;
}
else if (req instanceof msg.Nfsv4CreateRequest) {
return `CREATE objtype = ${(0, exports.formatNfsv4FType)(req.objtype.type)}, objname = "${req.objname}"`;
}
else if (req instanceof msg.Nfsv4DelegpurgeRequest) {
return `DELEGPURGE clientid = ${req.clientid}`;
}
else if (req instanceof msg.Nfsv4DelegreturnRequest) {
return `DELEGRETURN stateid = ${formatStateid(req.delegStateid, tab)}`;
}
else if (req instanceof msg.Nfsv4GetattrRequest) {
return `GETATTR attrs = ${(0, exports.formatNfsv4Bitmap)(req.attrRequest)}`;
}
else if (req instanceof msg.Nfsv4GetfhRequest) {
return 'GETFH';
}
else if (req instanceof msg.Nfsv4LinkRequest) {
return `LINK newname = "${req.newname}"`;
}
else if (req instanceof msg.Nfsv4LockRequest) {
return `LOCK locktype = ${(0, exports.formatNfsv4LockType)(req.locktype)}, reclaim = ${req.reclaim}, offset = ${req.offset}, length = ${req.length}`;
}
else if (req instanceof msg.Nfsv4LocktRequest) {
return `LOCKT locktype = ${(0, exports.formatNfsv4LockType)(req.locktype)}, offset = ${req.offset}, length = ${req.length}`;
}
else if (req instanceof msg.Nfsv4LockuRequest) {
return `LOCKU locktype = ${(0, exports.formatNfsv4LockType)(req.locktype)}, seqid = ${req.seqid}, stateid = ${formatStateid(req.lockStateid, tab)}, offset = ${req.offset}, length = ${req.length}`;
}
else if (req instanceof msg.Nfsv4LookupRequest) {
return `LOOKUP objname = "${req.objname}"`;
}
else if (req instanceof msg.Nfsv4LookuppRequest) {
return 'LOOKUPP';
}
else if (req instanceof msg.Nfsv4NverifyRequest) {
return `NVERIFY attrs = ${(0, exports.formatNfsv4Bitmap)(req.objAttributes.attrmask)}`;
}
else if (req instanceof msg.Nfsv4OpenRequest) {
const createInfo = req.openhow.how ? `, createmode = ${(0, exports.formatNfsv4CreateMode)(req.openhow.how.mode)}` : '';
return `OPEN seqid = ${req.seqid}, shareAccess = ${(0, exports.formatNfsv4OpenAccess)(req.shareAccess)}, shareDeny = ${(0, exports.formatNfsv4OpenDeny)(req.shareDeny)}, opentype = ${(0, exports.formatNfsv4OpenFlags)(req.openhow.opentype)}${createInfo}, claim = ${(0, exports.formatNfsv4OpenClaimType)(req.claim.claimType)}`;
}
else if (req instanceof msg.Nfsv4OpenattrRequest) {
return `OPENATTR createdir = ${req.createdir}`;
}
else if (req instanceof msg.Nfsv4OpenConfirmRequest) {
return `OPEN_CONFIRM stateid = ${formatStateid(req.openStateid, tab)}, seqid = ${req.seqid}`;
}
else if (req instanceof msg.Nfsv4OpenDowngradeRequest) {
return `OPEN_DOWNGRADE stateid = ${formatStateid(req.openStateid, tab)}, seqid = ${req.seqid}, shareAccess = ${(0, exports.formatNfsv4OpenAccess)(req.shareAccess)}, shareDeny = ${(0, exports.formatNfsv4OpenDeny)(req.shareDeny)}`;
}
else if (req instanceof msg.Nfsv4PutfhRequest) {
return `PUTFH fh = ${formatFileHandle(req.object)}`;
}
else if (req instanceof msg.Nfsv4PutpubfhRequest) {
return 'PUTPUBFH';
}
else if (req instanceof msg.Nfsv4PutrootfhRequest) {
return 'PUTROOTFH';
}
else if (req instanceof msg.Nfsv4ReadRequest) {
return `READ stateid = ${formatStateid(req.stateid, tab)}, offset = ${req.offset}, count = ${req.count}`;
}
else if (req instanceof msg.Nfsv4ReaddirRequest) {
return `READDIR cookie = ${req.cookie}, dircount = ${req.dircount}, maxcount = ${req.maxcount}, attrs = ${(0, exports.formatNfsv4Bitmap)(req.attrRequest)}`;
}
else if (req instanceof msg.Nfsv4ReadlinkRequest) {
return 'READLINK';
}
else if (req instanceof msg.Nfsv4RemoveRequest) {
return `REMOVE target = "${req.target}"`;
}
else if (req instanceof msg.Nfsv4RenameRequest) {
return `RENAME oldname = "${req.oldname}", newname = "${req.newname}"`;
}
else if (req instanceof msg.Nfsv4RenewRequest) {
return `RENEW clientid = ${req.clientid}`;
}
else if (req instanceof msg.Nfsv4RestorefhRequest) {
return 'RESTOREFH';
}
else if (req instanceof msg.Nfsv4SavefhRequest) {
return 'SAVEFH';
}
else if (req instanceof msg.Nfsv4SecinfoRequest) {
return `SECINFO name = "${req.name}"`;
}
else if (req instanceof msg.Nfsv4SetattrRequest) {
return `SETATTR stateid = ${formatStateid(req.stateid, tab)}, attrs = ${(0, exports.formatNfsv4Bitmap)(req.objAttributes.attrmask)}`;
}
else if (req instanceof msg.Nfsv4SetclientidRequest) {
return `SETCLIENTID callbackIdent = ${req.callbackIdent}`;
}
else if (req instanceof msg.Nfsv4SetclientidConfirmRequest) {
return `SETCLIENTID_CONFIRM clientid = ${req.clientid}`;
}
else if (req instanceof msg.Nfsv4VerifyRequest) {
return `VERIFY attrs = ${(0, exports.formatNfsv4Bitmap)(req.objAttributes.attrmask)}`;
}
else if (req instanceof msg.Nfsv4WriteRequest) {
return `WRITE stateid = ${formatStateid(req.stateid, tab)}, offset = ${req.offset}, stable = ${(0, exports.formatNfsv4StableHow)(req.stable)}, length = ${req.data.length}`;
}
else if (req instanceof msg.Nfsv4ReleaseLockOwnerRequest) {
return 'RELEASE_LOCKOWNER';
}
else if (req instanceof msg.Nfsv4IllegalRequest) {
return 'ILLEGAL';
}
return 'Unknown Request';
};
exports.formatNfsv4Request = formatNfsv4Request;
const formatNfsv4Response = (res, tab = '') => {
if (res instanceof msg.Nfsv4AccessResponse) {
if (res.status === 0 && res.resok) {
return `ACCESS (${(0, exports.formatNfsv4Stat)(res.status)}) supported = ${(0, exports.formatNfsv4Access)(res.resok.supported)}, access = ${(0, exports.formatNfsv4Access)(res.resok.access)}`;
}
return `ACCESS (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4CloseResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `stateid = ${formatStateid(res.resok.openStateid, tab)}`);
}
return `CLOSE (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4CommitResponse) {
return `COMMIT (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4CreateResponse) {
return `CREATE (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4DelegpurgeResponse) {
return `DELEGPURGE (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4DelegreturnResponse) {
return `DELEGRETURN (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4GetattrResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `attrs = ${(0, exports.formatNfsv4Bitmap)(res.resok.objAttributes.attrmask)}`);
}
return `GETATTR (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4GetfhResponse) {
if (res.status === 0 && res.resok) {
return `GETFH (${(0, exports.formatNfsv4Stat)(res.status)}) fh = ${formatFileHandle(res.resok.object)}`;
}
return `GETFH (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4LinkResponse) {
return `LINK (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4LockResponse) {
if (res.status === 0 && res.resok) {
return `LOCK (${(0, exports.formatNfsv4Stat)(res.status)}) stateid = ${formatStateid(res.resok.lockStateid, tab)}`;
}
return `LOCK (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4LocktResponse) {
return `LOCKT (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4LockuResponse) {
if (res.status === 0 && res.resok) {
return `LOCKU (${(0, exports.formatNfsv4Stat)(res.status)}) stateid = ${formatStateid(res.resok.lockStateid, tab)}`;
}
return `LOCKU (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4LookupResponse) {
return `LOOKUP (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4LookuppResponse) {
return `LOOKUPP (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4NverifyResponse) {
return `NVERIFY (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4OpenResponse) {
if (res.status === 0 && res.resok) {
return `OPEN (${(0, exports.formatNfsv4Stat)(res.status)}) stateid = ${formatStateid(res.resok.stateid, tab)}`;
}
return `OPEN (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4OpenattrResponse) {
return `OPENATTR (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4OpenConfirmResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `stateid = ${formatStateid(res.resok.openStateid, tab)}`);
}
return `OPEN_CONFIRM (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4OpenDowngradeResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `stateid = ${formatStateid(res.resok.openStateid, tab)}`);
}
return `OPEN_DOWNGRADE (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4PutfhResponse) {
return `PUTFH (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4PutpubfhResponse) {
return `PUTPUBFH (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4PutrootfhResponse) {
return `PUTROOTFH (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4ReadResponse) {
if (res.status === 0 && res.resok) {
return `READ (${(0, exports.formatNfsv4Stat)(res.status)}) eof = ${res.resok.eof}, length = ${res.resok.data.length}`;
}
return `READ (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4ReaddirResponse) {
return `READDIR (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4ReadlinkResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `link = "${res.resok.link}"`);
}
return `READLINK (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4RemoveResponse) {
return `REMOVE (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4RenameResponse) {
return `RENAME (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4RenewResponse) {
return `RENEW (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4RestorefhResponse) {
return `RESTOREFH (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4SavefhResponse) {
return `SAVEFH (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4SecinfoResponse) {
return `SECINFO (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4SetattrResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `attrsset = ${(0, exports.formatNfsv4Bitmap)(res.resok.attrsset)}`);
}
return `SETATTR (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4SetclientidResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `clientid = ${res.resok.clientid}`);
}
return `SETCLIENTID (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4SetclientidConfirmResponse) {
return `SETCLIENTID_CONFIRM (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4VerifyResponse) {
return `VERIFY (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4WriteResponse) {
const items = [];
if (res.status === 0 && res.resok) {
items.push((tab) => `count = ${res.resok.count}`);
items.push((tab) => `committed = ${(0, exports.formatNfsv4StableHow)(res.resok.committed)}`);
}
return `WRITE (${(0, exports.formatNfsv4Stat)(res.status)})` + (0, printTree_1.printTree)(tab, items);
}
else if (res instanceof msg.Nfsv4ReleaseLockOwnerResponse) {
return `RELEASE_LOCKOWNER (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
else if (res instanceof msg.Nfsv4IllegalResponse) {
return `ILLEGAL (${(0, exports.formatNfsv4Stat)(res.status)})`;
}
return 'Unknown Response';
};
exports.formatNfsv4Response = formatNfsv4Response;
const formatNfsv4CompoundRequest = (req, tab = '') => {
const items = [
(tab) => `tag = "${req.tag}"`,
(tab) => `minorversion = ${req.minorversion}`,
];
req.argarray.forEach((op, i) => {
items.push((tab) => `[${i}] ${(0, exports.formatNfsv4Request)(op, tab)}`);
});
return 'COMPOUND' + (0, printTree_1.printTree)(tab, items);
};
exports.formatNfsv4CompoundRequest = formatNfsv4CompoundRequest;
const formatNfsv4CompoundResponse = (res, tab = '') => {
const items = [
(tab) => `status = ${(0, exports.formatNfsv4Stat)(res.status)}`,
(tab) => `tag = "${res.tag}"`,
];
res.resarray.forEach((op, i) => {
items.push((tab) => `[${i}] ${(0, exports.formatNfsv4Response)(op, tab)}`);
});
return 'COMPOUND' + (0, printTree_1.printTree)(tab, items);
};
exports.formatNfsv4CompoundResponse = formatNfsv4CompoundResponse;
//# sourceMappingURL=format.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
export * from './constants';
export * from './structs';
export * from './messages';
export * from './builder';
export * from './Nfsv4Decoder';
export * from './Nfsv4Encoder';
export * from './Nfsv4FullEncoder';
export * from './format';

Some files were not shown because too many files have changed in this diff Show More