API:LINUX MODULE

구차니의 잡동사니 위키
이동: 둘러보기, 찾기
#define __initcall(fn) static initcall_t __initcall_##fn __init_call = fn
#define module_init(x)  __initcall(x);

#define __exitcall(fn)								\
	static exitcall_t __exitcall_##fn __exit_call = fn
#define module_exit(x)	__exitcall(x);

#define module_param(name, type, perm)                          \
        module_param_named(name, name, type, perm)

#define module_param_named(name, value, type, perm)                        \
        param_check_##type(name, &(value));                                \
        module_param_cb(name, &param_ops_##type, &value, perm);            \
        __MODULE_PARM_TYPE(name, #type)

#define module_param_cb(name, ops, arg, perm)                                 \
        __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0)

#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \
        /* Default value instead of permissions? */                     \
        static const char __param_str_##name[] = prefix #name;          \
        static struct kernel_param __moduleparam_const __param_##name   \
        __used                                                          \
    __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
        = { __param_str_##name, THIS_MODULE, ops,                       \
            VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }

#define __moduleparam_const const
struct file_operations {
	struct module *owner;
	loff_t (*llseek) (struct file *, loff_t, int);
	ssize_t (*read) (struct file *, char *, size_t, loff_t *);
	ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
	int (*readdir) (struct file *, void *, filldir_t);
	unsigned int (*poll) (struct file *, struct poll_table_struct *);
	int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
	int (*mmap) (struct file *, struct vm_area_struct *);
	int (*open) (struct inode *, struct file *);
	int (*flush) (struct file *);
	int (*release) (struct inode *, struct file *);
	int (*fsync) (struct file *, struct dentry *, int datasync);
	int (*fasync) (int, struct file *, int);
	int (*lock) (struct file *, int, struct file_lock *);
	ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
	ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
	ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
	unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
};
int register_blkdev (unsigned int major, const char * name);

int __register_chrdev (	unsigned int major,
 	unsigned int baseminor,
 	unsigned int count,
 	const char * name,
 	const struct file_operations * fops);
개인 도구
이름공간

변수
행위
둘러보기
도구모음