<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > file_operations下函數(shù)詳解

          file_operations下函數(shù)詳解

          作者: 時間:2011-06-21 來源:網(wǎng)絡(luò) 收藏

          struct {

          struct module *owner;

          // 指向擁有該結(jié)構(gòu)的模塊的指針,避免正在操作時被卸載,一般為初始化為THIS_MODULES

          loff_t (*llseek) (struct file *, loff_t, int);

          // llseek用來修改文件當(dāng)前的讀寫位置,返回新位置

          // loff_t為一個長偏移量。當(dāng)此指針為空,seek調(diào)用將會以不可預(yù)期的方式修改file結(jié)構(gòu)中的位置計數(shù)器。

          ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);

          // 從設(shè)備中同步讀取數(shù)據(jù)。讀取成功返回讀取的字節(jié)數(shù)。設(shè)置為NULL,調(diào)用時返回-EINVAL

          ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);

          // 初始化一個異步的讀取操作,為NULL時全部通過read處理

          ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);

          // 向設(shè)備發(fā)送數(shù)據(jù)。

          ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);

          // 初始化一個異步的寫入操作。

          int (*readdir) (struct file *, void *, filldir_t);

          // 僅用于讀取目錄,對于設(shè)備文件,該字段為 NULL

          unsigned int (*poll) (struct file *, struct poll_table_struct *);

          // 返回一個位掩碼,用來指出非阻塞的讀取或?qū)懭胧欠窨赡堋?br style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px; word-wrap: break-word" />
          // 將pool定義為 NULL,設(shè)備會被認為即可讀也可寫。

          int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);

          // 提供一種執(zhí)行設(shè)備特殊命令的方法。不設(shè)置入口點,返回-ENOTTY

          long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);

          // 不使用BLK的文件系統(tǒng),將使用此種指針代替ioctl

          long (*compat_ioctl) (struct file *, unsigned int, unsigned long);

          // 在64位系統(tǒng)上,32位的ioctl調(diào)用,將使用此指針代替

          int (*mmap) (struct file *, struct vm_area_struct *);

          // 用于請求將設(shè)備內(nèi)存映射到進程地址空間。如果無此方法,將訪問-ENODEV。

          int (*open) (struct inode *, struct file *);

          // 如果為空,設(shè)備的打開操作永遠成功,但系統(tǒng)不會通知驅(qū)動程序

          // 由VFS調(diào)用,當(dāng)VFS打開一個文件,即建立了一個新的struct file,之后調(diào)用open方法分配文件結(jié)構(gòu)。open屬于struct

          inode_operations。

          int (*flush) (struct file *);

          // 發(fā)生在進程關(guān)閉設(shè)備文件描述符副本,執(zhí)行并等待,若設(shè)置為NULL,內(nèi)核將忽略用戶應(yīng)用程序的請求。

          int (*release) (struct inode *, struct file *);

          // file結(jié)構(gòu)釋放時,將調(diào)用此指針函數(shù),release與open相同可設(shè)置為NULL

          int (*fsync) (struct file *, struct dentry *, int datasync);


          上一頁 1 2 下一頁

          關(guān)鍵詞: 詳解 函數(shù) file_operations

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();