linux之umask函数解析
2013-08-03 21:31
302 查看
[lingyun@localhost umask_1]$ vim umask.c
+ umask.c
/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: umask.c
* Description: This file
*
* Version: 1.0.0(08/02/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "08/02/2013 07:09:24 PM"
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
int main(void)
{
umask(0);
if(creat("hello", RWRWRW) < 0)
{
printf("creat error for hello\n");
exit(1);
}
umask(S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
if(creat("world", RWRWRW) < 0)
{
printf("creat error for world");
exit(1);
}
exit(0);
}
~
~
~
~
~
~
~
~
~
~
~/apue/umask/umask_1/umask.c[+] CWD: /usr/local/src/lingyun/apue/umask/umask_1 Line: 37/38:12
"umask.c" [New] 38L, 1016C written
[lingyun@localhost umask_1]$ gcc umask.c
[lingyun@localhost umask_1]$ umask
0022
[lingyun@localhost umask_1]$ ./a.out
[lingyun@localhost umask_1]$ ls -l hello world
-rw-rw-rw- 1 lingyun trainning 0 Aug 2 19:19 hello
-rw------- 1 lingyun trainning 0 Aug 2 19:19 world
[lingyun@localhost umask_1]$ umask
0022
[lingyun@localhost umask_1]$
+ umask.c
/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: umask.c
* Description: This file
*
* Version: 1.0.0(08/02/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "08/02/2013 07:09:24 PM"
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
int main(void)
{
umask(0);
if(creat("hello", RWRWRW) < 0)
{
printf("creat error for hello\n");
exit(1);
}
umask(S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
if(creat("world", RWRWRW) < 0)
{
printf("creat error for world");
exit(1);
}
exit(0);
}
~
~
~
~
~
~
~
~
~
~
~/apue/umask/umask_1/umask.c[+] CWD: /usr/local/src/lingyun/apue/umask/umask_1 Line: 37/38:12
"umask.c" [New] 38L, 1016C written
[lingyun@localhost umask_1]$ gcc umask.c
[lingyun@localhost umask_1]$ umask
0022
[lingyun@localhost umask_1]$ ./a.out
[lingyun@localhost umask_1]$ ls -l hello world
-rw-rw-rw- 1 lingyun trainning 0 Aug 2 19:19 hello
-rw------- 1 lingyun trainning 0 Aug 2 19:19 world
[lingyun@localhost umask_1]$ umask
0022
[lingyun@localhost umask_1]$
相关文章推荐
- linux之umask函数解析
- 关闭 linux下的umask( )函数、setsid( )函数
- 解析Linux下的时间函数:设置以及获取时间的方法
- 全面解析Linux 内核 3.10.x - 内核入口函数__kernel_entry
- Intel平台下linux中 ELF文件动态链接的加载、解析及实例分析(二): 函数解析与卸载
- 【linux】open函数创建新文件及umask函数使用
- Linux 字符设备驱动开发基础(五)—— ioremap() 函数解析
- linux之getcwd函数解析
- Linux中syslog日志函数扫盲式实例解析
- linux之fcntl函数解析
- Linux进程学习(五)之函数waitpid函数的解析
- linux c strtol 函数解析
- linux开发--dup和dup2函数解析
- linux之stat函数解析
- linux中fileno函数与ftruncate函数解析
- Linux中__init、__devinit等初始化宏解析和入口函数
- linux之dup和dup2函数解析
- linux之dup和dup2函数解析
- linux之ioctl函数解析
- Linux 字符设备驱动开发基础(三)—— read()、write() 相关函数解析