在Mac VFS/HFS +中可以进行原子重命名吗? [英] Is an atomic-rename possible in Mac VFS/HFS+?
问题描述
Mac OS X支持ACL,因此可以将文件声明为可写但不可删除.
With support for ACLs in Mac OS X, there is a way to declare a file as writeable but non-deletable.
由于 NSArray的writeToFile:atomically:
)将失败,而非原子写入将很成功
This poses a problem with atomic writes, since the current implementation of rename
in VFS delete
s a pre-existing target. If you have an existing file, which you have write privileges on, it is possible to be unable to atomically write to:
Simply attach an ACL that states deny delete
and an atomic write (like implemented by various Cocoa APIs — e.g. NSArray's writeToFile:atomically:
) will fail, while a non-atomic write will happily succeed.
由于我对底层C代码的理解相当有限:
仅发生轻微(插入您最喜欢的轻微"定义)头痛的替代实施方案是否可行?
Since my understanding of low-level C code is fairly limited:
Is an alternative implementation feasible with only minor (insert your favorite definition of "minor") headaches?
谢谢
丹尼尔
推荐答案
一个可行的选择似乎是在一个临时目录中创建文件,然后在这两个文件上调用exchangedata
. HFS导出VOL_CAP_INT_EXCHANGEDATA
属性,因此应该可以正常工作. vfs_syscalls.c中的相关检查表明,只有调用权限才能成功调用.
A viable alternative would seem to create the file in a temporary directory, then call exchangedata
on both files. HFS exports the VOL_CAP_INT_EXCHANGEDATA
attribute, so that should work. The relevant checks in vfs_syscalls.c indicate that only read and write permissions are necessary for the call to succeed.
这篇关于在Mac VFS/HFS +中可以进行原子重命名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!