更改 bash 中的 crtime
changing the crtime in bash
我想更改 bash 中的 crtime
属性。
首先,我尝试按照以下命令检查 crtime。
stat test
接下来,我更改了时间戳。
touch -t '200001010101.11' test
但是我意识到如果crtime
已经超过我写的日期,那么它就不能更改了。
所以我想知道如何指定crtime
即使它已经过去了。
编辑:
根据 This answer to a similar question,您可以使用 debugfs -w -R 'set_inode_field ...'
更改 inode 字段,尽管这确实需要卸载。
man debugfs
向我们展示了以下可用命令:
set_inode_field filespec field value
Modify the inode specified by filespec so that the inode field field has value value. The list of valid inode fields which can be set via this command can be displayed by using the command:
set_inode_field -l Also available as sif.
您可以尝试以下方法来验证 crtime 字段的索引节点号和名称:
stat -c %i test
debugfs -R 'stat <your-inode-number>' /dev/sdb1
另外 df -Th
以查找文件系统的 /dev
路径(例如 /dev/sdb1)
其次是:
umount /dev/sdb1
debugfs -w -R 'set_inode_field <your-inode-number> crtime 200001010101.11' /dev/sdb1
注意:在上述命令中,inode
数字必须用<>
括号表示,如图所示。此外,如 here 所述,可能需要使用 echo 2 > /proc/sys/vm/drop_caches
刷新 inode 缓存
原回答:
你可以试试 birthtime_touch
:
birthtime_touch
is a simple command line tool that works similar to
touch, but changes a file's creation time (its "birth time") instead
of its access and modification times.
来自 birthtime_touch Github page,其中还说明了为什么这不是一件容易完成的事情:
birthtime_touch
currently only runs on Mac OS X. The minimum required
version is Mac OS X 10.6. birthtime_touch
is known to work for files
that are stored on HFS+ and MS-DOS filesystems.
The main problem why birthtime_touch
does not work on all systems and
for all filesystems, is that not all filesystems store a file's
creation time, and for those that actually do store the creation time
there is no standardized API to access/change that information.
This page 详细说明了我们尚未看到对此功能的支持的原因。
除了这个工具之外,可能值得查看 Github 上的源代码以了解它是如何完成的以及它是否可以移植到 Unix/Linux。除此之外,我认为有必要编写低级代码来公开 crtime
将存储的文件系统的那些方面。
我想更改 bash 中的 crtime
属性。
首先,我尝试按照以下命令检查 crtime。
stat test
接下来,我更改了时间戳。
touch -t '200001010101.11' test
但是我意识到如果crtime
已经超过我写的日期,那么它就不能更改了。
所以我想知道如何指定crtime
即使它已经过去了。
编辑:
根据 This answer to a similar question,您可以使用 debugfs -w -R 'set_inode_field ...'
更改 inode 字段,尽管这确实需要卸载。
man debugfs
向我们展示了以下可用命令:
set_inode_field filespec field value
Modify the inode specified by filespec so that the inode field field has value value. The list of valid inode fields which can be set via this command can be displayed by using the command: set_inode_field -l Also available as sif.
您可以尝试以下方法来验证 crtime 字段的索引节点号和名称:
stat -c %i test
debugfs -R 'stat <your-inode-number>' /dev/sdb1
另外 df -Th
以查找文件系统的 /dev
路径(例如 /dev/sdb1)
其次是:
umount /dev/sdb1
debugfs -w -R 'set_inode_field <your-inode-number> crtime 200001010101.11' /dev/sdb1
注意:在上述命令中,inode
数字必须用<>
括号表示,如图所示。此外,如 here 所述,可能需要使用 echo 2 > /proc/sys/vm/drop_caches
原回答:
你可以试试 birthtime_touch
:
birthtime_touch
is a simple command line tool that works similar to touch, but changes a file's creation time (its "birth time") instead of its access and modification times.
来自 birthtime_touch Github page,其中还说明了为什么这不是一件容易完成的事情:
birthtime_touch
currently only runs on Mac OS X. The minimum required version is Mac OS X 10.6.birthtime_touch
is known to work for files that are stored on HFS+ and MS-DOS filesystems.The main problem why
birthtime_touch
does not work on all systems and for all filesystems, is that not all filesystems store a file's creation time, and for those that actually do store the creation time there is no standardized API to access/change that information.
This page 详细说明了我们尚未看到对此功能的支持的原因。
除了这个工具之外,可能值得查看 Github 上的源代码以了解它是如何完成的以及它是否可以移植到 Unix/Linux。除此之外,我认为有必要编写低级代码来公开 crtime
将存储的文件系统的那些方面。