📄 opepipe.c
字号:
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/ioctl.h>#include <unistd.h>#include <fcntl.h>#include <string.h>#include <stdlib.h>#include "hardview.h"int pipe_read;int pipe_write;int pipe_state;int startPipeGui(){ if(access("/tmp/pipe_read_from_gui",F_OK)!=0) mkfifo("/tmp/pipe_read_from_gui",0666); if(access("/tmp/pipe_write_to_gui",F_OK)!=0) mkfifo("/tmp/pipe_write_to_gui",0666); pipe_read=open("/tmp/pipe_read_from_gui",0666); pipe_write=open("/tmp/pipe_write_to_gui",0666); return pipe_read;}int writePipe(char *buf,int buflen){ return write(pipe_write,buf,buflen);}int readPipe(char *buf,int buflen){ return read(pipe_read,buf,buflen);}int readService(char *buf){ int sfile; int readn; system("/managePlat/shell/chkservice.sh"); sfile=open("/tmp/pipe_service_state",0666); readn=read(sfile,buf,256); close(sfile); return readn;}int readDisk(diskVolume *diskV){ FILE *file; char buf[128],buf1[16],*p,*pch; int pos,i,j,ver,z,diskI; system("/managePlat/shell/chkvolume.sh"); diskI=0; file=fopen("/tmp/pipe_disk_state","r"); while(fgets(buf,128,file)!=NULL) { pos=strlen(buf); pch=buf; for(i=0;i<pos;i++) { if(buf[i]==' ') pch++; else break; } p=pch;z=0;j=0;ver=0; pos=strlen(pch); for(i=0;i<pos;i++) { if(ver==0) { j++; if(*(pch+i)==' ') { z++; memcpy(buf1,p,j); buf1[j]=0; if(z==1) { diskV->disk[diskI].size=atoi(buf1); } if(z==2) { diskV->disk[diskI].usedsize=atoi(buf1); } ver=1; } } else { if(*(pch+i)!=' ') { j=0;ver=0;p=pch+i;} } } sprintf(diskV->disk[diskI].diskName,"%s",p); { int len=strlen(diskV->disk[diskI].diskName); diskV->disk[diskI].diskName[len-1]=0; } diskI++; if(diskI>11) break; } diskV->diskCount=diskI; fclose(file); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -