Wednesday, May 03, 2006

create, chmod a directory

#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

int main(int argc, char** argv)
{
int fd;

fd = open("testdir", O_CREAT, 555);
if(fd != -1)
fchmod(fd, 422);
else
printf("cannot open the directory \n");

return 0;
}

No comments: