1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| // <<<<<<<<<<<<<--- my debug Add by Late Lee 2016.11.15
#define PROC_FILE "lldebug"
#define _BIT(x) (1<<x) #define __DEFINE_LEVEL(name) [name] = {#name, _BIT(name)}
const struct ll_debug__info_t ll_debug_info[D_MAX_LEVEL] = { __DEFINE_LEVEL(D_NETCARD), __DEFINE_LEVEL(D_LINK), __DEFINE_LEVEL(D_IP), __DEFINE_LEVEL(D_ICMP), __DEFINE_LEVEL(D_ARP), __DEFINE_LEVEL(D_UDP), __DEFINE_LEVEL(D_TCP), __DEFINE_LEVEL(D_SOCKET), __DEFINE_LEVEL(D_PACKET), __DEFINE_LEVEL(D_IEEE80211), __DEFINE_LEVEL(D_VERBOSE), };
EXPORT_SYMBOL(ll_debug_info);
static int my_debug_proc_show(struct seq_file *m, void *v) { int i = 0; seq_printf(m, "debug info control.nusage: echo 0xXXX > /proc/%sn", PROC_FILE); seq_printf(m, "current debug level: 0x%08x max debug level type: %dn", g_ll_debug, D_MAX_LEVEL); for (i = 0; i < D_MAX_LEVEL; i++) { seq_printf(m, "bit 0x%02x %sn", ll_debug_info[i].bit, ll_debug_info[i].name); } return 0;
return 0; }
static int my_version_proc_open(struct inode *inode, struct file *file) { return single_open(file, my_debug_proc_show, NULL); }
static ssize_t my_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_ops) { unsigned char buffer[32] = {0}; int value = 0;
if (copy_from_user(buffer, buf, (count > 32 ? 32: count))) goto out;
value = simple_strtol(buffer, NULL, 16); g_ll_debug = value;
out: return count; }
static const struct file_operations my_debug_proc_fops = { .open = my_version_proc_open, .read = seq_read, .write = my_write, .llseek = seq_lseek, .release = single_release, };
struct proc_dir_entry* my_proc_entry = NULL;
void create_debugproc(void) { if (!my_proc_entry) my_proc_entry = proc_create(PROC_FILE, 0, NULL, &my_debug_proc_fops); // 在/proc目录下创建 }
void delete_debugproc(void) { if (my_proc_entry) proc_remove(my_proc_entry); }
// >>>>>>>>>>>>>>>>>>>>>>>>>>> ////////////////////////////////////////////////////
|