测试umaskzuoyong

来源:互联网 发布:杜兰特07年首秀数据 编辑:程序博客网 时间:2024/06/16 00:34

一,源代码:

<bldc:/home/tingbinz/apue.3e/SBSCODE/4>R*_*G:vim 4_9.c
  1 #include "apue.h"
  2 #include <fcntl.h>
  3
  4 #define RWRWRW S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
  5
  6 int main()
  7 {
  8         umask(0);
  9         if ( creat("without_umask", RWRWRW) < 0 )
 10                 err_sys("creat error");
 11         umask(S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
 12
 13         if ( creat("after_umask", RWRWRW) < 0)
 14                 err_sys("2 creat error");
 15
 16         exit(0);
 17
 18
 19 }
~

二,运行结果:

-rw-rw-rw- 1 tingbinz tingbinz       0 Sep 14 02:31 without_umask
-rw------- 1 tingbinz tingbinz       0 Sep 14 02:31 after_umask

0 0