c - 我怎样才能更好地理解内核 C 编程代码

标签 c linux-kernel

我正在研究内核架构及其编程以了解有关内核的概念。 我知道 C 编程,但内核代码中提到的结构和指针让我难以理解。如下图

int irq = regs.orig_eax & 0xff;


asmlinkage int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
                                struct irqaction *action)
{



struct super_operations {
        struct inode *(*alloc_inode) (struct super_block *sb);
        void (*destroy_inode) (struct inode *);
        void (*read_inode) (struct inode *);
        void (*dirty_inode) (struct inode *);
        void (*write_inode) (struct inode *, int);
        void (*put_inode) (struct inode *);
        void (*drop_inode) (struct inode *);
        void (*delete_inode) (struct inode *);
        void (*put_super) (struct super_block *);
        void (*write_super) (struct super_block *);
        int (*sync_fs) (struct super_block *, int);
        void (*write_super_lockfs) (struct super_block *);
        void (*unlockfs) (struct super_block *);
        int (*statfs) (struct super_block *, struct statfs *);
        int (*remount_fs) (struct super_block *, int *, char *);
        void (*clear_inode) (struct inode *);
        void (*umount_begin) (struct super_block *);
        int (*show_options) (struct seq_file *, struct vfsmount *);
};

我怎样才能更好地理解代码。任何教授内核代码中的指针和结构的书

最佳答案

除此之外,这是标准的 C 语法,您必须自己在内核代码中查找结构的定义。这并不难,只是一开始很乏味。

这就是说,Linux Kernel Newbies对您来说可能是一个很好的起点。

关于c - 我怎样才能更好地理解内核 C 编程代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3175954/

相关文章:

c - 在C中交换两行二维字符数组

c - “输入”作为输入?

c - 为什么像clone()这样的系统调用会失败、恢复和暂停?

linux-kernel - sysfs 属性可以在 Linux 设备驱动程序中采用非数值吗?

linux - 将 preempt_notifier 附加到 Linux 中的用户进程

c++ - 相当于 gcc/g++ 中的 __declspec( naked )

c - 输出返回为 0.00

c - 我的程序计算的 git 对象的 SHA1 哈希值与 git 中的哈希值不匹配

linux - 如何将多个结构 BIO 组合成一个结构请求?

linux - 如何在其他Linux内核版本上编译ixgbe网络驱动程序