- 论坛徽章:
- 0
|
- #include <unistd.h>;
- #include <sys/stat.h>;
- #include <sys/types.h>;
- #include <syslog.h>;
- #include <fcntl.h>;
- #include <stdio.h>;
- int
- main(void)
- {
- int fd,n;
- char buf[MAXLINE] ;
- if((fd=open("/dev/kmem",O_RDONLY))<0) {
- perror("open /dev/kmem error");
- return(1);
- }
- for( ; ; ) {
- while((n=read(fd,buf,MAXLINE))>;0) {
- if(write(STDOUT_FILENO,buf,n)<0) {
- perror("write error\n");
- return(1);
- }
- }
- if(n<0) {
- perror("read fd error");
- return(2);
- }
- memset(buf,'\0',sizeof(buf));
- }
- close(fd);
- return(0);
- }
复制代码 # ./getkmem
read fd error: Bad address
help !!我还有什么知识没懂吗?请指教!! |
|