在Android中创建硬链接和符号链接 [英] Creating Hardlinks and Symlinks in Android

查看:83
本文介绍了在Android中创建硬链接和符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用,希望在其中使用Android外部存储器文件系统中的硬链接和符号链接.我已经尝试过使用命令

I am creating an app in which I would like to make use of hardlinks and symlinks in the Android external memory filesystem. I have tried using the commands

Os.link("oldpath", "newpath");
Os.link("oldpath", "newpath");

但是,当我尝试此操作时,出现此错误:

However, when I try this, I get this error:

link failed: EPERM (Operation not permitted)

这使我认为您需要root用户访问权限,尽管我看到其他人也做同样的事情,并且我认为如果他们需要root用户,他们不会拥有这些命令.有什么想法吗?

This makes me think that you need root access, although I have seen other people do this same thing, and I would not think that they would have these commands if they needed root. Any ideas?

推荐答案

对Os.link的调用失败,因为Android默认将FAT32文件系统用于外部存储.FAT32文件系统不支持硬链接和软链接,这就是为什么您收到操作不允许错误的原因.

Call to Os.link is failing because Android uses FAT32 file system by default for external storage. FAT32 file system does not support hard links and soft links that is why you are getting operation not permitted error.

EPERM 包含oldpath和newpath的文件系统不支持硬链接的创建.

EPERM The filesystem containing oldpath and newpath does not support the creation of hard links.

您可以阅读有关 link 系统调用

You can read more information about link system call here

此外,您不能准确地伪造​​FAT32上的硬链接或软链接.另外请注意,在Android中创建硬链接需要root权限.

Furthermore you cannot fake hard links or soft links on FAT32 accurately. And also note that for creating hard link in Android requires root permission.

这篇关于在Android中创建硬链接和符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆