]> git.neil.brown.name Git - history.git/commitdiff
[CRYPTO]: Dont compile procfs stuff if procfs is not enabled.
authorJames Morris <jmorris@intercode.com.au>
Fri, 6 Dec 2002 03:04:03 +0000 (19:04 -0800)
committerJames Morris <jmorris@intercode.com.au>
Fri, 6 Dec 2002 03:04:03 +0000 (19:04 -0800)
crypto/Makefile
crypto/api.c
crypto/internal.h
crypto/proc.c [new file with mode: 0644]

index 13415dce518104a94594c3c3e723adb74d73162b..9bbb7ac45d5633e55e58dc97583d5d8a0039ceb9 100644 (file)
@@ -5,8 +5,10 @@
 export-objs := api.o hmac.o
 
 autoload-crypto-$(CONFIG_KMOD) = autoload.o
+proc-crypto-$(CONFIG_PROC_FS) = proc.o
 
-obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o $(autoload-crypto-y)
+obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o \
+                       $(autoload-crypto-y) $(proc-crypto-y)
 
 obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
index c903f2b39da2ec999be6c1909e2b6b925e2d89f4..f41d1437a4dad553b0849766dc69388b2604b292 100644 (file)
 #include <linux/init.h>
 #include <linux/crypto.h>
 #include <linux/rwsem.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "internal.h"
 
-static LIST_HEAD(crypto_alg_list);
-static DECLARE_RWSEM(crypto_alg_sem);
+LIST_HEAD(crypto_alg_list);
+DECLARE_RWSEM(crypto_alg_sem);
 
 static inline int crypto_alg_get(struct crypto_alg *alg)
 {
@@ -240,89 +239,10 @@ int crypto_alg_available(const char *name, u32 flags)
        return ret;
 }
 
-static void *c_start(struct seq_file *m, loff_t *pos)
-{
-       struct list_head *v;
-       loff_t n = *pos;
-
-       down_read(&crypto_alg_sem);
-       list_for_each(v, &crypto_alg_list)
-               if (!n--)
-                       return list_entry(v, struct crypto_alg, cra_list);
-       return NULL;
-}
-
-static void *c_next(struct seq_file *m, void *p, loff_t *pos)
-{
-       struct list_head *v = p;
-       
-       (*pos)++;
-       v = v->next;
-       return (v == &crypto_alg_list) ?
-               NULL : list_entry(v, struct crypto_alg, cra_list);
-}
-
-static void c_stop(struct seq_file *m, void *p)
-{
-       up_read(&crypto_alg_sem);
-}
-
-static int c_show(struct seq_file *m, void *p)
-{
-       struct crypto_alg *alg = (struct crypto_alg *)p;
-       
-       seq_printf(m, "name         : %s\n", alg->cra_name);
-       seq_printf(m, "module       : %s\n", module_name(alg->cra_module));
-       seq_printf(m, "blocksize    : %u\n", alg->cra_blocksize);
-       
-       switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
-       case CRYPTO_ALG_TYPE_CIPHER:
-               seq_printf(m, "min keysize  : %u\n",
-                                       alg->cra_cipher.cia_min_keysize);
-               seq_printf(m, "max keysize  : %u\n",
-                                       alg->cra_cipher.cia_max_keysize);
-               seq_printf(m, "ivsize       : %u\n",
-                                       alg->cra_cipher.cia_ivsize);
-               break;
-               
-       case CRYPTO_ALG_TYPE_DIGEST:
-               seq_printf(m, "digestsize   : %u\n",
-                          alg->cra_digest.dia_digestsize);
-               break;
-       }
-
-       seq_putc(m, '\n');
-       return 0;
-}
-
-static struct seq_operations crypto_seq_ops = {
-       .start          = c_start,
-       .next           = c_next,
-       .stop           = c_stop,
-       .show           = c_show
-};
-
-static int crypto_info_open(struct inode *inode, struct file *file)
-{
-       return seq_open(file, &crypto_seq_ops);
-}
-        
-struct file_operations proc_crypto_ops = {
-       .open           = crypto_info_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = seq_release
-};
-
 static int __init init_crypto(void)
 {
-       struct proc_dir_entry *proc;
-       
        printk(KERN_INFO "Initializing Cryptographic API\n");
-       proc = create_proc_entry("crypto", 0, NULL);
-       if (proc)
-               proc->proc_fops = &proc_crypto_ops;
-               
+       crypto_init_proc();
        return 0;
 }
 
index 408bc1bb5b0c6a040dab90ed95b19361cf2e2784..35bd91128aeb20efef7e16c04d4240ee7d43aea1 100644 (file)
@@ -11,7 +11,6 @@
  */
 #ifndef _CRYPTO_INTERNAL_H
 #define _CRYPTO_INTERNAL_H
-
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <asm/hardirq.h>
@@ -65,6 +64,13 @@ static inline void crypto_free_hmac_block(struct crypto_tfm *tfm)
 { }
 #endif
 
+#ifdef CONFIG_PROC_FS
+void __init crypto_init_proc(void);
+#else
+static inline void crypto_init_proc(void)
+{ }
+#endif
+
 int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
 int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
 int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
diff --git a/crypto/proc.c b/crypto/proc.c
new file mode 100644 (file)
index 0000000..f51a3cc
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Scatterlist Cryptographic API.
+ *
+ * Procfs information.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) 
+ * any later version.
+ *
+ */
+#include <linux/init.h>
+#include <linux/crypto.h>
+#include <linux/rwsem.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include "internal.h"
+
+extern struct list_head crypto_alg_list;
+extern struct rw_semaphore crypto_alg_sem;
+
+static void *c_start(struct seq_file *m, loff_t *pos)
+{
+       struct list_head *v;
+       loff_t n = *pos;
+
+       down_read(&crypto_alg_sem);
+       list_for_each(v, &crypto_alg_list)
+               if (!n--)
+                       return list_entry(v, struct crypto_alg, cra_list);
+       return NULL;
+}
+
+static void *c_next(struct seq_file *m, void *p, loff_t *pos)
+{
+       struct list_head *v = p;
+       
+       (*pos)++;
+       v = v->next;
+       return (v == &crypto_alg_list) ?
+               NULL : list_entry(v, struct crypto_alg, cra_list);
+}
+
+static void c_stop(struct seq_file *m, void *p)
+{
+       up_read(&crypto_alg_sem);
+}
+
+static int c_show(struct seq_file *m, void *p)
+{
+       struct crypto_alg *alg = (struct crypto_alg *)p;
+       
+       seq_printf(m, "name         : %s\n", alg->cra_name);
+       seq_printf(m, "module       : %s\n", module_name(alg->cra_module));
+       seq_printf(m, "blocksize    : %u\n", alg->cra_blocksize);
+       
+       switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
+       case CRYPTO_ALG_TYPE_CIPHER:
+               seq_printf(m, "min keysize  : %u\n",
+                                       alg->cra_cipher.cia_min_keysize);
+               seq_printf(m, "max keysize  : %u\n",
+                                       alg->cra_cipher.cia_max_keysize);
+               seq_printf(m, "ivsize       : %u\n",
+                                       alg->cra_cipher.cia_ivsize);
+               break;
+               
+       case CRYPTO_ALG_TYPE_DIGEST:
+               seq_printf(m, "digestsize   : %u\n",
+                          alg->cra_digest.dia_digestsize);
+               break;
+       }
+
+       seq_putc(m, '\n');
+       return 0;
+}
+
+static struct seq_operations crypto_seq_ops = {
+       .start          = c_start,
+       .next           = c_next,
+       .stop           = c_stop,
+       .show           = c_show
+};
+
+static int crypto_info_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &crypto_seq_ops);
+}
+        
+static struct file_operations proc_crypto_ops = {
+       .open           = crypto_info_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release
+};
+
+void __init crypto_init_proc(void)
+{
+       struct proc_dir_entry *proc;
+       
+       proc = create_proc_entry("crypto", 0, NULL);
+       if (proc)
+               proc->proc_fops = &proc_crypto_ops;
+}