diff options
author | Edoardo La Greca | 2025-08-09 21:07:53 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-09 21:07:53 +0200 |
commit | 48922ff78c0b82be4b52c3221cb408ff01951190 (patch) | |
tree | b0e792c60df4bc2790ce2766bf201544b27ddb9d /src/main/kotlin/Connection.kt | |
parent | c69d08ab05a044eb6b6135739de77b0711ebbdd3 (diff) |
implement create
Diffstat (limited to 'src/main/kotlin/Connection.kt')
-rw-r--r-- | src/main/kotlin/Connection.kt | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main/kotlin/Connection.kt b/src/main/kotlin/Connection.kt index 587f5ee..d5330d7 100644 --- a/src/main/kotlin/Connection.kt +++ b/src/main/kotlin/Connection.kt @@ -193,8 +193,28 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { return Pair(qid, iounit) } - override fun create(path: String) { - TODO("Not yet implemented") + override fun create(fid: UInt, name: String, perm: FilePermissions, mode: FileMode): Pair<QID, UInt> { + val omsg = OutMessage(NinePMessageType.TCREATE, this.tagGen.generate(), listOf("fid", "name", "perm", "mode"), + mapOf( + "fid" to Pair(BigInteger(fid.toString()), 4u), + "perm" to Pair(BigInteger(perm.toPermissionInt().toString()), 4u), + "mode" to Pair(BigInteger(mode.toModeByte().toString()), 1u) + ), + mapOf( + "name" to name + ), + emptyMap(), + this.maxSize + ) + omsg.write(this.tl) + val imsg = checkedInMessage(omsg.tag) + imsg.applySchema(listOf( + InMessage.Field("qid", InMessage.Field.Type.RAW, 13u), + InMessage.Field("iounit", InMessage.Field.Type.INTEGER, 4u) + )) + val qid = QID(imsg.fieldsRaw["qid"]!!.toList()) + val iounit = imsg.fieldsInt["iounit"]!!.toInt().toUInt() + return Pair(qid, iounit) } override fun read(fid: UInt, offset: ULong, count: UInt): Array<UByte> { |