mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-08 06:41:58 +00:00
This bug just occurs when reading a symlink on procfs. If input is an absolute path, it will get wrong my_dent. So we use stat syscall to check whether the "/proc/1/root" and "/" is same path in graphene. Signed-off-by: Zhang Chen <chen.zhang@intel.com>
27 lines
529 B
C
27 lines
529 B
C
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char ** argv)
|
|
{
|
|
struct stat root, proc_root;
|
|
|
|
if (stat("/", &root) == -1) {
|
|
perror("stat");
|
|
exit(1);
|
|
}
|
|
|
|
if (stat("/proc/1/root", &proc_root) == -1) {
|
|
perror("stat");
|
|
exit(1);
|
|
}
|
|
|
|
if (root.st_dev == proc_root.st_dev &&
|
|
root.st_ino == proc_root.st_ino) {
|
|
printf("proc path test success\n");
|
|
} else {
|
|
printf("proc path test failure\n");
|
|
}
|
|
}
|