Question: #include #include #include #include #include #include #include struct stat stat1; int main(){ char *type,*readok,*execok,*writeok; char line[40],buf[100]; bzero(buf,100); char filename[50]; struct stat stat1; int fp; printf(enter

#include #include #include #include #include #include #include struct stat stat1;

int main(){ char *type,*readok,*execok,*writeok; char line[40],buf[100]; bzero(buf,100); char filename[50]; struct stat stat1; int fp; printf("enter a file name : "); scanf("%s" , filename); if (stat(filename, &stat1)<0) { write(1,"File doesnot exist!! ",22); exit(1); } fp=open(filename,O_RDWR | O_APPEND); stat(filename,&stat1); if(S_ISREG(stat1.st_mode)) type = "regular"; else if(S_ISDIR(stat1.st_mode)) type = "directory"; else type= "Other"; printf("type is %s ",type); if((stat1.st_mode&S_IRUSR)){ readok ="user can read the file"; }else{ readok ="user cannot read the file";} //=================== if((stat1.st_mode&S_IWUSR)) writeok ="user can write the file"; else writeok ="user cannot write the file"; //=========================== if((stat1.st_mode&S_IXUSR)) execok ="user can execute the file"; else execok ="user cannot execute the file"; printf("%s %s %s ",readok,writeok,execok); //=================================== if((stat1.st_mode&S_IRGRP)) readok ="GROUP can read the file"; else readok ="GROUP cannot read the file"; //================ if((stat1.st_mode&S_IWGRP)) writeok ="GROUP can write the file"; else writeok ="GROUP cannot write the file"; //================= if((stat1.st_mode&S_IXGRP)) execok ="GROUP can execute the file"; else execok ="GROUP cannot execute the file"; printf("%s %s %s ",readok,writeok,execok); //=========================================== if((stat1.st_mode&S_IROTH)) readok ="OTHER can read the file"; else readok ="OTHER cannot read the file"; //========================= if((stat1.st_mode&S_IWOTH)) writeok ="OTHER can write the file"; else writeok ="OTHER cannot write the file"; //============================== if((stat1.st_mode&S_IXOTH)) execok ="OTHER can execute the file"; else execok ="OTHER cannot execute the file"; printf("%s %s %s ",readok,writeok,execok); if(strcmp(type,"regular")==0){ write(1,"Enter a line: ",15); bzero(line,40); read(0,line,40); lseek(fp, 0,SEEK_END); write(fp,line,strlen(line));

lseek(fp,0,SEEK_END); bzero(buf,100); read(fp,buf,100); write(1,buf,100); } close(fp); return 0; } #Question : Rewrite the above program to use only RIO I/O functions . do not use Unix I/O (for reading and writing ) nor C standard I/O functions save file as "lab07f.c"

(in C programming language ) computer system

please help me to change this code to RIO functions

thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!