Linux中可用于删除文件的系统调用 [英] System calls in Linux that can be used to delete files
问题描述
在Linux上可以用来删除文件的系统调用是什么?我指的不是libc-wrapper使用的系统调用(依次由命令行工具使用)。
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).
除了 unlink
和 unlinkat
可以用来删除Linux计算机上文件的系统调用是什么?
Other than unlink
and unlinkat
what are the system calls that could be used to delete files on a Linux machine?
推荐答案
rename()
和 renameat()
可以通过在文件上重命名另一个文件来删除文件。
rename()
and renameat()
can be used to delete a file by renaming another file over it.
如果您考虑将文件清空为删除的一种形式,则各种系统调用,包括 truncate()
和 open()
和 O_TRUNC
都可以
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.
这篇关于Linux中可用于删除文件的系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!