shred: with -u, unlink file even if it is zero length

function                                             old     new   delta
shred_main                                           391     387      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-06-20 13:48:21 +02:00
parent ec3170ac95
commit d71c7892ac

View File

@ -99,12 +99,12 @@ int shred_main(int argc UNUSED_PARAM, char **argv)
bb_copyfd_size(zero_fd, fd, size); bb_copyfd_size(zero_fd, fd, size);
fdatasync(fd); fdatasync(fd);
} }
if (opt & OPT_u) {
ftruncate(fd, 0);
xunlink(fname);
}
xclose(fd);
} }
if (opt & OPT_u) {
ftruncate(fd, 0);
xunlink(fname);
}
xclose(fd);
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;