0

I am working on 32bit to 64bit kernel module porting project. The old kernel version is 2.6.18 and the target is 2.6.32.

The old kernel modules were creating files under /proc/sys/net// path via the following function:

if (create_proc_read_entry("/sys/net/<module_name>/<proc_file_name>", 0, NULL, read_proc, NULL) == NULL){ ...}

I set CONFIG_PROC_FS as "y" in .config file before building 2.6.32 kernel.

However, although proc_fs.h for kernel version 2.6.32 has "create_proc_read_entry" same as kernel version 2.6.18, and "CONFIG_PROC_FS=y" in .config file, the return value is always NULL and it crashes the module when I load it with modprodbe command. If I comment out the subject function call, module is loaded without any problem and it works without any problem.

Did I miss something ? Should I stick with CONFIG_PROC_FS flag ?

Encinaar
  • 149
  • 3
  • 12
  • `create_proc_read_entry` may fail even with procfs enabled. E.g., all path components except last one should exist. Probably, you haven't created directory `/sys/net/` before. (And if you create this dir, it is better to create file under it using relative paths). – Tsyvarev Nov 26 '15 at 07:47
  • The dir that you mentioned is created when I loaded the module. The problem is that, old module was creating necessary proc files without any problem. – Encinaar Nov 26 '15 at 21:34
  • I understand that your problem is porting from one kernel version to newer one. But why also do not make code better? Relative path is shorter and more clear, than using absolute one. BTW, it looks strange for me using path started with `/`: path should be relative in any case, because root directory has name `/proc`. Could you try `create_proc_read_entry("", 0, , read_proc, NULL)` instead? `module_root_entry` is one which module creates before for `/sys/net/` path. – Tsyvarev Nov 26 '15 at 22:47
  • That's the place where you need to do some hacking and put prints in the procfs core module. – stdcall Nov 30 '15 at 05:11

0 Answers0