fs: Add stat example

Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>
This commit is contained in:
Louis Solofrizzo 2019-04-25 11:30:39 +02:00
parent 021914386e
commit 6a1c3734e6
2 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,3 @@
export ukl-obj-m := main.o
include ../../Makefile

View 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;
}