Neelkanth_39$ cat umask.c
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main () {
FILE *fp;
errno = 0;
/*
* RETURN VALUE
* This system call always
succeeds and the previous value of the mask is returned.
*/
int old_mask = umask(0);
printf("old mask : %d\n",
old_mask);
system("rm -rf neelu");
/* make directory */
int dir_result =
mkdir("neelu", 0777);
if(dir_result != 0 && errno !=
EEXIST){
printf( "Value of
errno: %s\n", strerror(errno));
}
else if (errno == EEXIST)
{
printf("error code:
%s", strerror(errno));
}
int old_mask1 = umask(old_mask);
printf("old mask : %d\n",
old_mask1);
return(0);
}
Output
Neelkanth_39$ ./a.out
old mask : 2
old mask : 0