Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error #2

Open
Aniark opened this issue Oct 22, 2022 · 1 comment
Open

Build error #2

Aniark opened this issue Oct 22, 2022 · 1 comment

Comments

@Aniark
Copy link

Aniark commented Oct 22, 2022

On Debian 11, kernel version 5.10.92

  CC [M]  /root/pk3c/proc_version.o
/root/pk3c/proc_version.c: In function ‘ver_create’:
/root/pk3c/proc_version.c:45:54: error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   45 |         ver_file = proc_create(PROCFS_NAME, 0, NULL, &ver_fops);
      |                                                      ^~~~~~~~~
      |                                                      |
      |                                                      const struct file_operations *
In file included from /root/pk3c/proc_version.c:9:
/usr/src/linux-headers-5.10.0-19-common/include/linux/proc_fs.h:109:122: note: expected ‘const struct proc_ops *’ but argument is of type ‘const struct file_operations *’
  109 |  *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
      |                                                      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

@mcr-ksh
Copy link

mcr-ksh commented May 12, 2023

Replace with the following until if (!ver_file) line 64 with:

#include "proc_commonconsts.h"
#include "proc_interface.h"

#include <linux/version.h>
#include <linux/init.h>
#include <linux/kernel.h>

#include <linux/fs.h>           // for basic filesystem
#include <linux/proc_fs.h>      // for the proc filesystem
#include <linux/seq_file.h>     // for sequence files
#include <linux/jiffies.h>      // for jiffies

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0)
//#define HAVE_PROC_CREATE_SINGLE
#define HAVE_PROC_OPS
#endif

static char str_proc_version_name[32];
static char str_proc_version_num[32];
static int active_con_cnt = 0;

static struct proc_dir_entry* ver_file;

static int ver_show(struct seq_file *m, void *v)
{
        seq_printf(m, "%s %s\n%i\n",str_proc_version_name, str_proc_version_num, active_con_cnt);

        return 0;
}

static int ver_open(struct inode *inode, struct file *file)
{
        return single_open(file, ver_show, NULL);
}


#ifdef HAVE_PROC_OPS
static const struct proc_ops ver_fops = {
  .proc_open = ver_open,
  .proc_read = seq_read,
  .proc_lseek = seq_lseek,
  .proc_release = single_release,
};
#else
static const struct file_operations ver_fops =
{
        .owner          = THIS_MODULE,
        .open           = ver_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
        .release        = single_release,
};
#endif

int ver_create(char* vername, char* verstr)
{
        strcpy(str_proc_version_name, vername);
        strcpy(str_proc_version_num, verstr);
#ifdef HAVE_PROC_CREATE_SINGLE
        ver_file = proc_create_single(PROCFS_NAME, 0, NULL, &ver_show);
#else
        ver_file = proc_create(PROCFS_NAME, 0, NULL, &ver_fops);
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants