From 48922ff78c0b82be4b52c3221cb408ff01951190 Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Sat, 9 Aug 2025 21:07:53 +0200 Subject: implement create --- src/main/kotlin/Connection.kt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin/Connection.kt') 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 { + 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 { -- cgit v1.2.3