Post Reply 
newRPL: [UPDATED April 27-2017] Firmware for testing available for download
08-14-2016, 02:14 AM
Post: #377
RE: newRPL: [UPDATED July-25-16] Firmware for testing available for download
(08-02-2016 07:14 PM)Claudio L. Wrote:  
(08-01-2016 01:31 AM)matthiaspaul Wrote:  // mainentry[12] = file->NTRes;
mainentry[13] = file->CrtTmTenth;
WriteInt32(mainentry+14, file->CreatTimeDate);
WriteInt16(mainentry+18, file->LastAccDate);
[...]
For some reasons, restoring the original value of the NTRes byte was commented out here. This byte is used for various purposes. It is important that the implementation does not change the contents of bits 7-5 and 2-0. It may change bits 3 and 4 when dealing with LFNs, and it may clear all bits when creating a new file. However, in an already existing file, the bits must not be changed.
That's exactly the reason why it's commented out: the bits must not be changed. This function does read-modify-write on an existing entry, only to update the size, date, etc. when you close the file, and it only modifies what needs to be modified, then writes back.
I have another question regarding this section: If NTRes is commented out because it doesn't change (except for possibly bits 4-3 during a file rename), does this imply that CreatTimeDate and CrtTmTenth do change here (they shouldn't unless during file creation)?

I could probably answer that question myself by digging deeper into the call hierarchy of your code, but as I haven't found the time for that so far and since you wrote that this piece of code is just used to modify existing entries (not to initialize new ones), setting the create date/time seems unnecessary as well here. Reinitializing with the same values read when opening the file would not cause any problems (just be redundant), but if the create date/time would be calculated afresh and applied to an already existing entry, this would not only undermine the very purpose of a create date/time stamp, but also overwrite some alternative data possibly residing at this location - which could cause problems elsewhere. So, this might be worth another close look.

Greetings,

Matthias


--
"Programs are poems for computers."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL: [UPDATED July-25-16] Firmware for testing available for download - matthiaspaul - 08-14-2016 02:14 AM



User(s) browsing this thread: 2 Guest(s)