diff --git a/dump_dir/dump_dir.c b/dump_dir/dump_dir.c index 5440cf4..91559d8 100644 --- a/dump_dir/dump_dir.c +++ b/dump_dir/dump_dir.c @@ -14,8 +14,8 @@ } else { while((entry = readdir(dir)) != NULL) - printf("inode = %d filename = %s\n", - (int)entry->d_ino, entry->d_name); + printf("inode = %d filename = %s type=%d \n", + (int)entry->d_ino, entry->d_name, entry->d_type); } closedir(dir); return 0; diff --git a/inotify/show_events.c b/inotify/show_events.c index aeda69b..09a9322 100644 --- a/inotify/show_events.c +++ b/inotify/show_events.c @@ -5,6 +5,7 @@ * 20201130 @miura added #include to prevent warning of implicit declaration of functions: * read / close. */ + #include #include #include diff --git a/lkmpg/hello_proc.c b/lkmpg/hello_proc.c index ff75eec..903dc4d 100644 --- a/lkmpg/hello_proc.c +++ b/lkmpg/hello_proc.c @@ -8,6 +8,12 @@ #include #include #include +#include +#include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#define HAVE_PROCOPS +#endif static int hello_proc_show(struct seq_file *m, void *v) { seq_printf(m, "Hello proc!\n"); @@ -18,13 +24,22 @@ return single_open(file, hello_proc_show, NULL); } -static const struct file_operations hello_proc_fops = { - .owner = THIS_MODULE, - .open = hello_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, +#ifdef HAVE_PROCOPS +static const struct proc_ops hello_proc_fops = { + .proc_open = hello_proc_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = single_release, }; +#else +static const struct file_operations hello_proc_fops = { + .owner = THIS_MODULE, + .open = hello_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +#endif static int __init hello_proc_init(void) { proc_create("hello_proc", 0, NULL, &hello_proc_fops);