Experiment 6(OSII)Write-up and Program
Experiment 6(OSII)Write-up and Program
Title: Implementation of various operations on Files (Create, Open, Read, Write, Append, Fstat,
Dup etc.)
Aim: To Learn about various operations on Files (Create, Open, Read, Write, Append, Fstat, Dup
etc.)
Theory: write theory about various operations on Files (Create, Open, Read, Write, Append,
Fstat, Dup etc.)
(here write the use of each operation then syntax with short explanation)
Problem Statement: Implement various operations on Files (Create, Open, Read, Write,
Append, Fstat, Dup etc.)
Conclusion
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
if (fd == -1) {
perror("open");
exit(1);
if (bytes_written == -1) {
perror("write");
exit(1);
close(fd);
if (fd == -1) {
perror("open");
exit(1);
char buffer[1024];
if (bytes_read == -1) {
perror("read");
exit(1);
printf("%s\n", buffer);
close(fd);
if (fd == -1) {
perror("open");
exit(1);
}
if (bytes_written == -1) {
perror("write");
exit(1);
close(fd);
perror("stat");
exit(1);
perror("dup");
exit(1);
close(fd);
if (bytes_written == -1) {
perror("write");
exit(1);
close(fd2);
return 0;