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

📄 mem_read.c

📁 LINUX内核编程的一些程序例子
💻 C
字号:
/** @file mem_read.c * * @author marco corvi <marco_corvi@geocities.com> * @date   mar 2003 * * \brief read test for the mem_tty driver * */ #include <stdio.h>      // printf#include <stdlib.h>     // exit#include <sys/types.h>  // open#include <sys/stat.h>   // open#include <fcntl.h>      // open#include <unistd.h>     // read close#include <errno.h>      // errno#include <sys/ioctl.h>  // ioctlint main( int argc, char ** argv ){  int fd;  char ch;  int i;  int ld;  if ( argc <= 1 ) {    fprintf(stderr, "Usage: %s <device>\n", argv[0] );    exit(1);  }  fd = open( argv[1], O_RDONLY );  if ( fd < 0 ) {    fprintf(stderr, "Error: unable to open %s (errno %d)\n", argv[1], errno);    exit( 1 );  }  ioctl( fd, TIOCGETD, &ld);  printf("Line discipline %d \n", ld );  for (i=0; i<1024; i++) {    if ( read( fd, &ch, 1 ) <= 0)       break;    fprintf(stderr, "%c", ch );  }  close( fd );  exit( 0 );}

⌨️ 快捷键说明

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