Linux系统调用 access函数详解
Linux系统调用--access函数详解
2007-07-30 23:10
【access系统调用】
功能描述:
检查调用进程是否可以对指定的文件执行某种操作。
用法:
#include <unistd.h>
#include <fcntl.h>
int access(const char *pathname, int mode);
参数:
pathname: 需要测试的文件路径名。
mode: 需要测试的操作模式,可能值是一个或多个R_OK(可读?), W_OK(可写?), X_OK(可执行?) 或 F_OK(文件存在?)组合体。
返回说明:
成功执行时,返回0。失败返回-1,errno被设为以下的某个值
EINVAL: 模式值无效
EACCES: 文件或路径名中包含的目录不可访问
ELOOP : 解释路径名过程中存在太多的符号连接
ENAMETOOLONG:路径名太长
ENOENT: 路径名中的目录不存在或是无效的符号连接
ENOTDIR: 路径名中当作目录的组件并非目录
EROFS: 文件系统只读
EFAULT: 路径名指向可访问的空间外
EIO: 输入输出错误
ENOMEM: 不能获取足够的内核内存
ETXTBSY:对程序写入出错
例子:
/* test.c */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
if (argc < 2) {
printf("Usage: ./test filename\n");
exit(1);
}
if (access(argv[1], F_OK) == -1) {
puts("File not exists!");
exit(2);
}
if (access(argv[1], R_OK) == -1)
puts("You can't read the file!");
else
if (access(argv[1], R_OK | W_OK) != -1)
puts("You can read and write the file");
else
&n
相关文档:
gcc的编译过程分为四步,分别为:
(1)预编译 (Pre-Processing)
(2)编译 (Compiling)
(3)汇编 (Assembling)
(4)链接 (Linking)
以hello.c为例说明:
#include<stdio.h>
int main(void)
{
printf("Hello World!");
return 0;
}
(1)预编译阶段 (Pre-Processing)
&nbs ......
http://blog.csdn.net/compiler_hdz/archive/2006/01/10/575113.aspx
先看一个“hello world!”的例子:
在某个目录下新建一个文件,叫hello.sh,敲入以下代码:
#!/bin/sh
echo "hello world!"
好,就这些。保存,在命令提示符下进入保存“hello.sh”的目录,这样执行:
......
[本文转自]http://www.scmlife.com/index.php/214/dp-bbsthread-21094.html
附件文档大纲:
环境
1.安装Apache2.2.14
2.安装Subversion
1.6.6
3.安装后的系统设置
4.Apache设置
5.svn库的配置
6.运行SVN服务器
环境:
Red Hat Enterprise Linux Server release 5.3
(Tikanga)
httpd-2.2.14.tar.gz
subversi ......
作者:刘洪涛,华清远见嵌入式学院讲师。
四、在内核里写i2c设备驱动的两种方式
前文介绍了利用/dev/i2c-0在应用层完成对i2c设备的操作,但很多时候我们还是习惯为i2c设备在内核层编写驱动程序。目前内核支持两种编写i2c驱动程序的方式。下面分别介绍这两种方式的实现。这里分别称这两种方式为“Adapter方式(LEGAC ......