-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherrnoshowcase.c
33 lines (29 loc) · 932 Bytes
/
errnoshowcase.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "sources/mystdio.h"
int main(int argc, char const *argv[])
{
/**
* @brief The following are three cases of errno use in my ufs implementation
*
*/
mymount("testfile.txt", NULL, NULL, NULL, NULL);
myFILE* fptr = myfopen("thits", "f");
if (fptr == -1) {
printf("Value of errno: %d\n", errno);
fprintf( stderr, "system error: %s\n" , strerror(errno) );
}
myFILE* fptr1 = myfopen("root/test1/file2", "r");
char* test = "test";
int ret = myfwrite(test, 1, 4, fptr1);
if (ret == -1) {
printf("Value of errno: %d\n", errno);
fprintf( stderr, "system error: %s\n" , strerror(errno) );
}
myfclose(fptr1);
int fd = myopen("root/test1", 0); // (Is a directory)
if (fd == -1) {
printf("Value of errno: %d\n", errno);
fprintf( stderr, "system error: %s\n" , strerror(errno) );
}
myclose(fd);
return 0;
}