Blame view

kernel/configs.c 2.02 KB
2b089bf8d   Thomas Huth   kernel/configs: R...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
  /*
   * kernel/configs.c
   * Echo the kernel .config file used to build the kernel
   *
   * Copyright (C) 2002 Khalid Aziz <khalid_aziz@hp.com>
f4b09ebc8   Adrian Bunk   update the email ...
7
   * Copyright (C) 2002 Randy Dunlap <rdunlap@xenotime.net>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
   * Copyright (C) 2002 Al Stone <ahs3@fc.hp.com>
   * Copyright (C) 2002 Hewlett-Packard Company
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
12
13
14
15
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
  #include <linux/init.h>
7c0f6ba68   Linus Torvalds   Replace <asm/uacc...
16
  #include <linux/uaccess.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
  /*
13610aa90   Masahiro Yamada   kernel/configs: u...
19
20
   * "IKCFG_ST" and "IKCFG_ED" are used to extract the config data from
   * a binary kernel image or a module. See scripts/extract-ikconfig.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
   */
13610aa90   Masahiro Yamada   kernel/configs: u...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  asm (
  "	.pushsection .rodata, \"a\"		
  "
  "	.ascii \"IKCFG_ST\"			
  "
  "	.global kernel_config_data		
  "
  "kernel_config_data:				
  "
  "	.incbin \"kernel/config_data.gz\"	
  "
  "	.global kernel_config_data_end		
  "
  "kernel_config_data_end:			
  "
  "	.ascii \"IKCFG_ED\"			
  "
  "	.popsection				
  "
  );
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42
43
  
  #ifdef CONFIG_IKCONFIG_PROC
13610aa90   Masahiro Yamada   kernel/configs: u...
44
45
  extern char kernel_config_data;
  extern char kernel_config_data_end;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
49
  static ssize_t
  ikconfig_read_current(struct file *file, char __user *buf,
  		      size_t len, loff_t * offset)
  {
85badbdf5   Akinobu Mita   use simple_read_f...
50
  	return simple_read_from_buffer(buf, len, offset,
13610aa90   Masahiro Yamada   kernel/configs: u...
51
52
53
  				       &kernel_config_data,
  				       &kernel_config_data_end -
  				       &kernel_config_data);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
  }
15ad7cdcf   Helge Deller   [PATCH] struct se...
55
  static const struct file_operations ikconfig_file_ops = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
57
  	.owner = THIS_MODULE,
  	.read = ikconfig_read_current,
6038f373a   Arnd Bergmann   llseek: automatic...
58
  	.llseek = default_llseek,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60
61
62
63
64
  static int __init ikconfig_init(void)
  {
  	struct proc_dir_entry *entry;
  
  	/* create the current config file */
c33fff0af   Denis V. Lunev   kernel: use non-r...
65
66
  	entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
  			    &ikconfig_file_ops);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
68
  	if (!entry)
  		return -ENOMEM;
13610aa90   Masahiro Yamada   kernel/configs: u...
69
  	proc_set_size(entry, &kernel_config_data_end - &kernel_config_data);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
71
72
  
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
74
  static void __exit ikconfig_cleanup(void)
  {
c74c120a2   Alexey Dobriyan   proc: remove proc...
75
  	remove_proc_entry("config.gz", NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76
77
78
79
  }
  
  module_init(ikconfig_init);
  module_exit(ikconfig_cleanup);
626a03125   Stephen Boyd   kernel/configs.c:...
80
  #endif /* CONFIG_IKCONFIG_PROC */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
82
83
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Randy Dunlap");
  MODULE_DESCRIPTION("Echo the kernel .config file used to build the kernel");