-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen.c
More file actions
28 lines (26 loc) · 665 Bytes
/
open.c
File metadata and controls
28 lines (26 loc) · 665 Bytes
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
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
static const char * const WRITE_FILE = "vivek is great\n";
int main(int argc, char *argv[])
{
int fd,fd1;
if(argc!=2)
{
printf("Usage : ./open <file name>\n");
exit(1);
}
pid_t pid = getpid();
//printf("\npid is %d\n",pid);
fd = open(argv[1],O_WRONLY|O_APPEND,S_IRWXU);
//fd1 = open(argv[2],O_WRONLY|O_APPEND,S_IRWXU);
//printf("File Descriptor used is %d\n", fd);
write(fd, WRITE_FILE, strlen(WRITE_FILE));
//write(fd1, WRITE_FILE, strlen(WRITE_FILE));
return 0;
}