fs: Add stat example
Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>
This commit is contained in:
parent
021914386e
commit
6a1c3734e6
2 changed files with 23 additions and 0 deletions
3
unikernel-demo/fs1/stat/Makefile
Normal file
3
unikernel-demo/fs1/stat/Makefile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export ukl-obj-m := main.o
|
||||
|
||||
include ../../Makefile
|
||||
20
unikernel-demo/fs1/stat/main.c
Normal file
20
unikernel-demo/fs1/stat/main.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef USERSPACE
|
||||
#define main ukl_main
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct stat st = { 0 };
|
||||
|
||||
if (stat("/etc/passwd", &st) != 0)
|
||||
{
|
||||
fprintf(stderr, "Cannot stat() /etc/passwd\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Size of /etc/passwd: %zu bytes\n", st.st_size);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue