2020-06-01 20:02:05 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
2020-06-01 23:56:22 +00:00
|
|
|
#include <unistd.h>
|
2020-06-01 20:02:05 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
if(argc <=1)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"Give a file\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fd = open(argv[1],O_RDWR|O_CREAT);
|
|
|
|
|
|
|
|
if(fd == -1)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"Error creating file\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
chmod(argv[1],420); /* 644 in decimal */
|
2020-06-01 23:56:22 +00:00
|
|
|
close(fd);
|
2020-06-01 20:02:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|