summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-08-18 03:06:14 +0000
committerIan Moffett <ian@osmora.org>2025-08-18 03:06:14 +0000
commit8a64c7d6a3ff2cc0cf87ba47cbbe1c4fe3aa170e (patch)
treea17153a95e28179329d13b342b7219e5b42299a9
parent50013e9da3036dbd8f36a2e1a8bfdc81d707d11f (diff)
kernel: disk: Add DISK_IO_QUERY op to disk engine
This commit introduces the DISK_IO_QUERY opcode to the disk engine so that a user application may query specific devices. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/include/sys/disk.h1
-rw-r--r--sys/kern/disk_engine.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/sys/include/sys/disk.h b/sys/include/sys/disk.h
index a277797..4ad068b 100644
--- a/sys/include/sys/disk.h
+++ b/sys/include/sys/disk.h
@@ -78,6 +78,7 @@ _Static_assert((V_BSIZE & 1) == 0, "V_BSIZE must be a power of two");
/* Valid disk operations */
#define DISK_IO_READ 0x00 /* Read data from the disk */
#define DISK_IO_WRITE 0x01 /* Write data to disk */
+#define DISK_IO_QUERY 0x02 /* Query disk information */
/*
* A disk identifier is a zero-based index into
diff --git a/sys/kern/disk_engine.c b/sys/kern/disk_engine.c
index a49c15f..1061165 100644
--- a/sys/kern/disk_engine.c
+++ b/sys/kern/disk_engine.c
@@ -172,6 +172,18 @@ disk_mux_io(diskid_t id, diskop_t opcode, struct disk_param *u_param)
param.size
);
break;
+ case DISK_IO_QUERY:
+ retval = disk_query(
+ id,
+ param.buf
+ );
+
+ /* Write back info to user program */
+ error = copyout(param.buf, param.u_buf, param.size);
+ if (error < 0) {
+ retval = error;
+ }
+ break;
}
disk_param_free(&param);