- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在 linux 上,ext4 分区上有一部电影,如果我打开电影并观看它,然后我移动或重命名电影。
在之前的缓存用完后,它需要从原始文件中读取更多的缓存,然后它仍然可以这样做。
问题是:
文件系统和 inode 是如何实现的?
最佳答案
使用 rename()
在同一文件系统中的文件上只是更改指向 inode 的名称。您甚至可以使用 rename()
将该名称移动到另一个目录中 - 只要它在同一文件系统中:
The rename() function shall change the name of a file. The old argument points to the pathname of the file to be renamed. The new argument points to the new pathname of the file. ...
请注意 rename()
的 POSIX 规范比 C 标准 rename()
规范更具体:
7.21.4.2 The
rename
functionSynopsis
#include <stdio.h>
int rename(const char *old, const char *new);Description
The rename function causes the file whose name is the string pointed to by
old
to be henceforth known by the name given by the string pointed to bynew
. The file namedold
is no longer accessible by that name. If a file named by the string pointed to bynew
exists prior to the call to therename
function, the behavior is implementation-defined.Returns
The
rename
function returns zero if the operation succeeds, nonzero if it fails, 269) in which case if the file existed previously it is still known by its original name.
(这是 rename()
的完整 C 标准规范。阅读 POSIX link 了解更多信息。)
那么如何在应用程序中观看文件时重命名文件呢?您的电影观看进程的打开文件描述符用于访问您刚刚 rename()
的文件的底层 inode 不会改变。
这就是为什么你可以 unlink()
的原因。 (删除)正在使用的文件 - 您所做的只是删除指向 inode 的条目 - 链接 到 inode 之一。文件使用的空间直到删除指向 inode 的 last 链接后才会释放 - 并且打开的文件描述符算作一个链接。这也是为什么删除文件目录条目的函数称为 unlink()
- 这就是它所做的全部。是的,一个文件( inode )可以有多个指向它的链接。
关于linux - inode - 移动一个已经打开的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34904412/
我可以查看 linux 内核的 inode 结构中的哪些值来判断我当前正在查看的 inode 是目录还是常规文件? 我已经搜索了 inode 但似乎真的找不到一个看起来像我想要的成员,因为我使用的是旧
我试图了解 inode 位图和 inode 表之间的区别(来自 ext2 文件系统文档),但我不明白。谁能解释一下? 最佳答案 位图只占一个 block ,是一个0和1的序列,其中0表示对应的inod
我们使用 Amazon EBS 在 3 级目录结构中存储大量小文件 (<10KB)。 ~/lists# df -hFilesystem Size Used Avail Use
我正在创建一个简单的 debugfs里面的文件/sys/kernel/debug/test/testFile使用以下代码: pDebugfs = debugfs_create_dir(name, NU
我的 VPS (CentOS 6.3.8.13 Parallels Plesk Panel) 已达到 inodes 限制: [root@vps21157 tmp]# df -i Filesystem
我阅读了 minix 的 API,但仍然感到困惑,无法仅通过 inode 编号获得“真正的”inode 结构 我们只能用“stat”结构得到“inode number”,对吧?但是得到这个数字后,有没
我发现在大多数情况下,i_data 只是 i_mapping 的解引用数据,如下所示,为什么在一个 inode 结构中设置两个相同的值? crash> struct inode ffffffc073c
我想知道为什么以下代码无法工作: public static List cloneList(List list) { List result = new ArrayList(list.siz
我需要用 C/C++ 编写一个程序,要求用户输入一个 inode 编号,然后返回所有 inode header 字段和信息。我对linux系统和命令一点都不熟悉。我找到了一些命令并尝试了不同的东西,但
由于我们的文件系统实现仅将 inode 存储在内存中,因此我们不想浪费更多的 inode 缓存。 在VFS下,我们计划不将新的inode添加到inode cache hash talbe中,也不将其添
代码是: void ext2_read_inode (struct inode * inode) { struct buffer_head * bh; struct ext2_inod
根据 struct ext4_inode { ..... __le16 i_extra_isize; ..... } 鉴于我使用的 inode 大小 = 256 字节,我看到这可以用于存
我正在阅读有关第 6 版 unix 的文章,并且刚刚了解了 inode。我有以下问题: 假设我在一个目录中有一个文件,并且在其他地方有一个指向该文件的链接。我是否正确地说,如果我删除文件,inode
我了解文件描述符是用于识别文件的内核句柄,而文件的 inode 编号是指向具有有关文件的其他详细信息的结构的指针(如果我错了,请纠正我)。但我无法区分它们。 最佳答案 根本区别在于,inode 代表文
Linux 上的 inode 限制是按子目录还是按整个文件系统?我使用 ububtu 64 位服务器 9.10。 如果是目录限制,是否可以通过将文件拆分为多个子目录来解决 inode 限制? 最佳答案
我知道unix系统中的文件是由它们的inode来表示的。 作为用户,我可以访问这些值并更改它们吗? 也就是说,替换两个相邻 block 之间的值,这样就改变了文件? 我可以只覆盖中间的一个 block
因此,我的托管服务对我的服务器( inode )上的 INODES 有限制。每个目录/文件 = 1 个 INODE。这可能是将来的一个问题,因为我想在我的网站中实现文件共享。理论上我不能将文件数据存储
在 linux 上,ext4 分区上有一部电影,如果我打开电影并观看它,然后我移动或重命名电影。 在之前的缓存用完后,它需要从原始文件中读取更多的缓存,然后它仍然可以这样做。 问题是: 文件系统和 i
有人可以告诉我如何计算目录中文件的 inode 数量吗? 谢谢。 最佳答案 有一个inode每个目录,其中的每个文件一个。如果您对文件进行符号链接(symbolic link),则符号链接(symbo
我最近了解了 Unix inode 及其用途。特别是,我了解到 an.inode 在文件系统中是唯一的。 我的问题是:如果用户将 Micro SD 卡插入他们的 Android 设备,该卡会成为现
我是一名优秀的程序员,十分优秀!