Experiment 5 (OSII)
Experiment 5 (OSII)
Title : Study & Implement File Management using Low Level file Access System calls.
Aim: To Learn about File Management using low level file access system calls.
Theory: write theory about low level file access system calls.
2. Read():
Def
Syntax
Explain syntax in brief.
3. Write():
Def
Syntax
Explain syntax in brief.
4. Close():
Def
Syntax
Explain syntax in brief.
Conclusion
1) Open():
// C program to illustrate
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main()
if (fd == -1) {
perror("Program");
return 0;
}
2) Close():
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main()
if (fd1 < 0) {
perror("c1");
exit(1);
if (close(fd1) < 0) {
perror("c1");
exit(1);
3) Read():
// C program to illustrate
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main()
fd = open("foo.txt", O_RDONLY);
if (fd < 0) {
perror("r1");
exit(1);
sz = read(fd, c, 10);
fd, sz);
c[sz] = '\0';
return 0;
}
4) Write():
// C program to illustrate
#include<stdio.h>
#include <fcntl.h>
main()
int sz;
if (fd < 0)
perror("r1");
exit(1);
close(fd);