Test / test (push) Successful in 2m4s
Release / gates (push) Successful in 2m5s
Release / build (amd64, freebsd) (push) Successful in 1m27s
Release / build (amd64, linux) (push) Successful in 1m22s
Release / build (amd64, netbsd) (push) Successful in 1m19s
Release / build (amd64, openbsd) (push) Successful in 1m20s
Release / build (arm64, darwin) (push) Successful in 1m21s
Release / build (arm64, freebsd) (push) Successful in 1m26s
Release / build (arm64, linux) (push) Successful in 1m25s
Release / build (arm64, netbsd) (push) Successful in 1m31s
Release / build (arm64, openbsd) (push) Successful in 1m27s
Release / build (loong64, linux) (push) Successful in 1m37s
Release / build (riscv64, linux) (push) Successful in 1m21s
Release / release (push) Successful in 40s
Assisted-by: GLM 5.3 Flash
67 lines
3.1 KiB
Go
67 lines
3.1 KiB
Go
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package nfs4server
|
|
|
|
import (
|
|
"log"
|
|
"strconv"
|
|
"time"
|
|
|
|
"sourcedock.dev/petrbalvin/nfs/internal/nfs4"
|
|
)
|
|
|
|
// opNames names the operations the log answers with, keyed by their wire
|
|
// number. An operation outside the table logs as its number.
|
|
var opNames = map[uint32]string{
|
|
nfs4.OpAccess: "ACCESS", nfs4.OpClose: "CLOSE", nfs4.OpCommit: "COMMIT",
|
|
nfs4.OpCreate: "CREATE", nfs4.OpDelegPurge: "DELEGPURGE",
|
|
nfs4.OpDelegReturn: "DELEGRETURN", nfs4.OpGetattr: "GETATTR",
|
|
nfs4.OpGetfh: "GETFH", nfs4.OpLink: "LINK", nfs4.OpLock: "LOCK",
|
|
nfs4.OpLockt: "LOCKT", nfs4.OpLocku: "LOCKU", nfs4.OpLookup: "LOOKUP",
|
|
nfs4.OpLookupp: "LOOKUPP", nfs4.OpNverify: "NVERIFY", nfs4.OpOpen: "OPEN",
|
|
nfs4.OpOpenattr: "OPENATTR", nfs4.OpOpenConfirm: "OPEN_CONFIRM",
|
|
nfs4.OpOpenDowngrade: "OPEN_DOWNGRADE", nfs4.OpPutfh: "PUTFH",
|
|
nfs4.OpPutPubfh: "PUTPUBFH", nfs4.OpPutRootfh: "PUTROOTFH",
|
|
nfs4.OpRead: "READ", nfs4.OpReaddir: "READDIR", nfs4.OpReadlink: "READLINK",
|
|
nfs4.OpRemove: "REMOVE", nfs4.OpRename: "RENAME", nfs4.OpRenew: "RENEW",
|
|
nfs4.OpRestorefh: "RESTOREFH", nfs4.OpSavefh: "SAVEFH",
|
|
nfs4.OpSecinfo: "SECINFO", nfs4.OpSetattr: "SETATTR",
|
|
nfs4.OpSetClientID: "SETCLIENTID", nfs4.OpSetClientIDConfirm: "SETCLIENTID_CONFIRM",
|
|
nfs4.OpVerify: "VERIFY", nfs4.OpWrite: "WRITE",
|
|
nfs4.OpReleaseLockOwner: "RELEASE_LOCKOWNER",
|
|
nfs4.OpBackchannelCtl: "BACKCHANNEL_CTL",
|
|
nfs4.OpBindConnToSession: "BIND_CONN_TO_SESSION",
|
|
nfs4.OpExchangeID: "EXCHANGE_ID", nfs4.OpCreateSession: "CREATE_SESSION",
|
|
nfs4.OpDestroySession: "DESTROY_SESSION", nfs4.OpFreeStateid: "FREE_STATEID",
|
|
nfs4.OpGetDirDelegation: "GET_DIR_DELEGATION",
|
|
nfs4.OpGetDeviceInfo: "GETDEVICEINFO", nfs4.OpGetDeviceList: "GETDEVICELIST",
|
|
nfs4.OpLayoutCommit: "LAYOUTCOMMIT", nfs4.OpLayoutGet: "LAYOUTGET",
|
|
nfs4.OpLayoutReturn: "LAYOUTRETURN", nfs4.OpSecinfoNoName: "SECINFO_NO_NAME",
|
|
nfs4.OpSequence: "SEQUENCE", nfs4.OpSetSsv: "SET_SSV",
|
|
nfs4.OpTestStateid: "TEST_STATEID", nfs4.OpWantDelegation: "WANT_DELEGATION",
|
|
nfs4.OpDestroyClientID: "DESTROY_CLIENTID",
|
|
nfs4.OpReclaimComplete: "RECLAIM_COMPLETE", nfs4.OpAllocate: "ALLOCATE",
|
|
nfs4.OpCopy: "COPY", nfs4.OpCopyNotify: "COPY_NOTIFY",
|
|
nfs4.OpDeallocate: "DEALLOCATE", nfs4.OpIoAdvise: "IO_ADVISE",
|
|
nfs4.OpLayoutError: "LAYOUTERROR", nfs4.OpLayoutStats: "LAYOUTSTATS",
|
|
nfs4.OpOffloadCancel: "OFFLOAD_CANCEL", nfs4.OpOffloadStatus: "OFFLOAD_STATUS",
|
|
nfs4.OpReadPlus: "READ_PLUS", nfs4.OpSeek: "SEEK", nfs4.OpWriteSame: "WRITE_SAME",
|
|
nfs4.OpClone: "CLONE", nfs4.OpGetxattr: "GETXATTR", nfs4.OpSetxattr: "SETXATTR",
|
|
nfs4.OpListxattr: "LISTXATTR", nfs4.OpRemovexattr: "REMOVEXATTR",
|
|
}
|
|
|
|
// opName answers the name of one operation for the log.
|
|
func opName(op uint32) string {
|
|
if name, ok := opNames[op]; ok {
|
|
return name
|
|
}
|
|
return "OP" + strconv.FormatUint(uint64(op), 10)
|
|
}
|
|
|
|
// logOp answers one log line per operation when -log-ops is on: the
|
|
// operation, the status it answered and the time it took, on stderr.
|
|
func logOp(op uint32, status uint32, took time.Duration) {
|
|
log.Printf("nfs: %s status %d %s", opName(op), status, took)
|
|
}
|