hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
705 stars 179 forks source link

ChangeTime only updated when modifing LastWriteTime #799

Closed henka-rl closed 11 months ago

henka-rl commented 11 months ago

I'm trying to modify ChangeTime on a file, but I can't get it to work. Just modify ChangeTime in FileBasicInformation leaves ChangeTime unmodified. However, I found (by playing around) that modifying LastWriteTime instead of ChangeTime modifies both LastWriteTime and ChangeTime.

I've put together a project with two test cases. modifyChangeTime() that just modifies ChangeTime which fails and modifyChangeTimeByLastWriteTime() which succeeds. https://github.com/henka-rl/smbj-changetime

Is this how it's supposed to work?

hierynomus commented 11 months ago

There's nothing in the MS-SMB2 spec detailing how this is supposed to work. I'd guess that at worst this is server specific. OTOH, I guess the behaviour you're seeing makes sense. Updating any property of the file will touch the ChangeTime. Except for touching the ChangeTime itself, because nothing got changed then! Also it will prevent you from setting the ChangeTime to something in the past, which would mess with all kinds of systems that rely on that attribute.

At least this is nothing that SMBJ controls, so I'm closing out the issue.