1 //http://blog.chinaunix.net/uid-24549279-id-71355.html 2 /* 3 ============================================================================ 4 Name : test.c 5 Author : blank 6 Version : 7 Copyright : Your copyright notice 8 Description : 程序4-3 umask函数实例 9 ============================================================================10 */11 12 #include13 #include "ourhdr.h"14 15 #define RWRWRW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)16 17 int main(int argc, char *argv[])18 {19 umask(0);20 21 if (creat("foo", RWRWRW) < 0){22 err_sys("create error for foo");23 }24 25 umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);26 if (creat("bar", RWRWRW) < 0){27 err_sys("creat error for bar");28 }29 exit(0);30 }