struct device_struct {
const char * name;
struct file_operations * fops;
};
static struct device_struct chrdevs[MAX_CHRDEV];
static struct {
const char *name;
struct block_device_operations *bdops;
} blkdevs[MAX_BLKDEV];
Jak widać, dla każdego urządzenia tablice wyglądają trochę inaczej.
Jest to różnica z poprzednią wersją, w której to obie tablice
zawierały wskaźnik na te same operacje struct file_operations * fops.
W tej nastapiło rozróżnienie.
Z pliku include/linux/fs.h:
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);
};
struct block_device_operations {
int (*open) (struct inode *, struct file *);
int (*release) (struct inode *, struct file *);
int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
int (*check_media_change) (kdev_t);
int (*revalidate) (kdev_t);
};
Korzystając z systemowej obsługi zapisu i odczytu z urządzeń blokowych, potrzebna jest dodatkowa funkcja realizująca kolejkowanie operacji I/O. Ustala się ją w oddzielnej tablicy zadeklarowanej include/linux/blkdev.h:
struct blk_dev_struct {
request_queue_t request_queue;
queue_proc *queue;
void *data;
};
Uwaga: Szczegółowo będzie to omawiane w następnych rozdziałach
,,Podsystemu WEJŚCIA/WYJŚCIA''