“系统调用参数打开(模式)包含未初始化的字节”在打开的系统调用中(“Syscall param open(mode) contains uninitialised byte(s)” in open s

编程入门 行业动态 更新时间:2024-10-28 18:33:33
系统调用参数打开(模式)包含未初始化的字节”在打开的系统调用中(“Syscall param open(mode) contains uninitialised byte(s)” in open sys call) 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 。 对我来说这似乎很奇怪!

fd = open(pathname, O_WRONLY | O_LARGEFILE | O_APPEND | O_CREAT);

When running my tests I encounter a valgrind error:

==14280== Syscall param open(mode) contains uninitialised byte(s) ==14280== at 0x4111084: open64 (open64.c:42)

And the return value of open is -2

Errno is set to 13 (Permission denied)

The pathname buffer contains:

0x68 0x72 0x32 0x2E 0x66 0x61 0x0

Info about my system:

$ 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

Headers included:

#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>

I don't understand how mode can have unitialised bytes and why I'm getting a Permission denied. It seems very strange to me!

最满意答案

如果您提供O_CREAT标志为open() ,则必须提供第三个参数。 这是一个整数,表示应用于创建文件的权限(由当前umask修改)。

If you supply the O_CREAT flag to open(), you must supply a third argument. This is an integer which represents the permissions to apply to the created file (modified by the current umask).

更多推荐

本文发布于:2023-08-01 10:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1357888.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系统   初始化   字节   参数   模式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!