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]$ 

  • 相关阅读:
    elementui表单输入框部分校验--判断
    vue学习如何引入js,封装操作localStorage本地储存的方法
    vue组件传值 递增次数传递bug修复
    vue深度监听之手机格式344
    vue-------滑动验证
    vue get/post请求如何携带cookie的问题
    elementui的dialog组件踩坑
    WebStorm License Activation (WebStorm许可证激活)
    input 标签实现带提示文字的输入框
    隐藏 input 标签的边框
  • 原文地址:https://www.cnblogs.com/aukle/p/3235321.html
Copyright © 2011-2022 走看看