Skip to content

Commit 869f066

Browse files
committed
LittleFS: set create/modified FS times on format
1 parent f9bd73c commit 869f066

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

libraries/LittleFS/src/LittleFS.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,26 @@ class LittleFSImpl : public FSImpl
221221
return false;
222222
}
223223

224+
if(_timeCallback && _tryMount()) {
225+
// Mounting is required to set attributes
226+
227+
time_t t = _timeCallback();
228+
rc = lfs_setattr(&_lfs, "/", 'c', &t, 8);
229+
if (rc != 0) {
230+
DEBUGV("lfs_format, lfs_setattr 'c': rc=%d\n", rc);
231+
return false;
232+
}
233+
234+
rc = lfs_setattr(&_lfs, "/", 't', &t, 8);
235+
if (rc != 0) {
236+
DEBUGV("lfs_format, lfs_setattr 't': rc=%d\n", rc);
237+
return false;
238+
}
239+
240+
lfs_unmount(&_lfs);
241+
_mounted = false;
242+
}
243+
224244
if (wasMounted) {
225245
return _tryMount();
226246
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy