//http://blog.chinaunix.net/uid-24549279-id-71355.html
/*
============================================================================
Name : test.c
Author : blank
Version :
Copyright : Your copyright notice
Description : 程序4-4 chmod函数实例
============================================================================
*/ #include <fcntl.h>
#include "ourhdr.h" int main(int argc, char *argv[])
{
struct stat buf;
if (stat("foo", &buf) < ){
err_sys("stat error for foo");
}
/*
* turn on set-group-ID and turn off group-execute
*/
if (chmod("foo", (buf.st_mode & ~S_IXGRP) | S_ISGID) < ){
err_sys("chmod error for foo");
} /*
*set absolute mode to rw-r--r--
*/
if (chmod("bar", (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < ){
err_sys("chmod error for bar");
}
exit();
}

程序4-4 chmod函数实例的更多相关文章

  1. 程序清单 8-8 exec函数实例,a.out是程序8-9产生的可执行程序

    /* ============================================================================ Name : test.c Author ...

  2. 程序4-6 utime函数实例

    //http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...

  3. 程序4-3 umask函数实例

    //http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...

  4. 程序4-2 access函数实例

    //http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...

  5. python迭代器与iter()函数实例教程

    python迭代器与iter()函数实例教程 发布时间:2014-07-16编辑:脚本学堂 本文介绍了python迭代器与iter()函数的用法,Python 的迭代无缝地支持序列对象,而且它还允许程 ...

  6. 解决C#程序只允许运行一个实例的几种方法详解

    解决C#程序只允许运行一个实例的几种方法详解 本篇文章是对C#中程序只允许运行一个实例的几种方法进行了详细的分析介绍,需要的朋友参考下 本文和大家讲一下如何使用C#来创建系统中只能有该程序的一个实例运 ...

  7. 解决C# WINFORM程序只允许运行一个实例的几种方法详解

    要实现程序的互斥,通常有下面几种方式,下面用 C# 语言来实现: 方法一: 使用线程互斥变量. 通过定义互斥变量来判断是否已运行实例. 把program.cs文件里的Main()函数改为如下代码: u ...

  8. PHP截取字符串函数substr()函数实例用法详解

    在PHP中有一项非常重要的技术,就是截取指定字符串中指定长度的字符.PHP对于字符串截取可以使用PHP预定义函数substr()函数来实现.下面就来介绍一下substr()函数的语法及其应用. sub ...

  9. C++的友元类和友元函数实例

    #include <math.h> #include<iostream> using namespace std; class Point { public: Point(do ...

随机推荐

  1. 【bzoj5427】最长上升子序列(贪心+LIS)

    题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=5427 因为noip,博客咕了好久,这几天集中填一下坑. 这题我们可以假设往不确定的空位 ...

  2. Oracle书籍资料链接——更新ing

    oracle database 11g初学者指南(中文版).pdf https://pan.baidu.com/s/1mkl8JVU Oracle Database 11g完全参考手册.pdf htt ...

  3. PAT1054. The Dominant Color (20)

    #include <iostream> #include <map> using namespace std; int n,m; map<int,int> imgM ...

  4. 未能加载文件或程序集 Ninject.Web.Common, Version=3.2.0.0

    在Web MVC4中使用NuGet添加NInject.MVC4后,编译报了个警告: 发现同一依赖程序集的不同版本之间存在冲突 然后在运行时就运行到var kernel = new StandardKe ...

  5. ButterKnife使用详谈

    (1)ButterKnife是什么? 在开发过程中,我们总是会写大量的findViewById和点击事件,像初始view.设置view监听这样简单而重复的操作让人觉得特别麻烦,当然不会偷懒的程序员不是 ...

  6. flash滚动图片遮住二级下拉菜单解决方法

    如上图所示,在进行排版时,如果不注意会遇到二级下拉菜单被下边的img图片遮住.此种情况在ie7 8 中出现. 解决方法:给二级下拉菜单添加z-index:9999;position:relative; ...

  7. poj2478欧拉函数

    打表欧拉函数,求2到n的欧拉函数和 #include<map> #include<set> #include<cmath> #include<queue> ...

  8. URL的编码

    + URL 中+号表示空格 %2B 空格 URL中的空格可以用+号或者编码 %20 / 分隔目录和子目录 %2F ? 分隔实际的 URL 和参数 %3F % 指定特殊字符 %25 # 表示书签 %23 ...

  9. 常见GAN的应用

    深入浅出 GAN·原理篇文字版(完整)|干货 from:http://baijiahao.baidu.com/s?id=1568663805038898&wfr=spider&for= ...

  10. Linux下用c语言实现whereis.

    简单的一个whereis的实现,代码如下: #include <stdio.h> #include <errno.h> #include <dirent.h> #i ...