System calls in Linux that can be used to delete f

2019-09-08 12:32发布

问题:

What are the system calls that can be used to delete a file on Linux? I am not referring to just the system calls used by the libc-wrapper(which in-turn are used by command line tools).

Other than unlink and unlinkat what are the system calls that could be used to delete files on a Linux machine?

回答1:

rename() and renameat() can be used to delete a file by renaming another file over it.

If you consider making a file empty to be a form of deletion, a variety of system calls, including truncate() and open() with O_TRUNC, can do that.