tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Is there a command to change btime (creation time of files)?
Good day,
I am using NetBSD 9.2 (amd64) with ZFS as file system and I have not found a command to change btime for my files. When I type stat command I see an entry called "Birth", I want to change the value under "Birth".
stat -f "atime: %Sa%nmtime: %Sm%nBirth (btime): %SB" /123.txt
atime: Jun 19 07:29:04 2020
mtime: Jun 19 07:29:04 2020
Birth (btime): Jan 01 00:00:00 1970
touch command (touch -a -m -t [[CC]YY]MMDDhhmm[.ss] 123.text) unfortunately only supports changing the mtime and atime. Is there a command under NetBSD to change btime? If not can a command be added?
I want to change btime because as you can see a lot of my .txt files got corrupted during a system change to NetBSD and now I need to manually change my btime timestamps but I haven't found a command.
It seems that Unix systems in general do not have a command for this to correct corrupt or damaged btime timestamps.
A suggestion would be to add a special command (e.g. SetTime -b) for NetBSD so that users get permission from the kernel to change btime. It should be made so that only in kernel mode there is the possibility to change btime. The btime can be set as you like it has no effect with the other timestamps.
An example of exactly what I mean when I do it in Terminal.
SetTime -b [[CC]YY]MMDDhhmm[.ss] 123.text
stat -f "atime: %Sa%nmtime: %Sm%nBirth (btime): %SB" /123.txt
atime: Jun 19 07:29:04 2020
mtime: Jun 19 07:29:04 2020
Birth (btime): Jun 28 17:04:37 2019
What would happen if by mistake btime has a higher value than atime and mtime? Also no problem, it should be generally integrated a note that the value is higher than the other values (atime and mtime), so the user can know that he should pay attention to the other values and if necessary make btime lower.
An example (in this case I set the year 2030)
SetTime -b [[CC]YY]MMDDhhmm[.ss] 123.text
Note: btime has a higher value than atime and mtime
stat -f "atime: %Sa%nmtime: %Sm%nBirth (btime): %SB" /123.txt
atime: Jun 19 07:29:04 2020
mtime: Jun 19 07:29:04 2020
Birth (btime): Jan 1 00:00:00 2030
Home |
Main Index |
Thread Index |
Old Index