【发布时间】:2013-07-04 12:06:00
【问题描述】:
fd = open(pathname, O_WRONLY | O_LARGEFILE | O_APPEND | O_CREAT);
在运行我的测试时,我遇到了一个 valgrind 错误:
==14280== Syscall param open(mode) contains uninitialised byte(s)
==14280== at 0x4111084: open64 (open64.c:42)
而open的返回值为-2
Errno 设置为13 (Permission denied)
pathname 缓冲区包含:
0x68
0x72
0x32
0x2E
0x66
0x61
0x0
关于我的系统的信息:
$ ls -la
drwxr-xr-x 7 rzetterberg zed 4096 Jul 4 13:56 .
$ id
uid=1000(rzetterberg) gid=1000(rzetterberg) groups=1000(rzetterberg), ... etc
$ sudo file -Ls /dev/sda1
/dev/sda1: sticky Linux rev 1.0 ext3 filesystem data, UUID=XXXX (needs journal recovery) (large files)
$ uname -a
Linux xxxx 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1 i686 GNU/Linux
包含的标题:
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
我不明白mode 是如何具有单元化字节的,以及为什么我会得到Permission denied。这对我来说似乎很奇怪!
【问题讨论】:
标签: c linux io system-calls