Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am having trouble creating a new .txt file by using the system calls in

ID: 3746560 • Letter: H

Question

Hello,

I am having trouble creating a new .txt file by using the system calls in xv6. It isn't actually creating tom.txt. I have tried writing it like it is now as well as changing the open("tom.txt", O_CREATE); Please help.

system-calls.txtx simple.c | HW2.c |.h syscall.h #include #include #include "types.h"//unknown type name 'uint' "stat.h"//don.t need "user.h"//implicit decleration of fuctiom printf(); #include "fcntl " h" #define N 15 int main //int fd; printf(1,"Travis Redd " )://needs two perameters open ("home/travis/dektop/xv6/tom.txt", 0 _CREATE | 0 RDWR) exit)

Explanation / Answer

Here is the simple code for creating or opening a file using system calls

#include<stdio.h>
#include<fcntl.h>
#include<errno.h>
extern int errno;
int main()
{   
int fdr = open("file1.txt", O_RDONLY | O_CREAT);  
printf("fdr = %d/n", fdr);
if (fdr ==-1)
{
printf("Error Number % d ", errno);  
perror("Program");   
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote