小编FUT*_*CH6的帖子

调用open时如何调用sys_open而不是sys_openat

我写了一段代码来生成系统调用

void open_test(int fd, const char *filepath) {
    if (fd == -1) {
        printf("Open \"%s\" Failed!\n", filepath);
    } else {
        printf("Successfully Open \"%s\"!\n", filepath);
        write(fd, "successfully open!", sizeof("successfully open!") - 1);
        close(fd);
    }
    fflush(stdout);
}

int main(int argc, char const *argv[]) {
    const char fp1[] = "whatever.txt", fp2[] = "./not-exist.txt";
    int fd1 = open(fp1, O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU);
    int fd2 = open(fp2, O_WRONLY | O_TRUNC, S_IRWXU);
    open_test(fd1, fp1);
    open_test(fd2, fp2);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

和另一个程序(细节省略)来捕捉系统调用,但后来我发现所有open()结果都是调用 sys_openat 而不是 …

c linux gcc system-calls linux-kernel

2
推荐指数
1
解决办法
416
查看次数

标签 统计

c ×1

gcc ×1

linux ×1

linux-kernel ×1

system-calls ×1