zoukankan      html  css  js  c++  java
  • linux之umask函数解析

    [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 ");
            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]$ 

  • 相关阅读:
    C# 如何在PDF文档中创建表格
    C# 如何创建Excel多级分组
    C# 添加、修改以及删除Excel迷你图表的方法
    C# 创建EXCEL图表并保存为图片
    【BZOJ5287】[HNOI2018]毒瘤(动态规划,容斥)
    【BZOJ5250】[九省联考2018]秘密袭击(动态规划)
    【BZOJ5213】[ZJOI2018]迷宫(神仙题)
    CodeForces Global Round 1
    【BZOJ5212】[ZJOI2018]历史(Link-Cut Tree)
    【BZOJ5211】[ZJOI2018]线图(树哈希,动态规划)
  • 原文地址:https://www.cnblogs.com/aukle/p/3235321.html
Copyright © 2011-2022 走看看