⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtl_posixio_fake.h

📁 最新rtlinux内核源码
💻 H
字号:
/* This file has been written by Sergio Perez Alca駃z <serpeal@upvnet.upv.es>  Departamento de Inform醫ica de Sistemas y Computadores Universidad Polit閏nica de Valencia Valencia (Spain) Date: December 2004 Copyright (c) December,   2004 SISTEMAS  DE TIEMPO  REAL  EMPOTRADOS, FIABLES Y DISTRIBUIDOS BASADOS EN COMPONENTES Released under  the terms of the GNU  General  Public License Version 2.0 rtl_posixio_fake.h: This file  allows  other applications to  build a software layer over the driver, substituting the driver's open, read, write, ioctl and  close calls with  the other applications owns (that can still use the  older calls to  send and receive). That  allows to execute "extra" code before executing  -for example- the code of  the read call while keeping  this  substitution transparent to  the final user (who will finally call read). As said before, the main idea of this code is to provide the basis to build a software layer over the  driver in a transparent manner. This could be useful,  for example, to develope  a real-time protocol over Ethernet while providing the same standard (POSIX) interface. If  compiled  with  the  _TEST_FAKE_   option,  the   next  code will substitute the driver's read, write, open, close and ioctl calls with the   rtl_{read,write,open,close,ioctl}_fake   functions, function(s) that first prints "FAKE!!" and finally calls the corresponding driver call.*/#ifdef _FAKE_DRIVER_#ifndef _TEST_FAKE_extern ssize_t (*oldread) (struct rtl_file *, char *, size_t, loff_t *);extern ssize_t (*oldwrite) (struct rtl_file *, const char *, size_t, loff_t *);extern int (*oldioctl) (struct rtl_file *, unsigned int, unsigned long);extern int (*oldopen) (struct rtl_file *);extern int (*oldrelease) (struct rtl_file *);extern ssize_t rtl_read_fake(struct rtl_file *filp, char *buf, size_t count, loff_t* ppos);extern ssize_t rtl_write_fake(struct rtl_file *filp, const char *buf, size_t count, loff_t* ppos);extern int rtl_ioctl_fake(struct rtl_file * filp, unsigned int request, unsigned long other);extern int rtl_open_fake (struct rtl_file *filp);extern int rtl_release_fake (struct rtl_file *filp);#elsessize_t (*oldread) (struct rtl_file *, char *, size_t, loff_t *);ssize_t (*oldwrite) (struct rtl_file *, const char *, size_t, loff_t *);int (*oldioctl) (struct rtl_file *, unsigned int, unsigned long);int (*oldopen) (struct rtl_file *);int (*oldrelease) (struct rtl_file *);static ssize_t rtl_read_fake(struct rtl_file *filp, char *buf, size_t count, loff_t* ppos){  rtl_printf("READ FAKE!!\n");  return oldread(filp, buf, count, ppos);}static ssize_t rtl_write_fake(struct rtl_file *filp, const char *buf, size_t count, loff_t* ppos){  rtl_printf("WRITE FAKE!!\n");  return oldwrite(filp, buf, count, ppos);}static int rtl_ioctl_fake(struct rtl_file * filp, unsigned int request, unsigned long other){  rtl_printf("IOCTL FAKE!!\n");  return oldioctl(filp, request, other);}static int rtl_open_fake (struct rtl_file *filp){  rtl_printf("OPEN FAKE!!\n");  return oldopen(filp);}static int rtl_release_fake (struct rtl_file *filp){  rtl_printf("CLOSE FAKE!!\n");  return oldrelease(filp);}#endifstatic void init(void){  //This code   saves  a  pointer  to  the   driver's  read call   and  //substitutes that call with the fake one  oldread = fops->read;  fops->read = rtl_read_fake;  //This  code saves   a pointer  to    the driver's  write  call  and  //substitutes that call with the fake one  oldwrite = fops->write;  fops->write = rtl_write_fake;  //This  code    saves a  pointer   to the  driver's   ioctl call and  //substitutes that call with the fake one  oldioctl = fops->ioctl;  fops->ioctl = rtl_ioctl_fake;  //This  code  saves  a  pointer  to   the   driver's  open call  and  //substitutes that call with the fake one  oldopen = fops->open;  fops->open = rtl_open_fake;  //This code  saves   a pointer to  the  driver's  read  release  and  //substitutes that call with the fake one  oldrelease = fops->release;  fops->release = rtl_release_fake;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -