docker的ubuntu容器中如何获取文件信息
在容器中查询文件系统信息如下:
root@27755d922ffb:~# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 18G 15G 2.1G 88% /
none 18G 15G 2.1G 88% /
tmpfs 998M 0 998M 0% /dev
shm 64M 0 64M 0% /dev/shm
/dev/disk/by-uuid/f65dfc67-4152-4da0-9a6e-fcc2b822a574 18G 15G 2.1G 88% /etc/hosts
tmpfs 998M 0 998M 0% /proc/kcore
root@27755d922ffb:~# tune2fs -l rootfs
tune2fs 1.42.9 (4-Feb-2014)
tune2fs: No such file or directory while trying to open rootfs
Couldn't find valid filesystem superblock.
请问为什么看不到文件系统信息?
正常情况下,不应该是类似于/dev/sda1之类的名字吗,为什么是rootfs
另外,编写如下程序:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#define __USE_GNU 1
#include <fcntl.h>
int main()
{
int ret_num = 0;
char *szPath = "./test.txt";
int dwFlags = O_RDWR | O_NOATIME | O_CREAT | O_SYNC;
printf("open function test\n");
ret_num = open("./test1.txt", dwFlags, 00600);
if (ret_num == -1)
printf("test1(no O_DIRECT) fail system errno %d\n",errno);
else
printf("test1(no O_DIRECT) Success\n");
ret_num = 0;
dwFlags |= O_DIRECT;
ret_num = open("./test2.txt", dwFlags, 00600);
if (ret_num == -1)
printf("test2(have O_DIRECT) fail system errno %d\n",errno);
else
printf("test2(have O_DIRECT) Success\n");
printf("open function test finish\n");
}
在ubuntu服务器上执行结果如下:
root@ubuntu:~# gcc test.c -o aa
root@ubuntu:~# ./aa
open function test
test1(no O_DIRECT) Success
test2(have O_DIRECT) Success
open function test finish
在ubuntu容器中执行结果如下:
root@27755d922ffb:~# gcc test.c -o aa
root@27755d922ffb:~# ./aa
open function test
test1(no O_DIRECT) Success
test2(have O_DIRECT) fail system errno 2
open function test finish
请问有什么 办法解决这个差异?谢谢!