【发布时间】:2021-11-29 15:34:58
【问题描述】:
我正在尝试删除或取消链接文件。取消链接意味着删除,我认为(从我所读到的)。
我读过documentation 和另一个documentation。他们都说取消链接需要1个参数。 const char * pathname.
我已经这样做了,但是我要删除的文件没有被删除。有谁知道为什么?这是我的代码:
global start
section .text
start:
;This is the deleting/unlinking part
mov rax, 0x2000010; unlinking
mov rdi, file ; contains path and the file. If you look down more in section .data you can see the file and path
syscall
;This part is not important: Its just exiting
mov rax, 0x2000001 ;Exiting
xor rdi, rdi
syscall
section .data
file: db "/Users/daniel.yoffe/desktop/assembly/CoolFile.txt", 0
我还查看了 linux 中的一个示例。就是这样。有什么我做错了吗?取消链接甚至会删除文件吗?我是否遗漏了什么可能是另一个论点?
我们将不胜感激。
【问题讨论】:
-
是的,取消链接会删除文件。检查你得到什么错误代码。使用您的系统调用跟踪器。
-
@Jester 没有错误。
-
您能否在问题中包含 dtruss 输出?
-
@Yoffdan 你怎么知道?你甚至都不检查是否有一个。
-
@Yoffdan: stackoverflow.com/questions/31045575/…
标签: macos assembly x86-64 nasm system-calls