Skip to content

Commit 2a73651

Browse files
BREAKING: Remove FS::info64, make FS::info 64-bit (#2335)
Removed FS::info64, and updates FS::info with the 64-bit version since in 2024 it's almost impossible to get a SD card smaller than 4GB. Most code can simply replace info64 with info and continue operation, if they were updated to be 64-bit in the first place.
1 parent bd64b97 commit 2a73651

File tree

9 files changed

+12
-77
lines changed

9 files changed

+12
-77
lines changed

cores/rp2040/FS.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,6 @@ bool FS::info(FSInfo& info) {
366366
return _impl->info(info);
367367
}
368368

369-
bool FS::info64(FSInfo64& info) {
370-
if (!_impl) {
371-
return false;
372-
}
373-
return _impl->info64(info);
374-
}
375-
376369
File FS::open(const String& path, const char* mode) {
377370
return open(path.c_str(), mode);
378371
}

cores/rp2040/FS.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,8 @@ class Dir {
152152
time_t (*_timeCallback)(void) = nullptr;
153153
};
154154

155-
// Backwards compatible, <4GB filesystem usage
156-
struct FSInfo {
157-
size_t totalBytes;
158-
size_t usedBytes;
159-
size_t blockSize;
160-
size_t pageSize;
161-
size_t maxOpenFiles;
162-
size_t maxPathLength;
163-
};
164-
165155
// Support > 4GB filesystems (SD, etc.)
166-
struct FSInfo64 {
156+
struct FSInfo {
167157
uint64_t totalBytes;
168158
uint64_t usedBytes;
169159
size_t blockSize;
@@ -172,7 +162,6 @@ struct FSInfo64 {
172162
size_t maxPathLength;
173163
};
174164

175-
176165
class FSConfig {
177166
public:
178167
static constexpr uint32_t FSId = 0x00000000;
@@ -201,7 +190,6 @@ class FS {
201190

202191
bool format();
203192
bool info(FSInfo& info);
204-
bool info64(FSInfo64& info);
205193

206194
File open(const char* path, const char* mode);
207195
File open(const String& path, const char* mode);

cores/rp2040/FSImpl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ class FSImpl {
119119
virtual void end() = 0;
120120
virtual bool format() = 0;
121121
virtual bool info(FSInfo& info) = 0;
122-
virtual bool info64(FSInfo64& info) = 0;
123122
virtual FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) = 0;
124123
virtual bool exists(const char* path) = 0;
125124
virtual DirImplPtr openDir(const char* path) = 0;

libraries/FatFS/src/FatFS.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class FatFSImpl : public FSImpl {
8888
return _mounted ? (FR_OK == f_rename(pathFrom, pathTo)) : false;
8989
}
9090

91-
bool info64(FSInfo64& info) override {
91+
bool info(FSInfo& info) override {
9292
if (!_mounted) {
9393
DEBUGV("FatFS::info: FS not mounted\n");
9494
return false;
@@ -105,20 +105,6 @@ class FatFSImpl : public FSImpl {
105105
return true;
106106
}
107107

108-
bool info(FSInfo& info) override {
109-
FSInfo64 i;
110-
if (!info64(i)) {
111-
return false;
112-
}
113-
info.blockSize = i.blockSize;
114-
info.pageSize = i.pageSize;
115-
info.maxOpenFiles = i.maxOpenFiles;
116-
info.maxPathLength = i.maxPathLength;
117-
info.totalBytes = (size_t)i.totalBytes;
118-
info.usedBytes = (size_t)i.usedBytes;
119-
return true;
120-
}
121-
122108
bool remove(const char* path) override {
123109
return _mounted ? (FR_OK == f_unlink(path)) : false;
124110
}

libraries/HTTPUpdateServer/src/HTTPUpdateServer-impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ void HTTPUpdateServerTemplate<ServerType, ServerPort>::setup(WebServerTemplate<S
139139
}
140140
}
141141
} else {
142-
FSInfo64 i;
142+
FSInfo i;
143143
LittleFS.begin();
144-
LittleFS.info64(i);
144+
LittleFS.info(i);
145145
uint32_t maxSketchSpace = i.totalBytes - i.usedBytes;
146146
if (!Update.begin(maxSketchSpace, U_FLASH)) { //start with max available size
147147
_setUpdaterError();

libraries/LittleFS/src/LittleFS.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,6 @@ class LittleFSImpl : public FSImpl {
115115
return true;
116116
}
117117

118-
virtual bool info64(FSInfo64& info64) {
119-
FSInfo i;
120-
if (!info(i)) {
121-
return false;
122-
}
123-
info64.blockSize = i.blockSize;
124-
info64.pageSize = i.pageSize;
125-
info64.maxOpenFiles = i.maxOpenFiles;
126-
info64.maxPathLength = i.maxPathLength;
127-
info64.totalBytes = i.totalBytes;
128-
info64.usedBytes = i.usedBytes;
129-
return true;
130-
}
131-
132118
bool remove(const char* path) override {
133119
if (!_mounted || !path || !path[0]) {
134120
return false;

libraries/SDFS/src/SDFS.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class SDFSImpl : public FSImpl {
9292
return _mounted ? _fs.rename(pathFrom, pathTo) : false;
9393
}
9494

95-
bool info64(FSInfo64& info) override {
95+
bool info(FSInfo& info) override {
9696
if (!_mounted) {
9797
DEBUGV("SDFS::info: FS not mounted\n");
9898
return false;
@@ -106,26 +106,6 @@ class SDFSImpl : public FSImpl {
106106
return true;
107107
}
108108

109-
bool info(FSInfo& info) override {
110-
FSInfo64 i;
111-
if (!info64(i)) {
112-
return false;
113-
}
114-
info.blockSize = i.blockSize;
115-
info.pageSize = i.pageSize;
116-
info.maxOpenFiles = i.maxOpenFiles;
117-
info.maxPathLength = i.maxPathLength;
118-
#ifdef DEBUG_RP2040_PORT
119-
if (i.totalBytes > std::numeric_limits<uint32_t>::max()) {
120-
// This catches both total and used cases, since used must always be < total.
121-
DEBUG_RP2040_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld >= 4GB). Please update source to use info64().\n"), (long long)i.totalBytes);
122-
}
123-
#endif
124-
info.totalBytes = (size_t)i.totalBytes;
125-
info.usedBytes = (size_t)i.usedBytes;
126-
return true;
127-
}
128-
129109
bool remove(const char* path) override {
130110
return _mounted ? _fs.remove(path) : false;
131111
}

libraries/WebServer/examples/FSBrowser/FSBrowser.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ void handleStatus() {
154154
if (fsOK) {
155155
fileSystem->info(fs_info);
156156
json += F("\"true\", \"totalBytes\":\"");
157-
json += fs_info.totalBytes;
157+
char b64[32];
158+
sprintf(b64, "%llu", fs_info.totalBytes);
159+
json += b64;
158160
json += F("\", \"usedBytes\":\"");
159-
json += fs_info.usedBytes;
161+
sprintf(b64, "%llu", fs_info.usedBytes);
162+
json += b64;
160163
json += "\"";
161164
} else {
162165
json += "\"false\"";

libraries/WebServer/examples/WebUpdate/WebUpdate.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ void setup(void) {
4343
if (upload.status == UPLOAD_FILE_START) {
4444
WiFiUDP::stopAll();
4545
Serial.printf("Update: %s\n", upload.filename.c_str());
46-
FSInfo64 i;
46+
FSInfo i;
4747
LittleFS.begin();
48-
LittleFS.info64(i);
48+
LittleFS.info(i);
4949
uint32_t maxSketchSpace = i.totalBytes - i.usedBytes;
5050
if (!Update.begin(maxSketchSpace)) { // start with max available size
5151
Update.printError(Serial);

0 commit comments

Comments
 (0)