【发布时间】:2021-01-16 21:25:52
【问题描述】:
我在尝试创建自制容器时遇到这些编译器错误
warning: implicit declaration of function ‘sys_pivot_root’; did you mean ‘SYS_pivot_root’? [-Wimplicit-function-declaration]
TRY (sys_pivot_root(wd, "/dir/oldroot"));
然后我将 sys_pivot_root 更改为 SYS_pivot_root 然后出现以下错误消息。
install_rootg.c:61:9: error: called object is not a function or function pointer
TRY (SYS_pivot_root(wd, "/dir/oldroot"));
然后我查看 syscall.h 以查看该函数是否存在。我得到以下行
asmlinkage long sys_pivot_root (const char __user * new_root, const char __user * put_old)
为什么会出现这些编译器错误?我已经有一个星期没能解决这个问题了。
我按照这个确切的顺序包含头文件。
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <sched.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <limits.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/mman.h>
任何帮助将不胜感激。提前谢谢!
【问题讨论】:
-
根据谷歌快速搜索,函数的名称是
pivot_root,SYS_pivot_root是一个定义的常量,将作为第一个参数传递给syscall。 -
感谢您的回复。 pivot_root 也出现了同样的问题。
标签: c linux containers system-calls mount