LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   Does debugfs with set_inode_field for timestamps work? (https://www.linuxquestions.org/questions/ubuntu-63/does-debugfs-with-set_inode_field-for-timestamps-work-4175732686/)

maybeJosiah 01-11-2024 08:12 PM

Does debugfs with set_inode_field for timestamps work?
 
For created at:
sudo debugfs -w -R 'set_inode_field <'$inode'> crtime '$formatted_time'' "$device"
Also like this for changed at time:
sudo debugfs -w -R 'set_inode_field <'$inode'> ctime '$formatted_time'' "$device"

Like my source is man debugfs and zzzcode.ai. Latter was unsure whether to include <> but man debugfs clears that up. These are Ubuntu commands. Use on a bootable USB for main drive if ever on main drive. From what I remember stat may be used for $inode. What I am trying for is if, for record, this actually works.

I saw a thing on Linux and Unix Stack Exchange someone did in fact set crtime with a hi and lo. https://unix.stackexchange.com/quest...4fs-filesystem
What I try for is a program that uses a file to set all timestamps that can be set like originals from a backup. I already have a recorder and a reader that maybe sets timestamps. I would be using Bash. All I need to know is if I can set created at time and changed at time with debugfs. If there is a way I may accept that answer. Test it before saying there is a way. I do not have a full backup yet so I can't do it like myself. Maybe a blank computer with Ubuntu freshly installed would be a good thing for testing. Try to lose nothing and be careful. From what I can tell format for time is Seconds.nanos like some big number of seconds, a ., nanos. This can mess up your system so be careful. Maybe read "man debugfs" for details before testing this.

From what I underatand -w means use in read write mode, -R means execute one command and exit (needed for in Bash) that in quotes is command, set_inode_field is like it states, filespec, either <inode> or file path, comes next, which field, ctime for changed at or crtime for created at, is next, next is to set it to formatted, out of quotes, next is device that is with files to set, like /dev/sda1 but should not be that with safer usage. Just can debugfs set created at and changed at and maybe some how to answer. I already saw another question that could use an answer to this.
https://www.linuxquestions.org/quest...t4-4175625229/
X E.

maybeJosiah 01-12-2024 09:08 AM

Many debugfs commands take a filespec as an argument to specify an inode (as opposed to a pathname) in the filesystem which is currently opened by debugfs. The filespec argument may be specified in two forms. The first form is an inode number surrounded by angle brackets, e.g., <2>. The second form is a pathname; if the pathname is prefixed by a forward slash ('/'), then it is interpreted relative to the root of the filesystem which is currently opened by debugfs. If not, the pathname is interpreted relative to the current working directory as maintained by debugfs. This may be modified by using the debugfs command cd.

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

https://linux.die.net/man/8/debugfs
That from man debugfs. Still no official word in that what format timestamps should be in. If you try set_inode_field -l it should show more and if you try, post results please. I can't find more information. If it helps I am trying to set date with nanos and although it has been wrong before you may use zzzcode.ai. Note for relative path to current directory omit first /. All else is like inside debugfs. Also, use file paths for this. Be careful where you are like with cd.

https://zzzcode.ai/answer-question?i...2-3e96c61a1703
I am trying to set times to nanosecond precision and maybe this helps. X E.

maybeJosiah 01-12-2024 10:31 AM

There is no more information out there so I contacted author of debugfs. X E.

maybeJosiah 01-13-2024 01:03 PM

https://www.linuxquestions.org/quest...530/page2.html
Yes it can be done and this is tested by Petri Kaukasoina. Thank you. X E.


All times are GMT -5. The time now is 02:25 AM.