summaryrefslogtreecommitdiff
path: root/fs/cachefiles/main.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2021-11-26 15:12:07 +0000
committerDavid Howells <dhowells@redhat.com>2022-01-07 13:41:20 +0000
commit8667d434b2a993b34a9dae6f6673bf93870fac25 (patch)
tree197a555cb4364c72eddbdb4bf5afa37013d0fea6 /fs/cachefiles/main.c
parent254947d47945f2fa02e9b3366594fad2ed127618 (diff)
cachefiles: Register a miscdev and parse commands over it
Register a misc device with which to talk to the daemon. The misc device holds a cache set up through it around and closing the device kills the cache. cachefilesd communicates with the kernel by passing it single-line text commands. Parse these and use them to parameterise the cache state. This does not implement the command to actually bring a cache online. That's left for later. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/163819628388.215744.17712097043607299608.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906929128.143852.14065207858943654011.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967139085.1823006.3514846391807454287.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021538400.640689.9172006906288062041.stgit@warthog.procyon.org.uk/ # v4
Diffstat (limited to 'fs/cachefiles/main.c')
-rw-r--r--fs/cachefiles/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/cachefiles/main.c b/fs/cachefiles/main.c
index 387d42c7185f..533e3067d80f 100644
--- a/fs/cachefiles/main.c
+++ b/fs/cachefiles/main.c
@@ -31,6 +31,12 @@ MODULE_DESCRIPTION("Mounted-filesystem based cache");
MODULE_AUTHOR("Red Hat, Inc.");
MODULE_LICENSE("GPL");
+static struct miscdevice cachefiles_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "cachefiles",
+ .fops = &cachefiles_daemon_fops,
+};
+
/*
* initialise the fs caching module
*/
@@ -41,10 +47,15 @@ static int __init cachefiles_init(void)
ret = cachefiles_register_error_injection();
if (ret < 0)
goto error_einj;
+ ret = misc_register(&cachefiles_dev);
+ if (ret < 0)
+ goto error_dev;
pr_info("Loaded\n");
return 0;
+error_dev:
+ cachefiles_unregister_error_injection();
error_einj:
pr_err("failed to register: %d\n", ret);
return ret;
@@ -59,6 +70,7 @@ static void __exit cachefiles_exit(void)
{
pr_info("Unloading\n");
+ misc_deregister(&cachefiles_dev);
cachefiles_unregister_error_injection();
}