|
| 1 | +import {Nfsv4Stat} from '../constants'; |
| 2 | +import {Nfsv4OperationCtx, Nfsv4Operations} from './Nfsv4Operations'; |
| 3 | +import * as msg from '../messages'; |
| 4 | +import * as struct from '../structs'; |
| 5 | + |
| 6 | +export interface Nfsv4OperationsNodeOpts { |
| 7 | + /** Node.js `fs` module. */ |
| 8 | + fs: typeof import('node:fs'); |
| 9 | + /** Absolute path to the root directory to serve. */ |
| 10 | + dir: string; |
| 11 | +} |
| 12 | + |
| 13 | +/** |
| 14 | + * NFS v4 Operations implementation for Node.js `fs` filesystem. |
| 15 | + */ |
| 16 | +export class Nfsv4OperationsNode implements Nfsv4Operations { |
| 17 | + protected fs: typeof import('node:fs'); |
| 18 | + protected dir: string; |
| 19 | + |
| 20 | + constructor (opts: Nfsv4OperationsNodeOpts) { |
| 21 | + this.fs = opts.fs; |
| 22 | + this.dir = opts.dir; |
| 23 | + } |
| 24 | + |
| 25 | + public async ACCESS(request: msg.Nfsv4AccessRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4AccessResponse> { |
| 26 | + ctx.connection.logger.log('ACCESS', request); |
| 27 | + throw new Error('Not implemented'); |
| 28 | + } |
| 29 | + public async CLOSE(request: msg.Nfsv4CloseRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4CloseResponse> { |
| 30 | + ctx.connection.logger.log('CLOSE', request); |
| 31 | + throw new Error('Not implemented'); |
| 32 | + } |
| 33 | + public async COMMIT(request: msg.Nfsv4CommitRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4CommitResponse> { |
| 34 | + ctx.connection.logger.log('COMMIT', request); |
| 35 | + throw new Error('Not implemented'); |
| 36 | + } |
| 37 | + public async CREATE(request: msg.Nfsv4CreateRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4CreateResponse> { |
| 38 | + ctx.connection.logger.log('CREATE', request); |
| 39 | + throw new Error('Not implemented'); |
| 40 | + } |
| 41 | + public async DELEGPURGE(request: msg.Nfsv4DelegpurgeRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4DelegpurgeResponse> { |
| 42 | + ctx.connection.logger.log('DELEGPURGE', request); |
| 43 | + throw new Error('Not implemented'); |
| 44 | + } |
| 45 | + public async DELEGRETURN(request: msg.Nfsv4DelegreturnRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4DelegreturnResponse> { |
| 46 | + ctx.connection.logger.log('DELEGRETURN', request); |
| 47 | + throw new Error('Not implemented'); |
| 48 | + } |
| 49 | + public async GETATTR(request: msg.Nfsv4GetattrRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4GetattrResponse> { |
| 50 | + ctx.connection.logger.log('GETATTR', request); |
| 51 | + throw new Error('Not implemented'); |
| 52 | + } |
| 53 | + public async GETFH(request: msg.Nfsv4GetfhRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4GetfhResponse> { |
| 54 | + ctx.connection.logger.log('GETFH', request); |
| 55 | + throw new Error('Not implemented'); |
| 56 | + } |
| 57 | + public async LINK(request: msg.Nfsv4LinkRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4LinkResponse> { |
| 58 | + ctx.connection.logger.log('LINK', request); |
| 59 | + throw new Error('Not implemented'); |
| 60 | + } |
| 61 | + public async LOCK(request: msg.Nfsv4LockRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4LockResponse> { |
| 62 | + ctx.connection.logger.log('LOCK', request); |
| 63 | + throw new Error('Not implemented'); |
| 64 | + } |
| 65 | + public async LOCKT(request: msg.Nfsv4LocktRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4LocktResponse> { |
| 66 | + ctx.connection.logger.log('LOCKT', request); |
| 67 | + throw new Error('Not implemented'); |
| 68 | + } |
| 69 | + public async LOCKU(request: msg.Nfsv4LockuRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4LockuResponse> { |
| 70 | + ctx.connection.logger.log('LOCKU', request); |
| 71 | + throw new Error('Not implemented'); |
| 72 | + } |
| 73 | + public async LOOKUP(request: msg.Nfsv4LookupRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4LookupResponse> { |
| 74 | + ctx.connection.logger.log('LOOKUP', request); |
| 75 | + throw new Error('Not implemented'); |
| 76 | + } |
| 77 | + public async LOOKUPP(request: msg.Nfsv4LookuppRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4LookuppResponse> { |
| 78 | + ctx.connection.logger.log('LOOKUPP', request); |
| 79 | + throw new Error('Not implemented'); |
| 80 | + } |
| 81 | + public async NVERIFY(request: msg.Nfsv4NverifyRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4NverifyResponse> { |
| 82 | + ctx.connection.logger.log('NVERIFY', request); |
| 83 | + throw new Error('Not implemented'); |
| 84 | + } |
| 85 | + public async OPEN(request: msg.Nfsv4OpenRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4OpenResponse> { |
| 86 | + ctx.connection.logger.log('OPEN', request); |
| 87 | + throw new Error('Not implemented'); |
| 88 | + } |
| 89 | + public async OPENATTR(request: msg.Nfsv4OpenattrRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4OpenattrResponse> { |
| 90 | + ctx.connection.logger.log('OPENATTR', request); |
| 91 | + throw new Error('Not implemented'); |
| 92 | + } |
| 93 | + public async OPEN_CONFIRM(request: msg.Nfsv4OpenConfirmRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4OpenConfirmResponse> { |
| 94 | + ctx.connection.logger.log('OPEN_CONFIRM', request); |
| 95 | + throw new Error('Not implemented'); |
| 96 | + } |
| 97 | + public async OPEN_DOWNGRADE(request: msg.Nfsv4OpenDowngradeRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4OpenDowngradeResponse> { |
| 98 | + ctx.connection.logger.log('OPEN_DOWNGRADE', request); |
| 99 | + throw new Error('Not implemented'); |
| 100 | + } |
| 101 | + public async PUTFH(request: msg.Nfsv4PutfhRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4PutfhResponse> { |
| 102 | + ctx.connection.logger.log('PUTFH', request); |
| 103 | + throw new Error('Not implemented'); |
| 104 | + } |
| 105 | + public async PUTPUBFH(request: msg.Nfsv4PutpubfhRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4PutpubfhResponse> { |
| 106 | + ctx.connection.logger.log('PUTPUBFH', request); |
| 107 | + throw new Error('Not implemented'); |
| 108 | + } |
| 109 | + public async PUTROOTFH(request: msg.Nfsv4PutrootfhRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4PutrootfhResponse> { |
| 110 | + ctx.connection.logger.log('PUTROOTFH', request); |
| 111 | + throw new Error('Not implemented'); |
| 112 | + } |
| 113 | + public async READ(request: msg.Nfsv4ReadRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4ReadResponse> { |
| 114 | + ctx.connection.logger.log('READ', request); |
| 115 | + throw new Error('Not implemented'); |
| 116 | + } |
| 117 | + public async READDIR(request: msg.Nfsv4ReaddirRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4ReaddirResponse> { |
| 118 | + ctx.connection.logger.log('READDIR', request); |
| 119 | + throw new Error('Not implemented'); |
| 120 | + } |
| 121 | + public async READLINK(request: msg.Nfsv4ReadlinkRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4ReadlinkResponse> { |
| 122 | + ctx.connection.logger.log('READLINK', request); |
| 123 | + throw new Error('Not implemented'); |
| 124 | + } |
| 125 | + public async REMOVE(request: msg.Nfsv4RemoveRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4RemoveResponse> { |
| 126 | + ctx.connection.logger.log('REMOVE', request); |
| 127 | + throw new Error('Not implemented'); |
| 128 | + } |
| 129 | + public async RENAME(request: msg.Nfsv4RenameRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4RenameResponse> { |
| 130 | + ctx.connection.logger.log('RENAME', request); |
| 131 | + throw new Error('Not implemented'); |
| 132 | + } |
| 133 | + public async RENEW(request: msg.Nfsv4RenewRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4RenewResponse> { |
| 134 | + ctx.connection.logger.log('RENEW', request); |
| 135 | + throw new Error('Not implemented'); |
| 136 | + } |
| 137 | + public async RESTOREFH(request: msg.Nfsv4RestorefhRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4RestorefhResponse> { |
| 138 | + ctx.connection.logger.log('RESTOREFH', request); |
| 139 | + throw new Error('Not implemented'); |
| 140 | + } |
| 141 | + public async SAVEFH(request: msg.Nfsv4SavefhRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4SavefhResponse> { |
| 142 | + ctx.connection.logger.log('SAVEFH', request); |
| 143 | + throw new Error('Not implemented'); |
| 144 | + } |
| 145 | + public async SECINFO(request: msg.Nfsv4SecinfoRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4SecinfoResponse> { |
| 146 | + ctx.connection.logger.log('SECINFO', request); |
| 147 | + throw new Error('Not implemented'); |
| 148 | + } |
| 149 | + public async SETATTR(request: msg.Nfsv4SetattrRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4SetattrResponse> { |
| 150 | + ctx.connection.logger.log('SETATTR', request); |
| 151 | + throw new Error('Not implemented'); |
| 152 | + } |
| 153 | + public async SETCLIENTID(request: msg.Nfsv4SetclientidRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4SetclientidResponse> { |
| 154 | + const verifier = new struct.Nfsv4Verifier(new Uint8Array([1,2,3,4])); |
| 155 | + const body = new msg.Nfsv4SetclientidResOk(123n, verifier); |
| 156 | + const response = new msg.Nfsv4SetclientidResponse(Nfsv4Stat.NFS4_OK, body); |
| 157 | + return response; |
| 158 | + } |
| 159 | + public async SETCLIENTID_CONFIRM(request: msg.Nfsv4SetclientidConfirmRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4SetclientidConfirmResponse> { |
| 160 | + ctx.connection.logger.log('SETCLIENTID_CONFIRM', request); |
| 161 | + throw new Error('Not implemented'); |
| 162 | + } |
| 163 | + public async VERIFY(request: msg.Nfsv4VerifyRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4VerifyResponse> { |
| 164 | + ctx.connection.logger.log('VERIFY', request); |
| 165 | + throw new Error('Not implemented'); |
| 166 | + } |
| 167 | + public async WRITE(request: msg.Nfsv4WriteRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4WriteResponse> { |
| 168 | + ctx.connection.logger.log('WRITE', request); |
| 169 | + throw new Error('Not implemented'); |
| 170 | + } |
| 171 | + public async RELEASE_LOCKOWNER(request: msg.Nfsv4ReleaseLockOwnerRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4ReleaseLockOwnerResponse> { |
| 172 | + ctx.connection.logger.log('RELEASE_LOCKOWNER', request); |
| 173 | + throw new Error('Not implemented'); |
| 174 | + } |
| 175 | + public async ILLEGAL(request: msg.Nfsv4IllegalRequest, ctx: Nfsv4OperationCtx): Promise<msg.Nfsv4IllegalResponse> { |
| 176 | + ctx.connection.logger.log('ILLEGAL', request); |
| 177 | + throw new Error('Not implemented'); |
| 178 | + } |
| 179 | +} |
0 commit comments