file_operations下函數詳解
// 刷新待處理的數據,如果驅動程序沒有實現,fsync調用將返回-EINVAL
int (*aio_fsync) (struct kiocb *, int datasync);
// 異步fsync
int (*fasync) (int, struct file *, int);
// 通知設備FASYNC標志發生變化,如果設備不支持異步通知,該字段可以為NULL
int (*lock) (struct file *, int, struct file_lock *);
// 實現文件鎖,設備驅動常不去實現此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 *);
// readv和writev 分散/聚集型的讀寫操作,實現進行涉及多個內存區域的單次讀或寫操作。
ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
// 實現sendfile調用的讀取部分,將數據從一個文件描述符移到另一個,設備驅動通常將其設置為 NULL
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
// 實現sendfile調用的另一部分,內核調用將其數據發送到對應文件,每次一個數據頁,設備驅動通常將其設置為NULL
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned
long);
// 在進程地址空間找到一個合適的位置,以便將底層設備中的內存段映射到該位置。大部分驅動可將其設置為NULL
int (*check_flags)(int);
// 允許模塊檢查傳遞給fcntl(F_SETEL…)調用的標志
int (*dir_notify)(struct file *filp, unsigned long arg);
// 應用程序使用fcntl來請求目錄改變通知時,調用該方法。僅對文件系統有效,驅動程序不必實現。
int (*flock) (struct file *, int, struct file_lock *);
// 實現文件鎖
};本文引用地址:http://www.104case.com/article/150582.htm
評論