2 * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
5 * SPDX-License-Identifier: GPL-2.0-or-later
16 * Do not print any messages, indicate errors with return codes.
19 check_fd(int fd, const char *fname)
21 const int should_be_closed = (fname[0] == '\0');
23 struct stat st_fd, st_fn;
25 if (fstat(fd, &st_fd)) {
26 if (!should_be_closed)
32 if (stat(fname, &st_fn))
35 if (st_fd.st_dev != st_fn.st_dev
36 || st_fd.st_ino != st_fn.st_ino)
44 main(int ac, char **av)
46 assert(ac == 1 + N_FDS);
49 for (fd = 1; fd < 1 + N_FDS; ++fd)
50 if ((rc = check_fd(fd - 1, av[fd])))