dev: Implement basic devctl
This commit is contained in:
+10
-3
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user