-1

I have doubt on writing structure like this. Why here we have to equate some thing to some other thing (.owner = THIS_MODULE)

const struct file_operations nvram_fops = {
        .owner          = THIS_MODULE,
        .llseek         = nvram_llseek,
        .read           = read_nvram,
        .write          = write_nvram,
        .ioctl          = nvram_ioctl,
};

PLease help on this.

R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
Sijith
  • 3,740
  • 17
  • 61
  • 101

1 Answers1

3

This is initialization syntax.

Here, nvram_fops is a structure of type file_operations. Its owner field is set to THIS_MODULE, llseek to nvram_llseek and so on.

If you are trying to understand the code at a higher level, take a look at "The Linux Kernel Module Programming Guide". It explains that

The file_operations structure is defined in linux/fs.h, and holds pointers to functions defined by the driver that perform various operations on the device. Each field of the structure corresponds to the address of some function defined by the driver to handle a requested operation.

NPE
  • 486,780
  • 108
  • 951
  • 1,012