-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b96f7ca
commit 1520e0e
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.out | ||
*.bin | ||
*.exe | ||
*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
#include<sys/types.h> | ||
#include<sys/uio.h> | ||
#include<fcntl.h> | ||
#include<unistd.h> | ||
|
||
int main(void) { | ||
|
||
int fd; | ||
int bytes_read; | ||
char buf[51200]; | ||
fd = open("./delme.txt", O_RDONLY); | ||
|
||
printf("fd = %d\n", fd); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
printf("________\n"); | ||
|
||
// 1 sec = 1000000 | ||
//usleep(500000); | ||
sleep(5); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
printf("________\n"); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
printf("________\n"); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
printf("________\n"); | ||
bytes_read = read(fd, buf, sizeof(buf)); | ||
printf("%d bytes read: %s\n", bytes_read, buf); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include<stdio.h> | ||
#include<fcntl.h> | ||
#include<unistd.h> | ||
#include<sys/types.h> | ||
#include<sys/stat.h> | ||
|
||
int main(void) { | ||
int fd, i; | ||
int bytes_written; | ||
char buf[51200]; | ||
for (i = 0; i < sizeof(buf); i++) { | ||
buf[i] = 'a'; | ||
} | ||
fd = open("./delme.txt", O_WRONLY | O_CREAT, 0777); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
printf("_______\n"); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
printf("_______\n"); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
printf("_______\n"); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
printf("_______\n"); | ||
bytes_written = write(fd, buf, sizeof(buf)); | ||
printf("%d bytes written\n", bytes_written); | ||
close(fd); | ||
} |