diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2000-06-14 16:51:56 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2000-06-14 16:51:56 +0000 |
commit | cb991a905a45bb827b43f71bab3833e3b9648f85 (patch) | |
tree | 8adce6d58f1e36b9208a97a2f2df40ccd0f0c6e3 /sys/uvm/uvm_swap_encrypt.c | |
parent | 3bc35fe51227abbf3c8d9e587d1c899d0b0ab712 (diff) |
put in own ctl level for swapencrypt.
Diffstat (limited to 'sys/uvm/uvm_swap_encrypt.c')
-rw-r--r-- | sys/uvm/uvm_swap_encrypt.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sys/uvm/uvm_swap_encrypt.c b/sys/uvm/uvm_swap_encrypt.c index 97fefd244f2..64f50ca6346 100644 --- a/sys/uvm/uvm_swap_encrypt.c +++ b/sys/uvm/uvm_swap_encrypt.c @@ -32,6 +32,7 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/malloc.h> +#include <sys/sysctl.h> #include <sys/time.h> #include <dev/rndvar.h> #include <crypto/rijndael.h> @@ -50,6 +51,48 @@ u_int uvm_swpkeysdeleted = 0; int swap_encrypt_initalized = 0; +int +swap_encrypt_ctl(name, namelen, oldp, oldlenp, newp, newlen, p) + int *name; + u_int namelen; + void *oldp; + size_t *oldlenp; + void *newp; + size_t newlen; + struct proc *p; +{ + /* all sysctl names at this level are terminal */ + if (namelen != 1) + return (ENOTDIR); /* overloaded */ + + switch (name[0]) { + case SWPENC_ENABLE: { + int doencrypt = uvm_doswapencrypt; + int result; + + result = sysctl_int(oldp, oldlenp, newp, newlen, &doencrypt); + if (result) + return result; + + /* Swap Encryption has been turned on, we need to + * initalize state for swap devices that have been + * added + */ + if (doencrypt) + uvm_swap_initcrypt_all(); + uvm_doswapencrypt = doencrypt; + return (0); + } + case SWPENC_CREATED: + return (sysctl_rdint(oldp, oldlenp, newp, uvm_swpkeyscreated)); + case SWPENC_DELETED: + return (sysctl_rdint(oldp, oldlenp, newp, uvm_swpkeysdeleted)); + default: + return (EOPNOTSUPP); + } + /* NOTREACHED */ +} + void swap_key_create(struct swap_key *key) { |