main fbirth.c
 1#define _GNU_SOURCE
 2
 3#include <stdio.h>
 4#include <inttypes.h>
 5#include <sys/stat.h>
 6#include <fcntl.h>
 7#include <err.h>
 8
 9int
10main(int argc, char **argv) {
11	if (argc < 2) {
12		fprintf(stderr, "Usage: %s FILE...\n", argv[0]);
13		return 1;
14	}
15
16	struct statx buf;
17
18	for (int i = 1; i < argc; i++) {
19		int r = statx(AT_FDCWD, argv[i],
20			AT_STATX_SYNC_AS_STAT, STATX_BTIME, &buf);
21		if (r < 0) err(1, "statx");
22
23		if (buf.stx_mask & STATX_BTIME)
24			printf("%" PRIu64 "\n", buf.stx_btime.tv_sec);
25		else {
26			warn("statx");
27			puts("0");
28		}
29	}
30
31	return 0;
32}