The POSIX standard requires dev_t be an integer type, and ino_t be an unsigned integer.
dev_t must be an integer type.
fsblkcnt_t, fsfilcnt_t and ino_t must be defined as unsigned integer types.
Since intmax_t and uintmax_t must be integers of the greatest width, your code is safe. To make sure st_dev is negative, you can write it as:
printf("%jd %ju\n", (intmax_t)st.st_dev, (uintmax_t)st.st_ino);
Otherwise, your code will be safe.
source share