dev: Implement basic devctl

This commit is contained in:
2026-10-25 19:48:03 +01:00
parent eb86ea3622
commit 95d2096dda
5 changed files with 285 additions and 5 deletions
+10 -3
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: ISC
#include <zinnia/chardev.h>
#include <zinnia/devctl.h>
void chardev_init(
struct chardev* dev,
@@ -55,9 +56,12 @@ errno_t devtmpfs_add_chardev(const char* name, struct chardev* dev, mode_t mode)
struct vfs_path root = devtmpfs_root();
errno_t status = vfs_mknod(root, root, name, mode, &target, ident_kernel(), nullptr);
vfs_path_drop(root);
if (status)
if (status) {
chardev_unref(dev);
return status;
return status;
}
devctl_notify_create(name);
return 0;
}
errno_t devtmpfs_mkdir(const char* name, mode_t mode) {
@@ -71,7 +75,10 @@ errno_t devtmpfs_remove(const char* name) {
struct vfs_path root = devtmpfs_root();
errno_t status = vfs_unlink(root, root, name, ident_kernel());
vfs_path_drop(root);
return status;
if (status)
return status;
devctl_notify_destroy(name);
return 0;
}
errno_t devtmpfs_symlink(const char* name, const char* target) {