diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /myfind/simple_stat | |
Diffstat (limited to 'myfind/simple_stat')
| -rw-r--r-- | myfind/simple_stat/Makefile | 15 | ||||
| -rw-r--r-- | myfind/simple_stat/simple_stat.c | 31 |
2 files changed, 46 insertions, 0 deletions
diff --git a/myfind/simple_stat/Makefile b/myfind/simple_stat/Makefile new file mode 100644 index 0000000..f38f031 --- /dev/null +++ b/myfind/simple_stat/Makefile @@ -0,0 +1,15 @@ +CC = gcc +CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla + +SRC = simple_stat.c +OBJ = $(SRC:.c=.o) + +all: $(OBJ) + $(CC) -o simple_stat $(OBJ) + +$(OBJ): $(SRC) + +.PHONY: clean + +clean : + $(RM) $(OBJ) simple_stat diff --git a/myfind/simple_stat/simple_stat.c b/myfind/simple_stat/simple_stat.c new file mode 100644 index 0000000..27065b6 --- /dev/null +++ b/myfind/simple_stat/simple_stat.c @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <sys/stat.h> + +int main(int argc, char **argv) +{ + if (argc == 1) + return 0; + + struct stat s; + + for (int i = 1; i < argc; i++) + { + if (stat(argv[i], &s) != 0) + return 1; + printf("st_dev=%ld\n", s.st_dev); + printf("st_ino=%ld\n", s.st_ino); + printf("st_mode=%07o\n", s.st_mode); + printf("st_nlink=%ld\n", s.st_nlink); + printf("st_uid=%d\n", s.st_uid); + printf("st_gid=%d\n", s.st_gid); + printf("st_rdev=%ld\n", s.st_rdev); + printf("st_size=%ld\n", s.st_size); + printf("st_atime=%ld\n", s.st_atime); + printf("st_mtime=%ld\n", s.st_mtime); + printf("st_ctime=%ld\n", s.st_ctime); + printf("st_blksize=%ld\n", s.st_blksize); + printf("st_blocks=%ld\n", s.st_blocks); + } + + return 0; +} |
