Skip to content

Commit

Permalink
Fix minor filesystem bugs (#2563)
Browse files Browse the repository at this point in the history
- Fix return value from Spiffs `fenumxattr()`: Should return number of attributes read.
- Fix LittleFS `FileSystem::format()` return value: int not bool
- Remove (non-const) `Device::partitions()` method: Partition table is always accessed read-only
- Remove `Partition::getDevice()` method: Could be used to bypass protections offered by partitioning API
- Fix `IFS::Stat::printTo()` timestamp printing: Shows numeric (time_t) value instead of string
  • Loading branch information
mikee47 authored Oct 1, 2022
1 parent 8013fff commit abbdbbf
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Sming/Components/IFS
Submodule IFS updated 1 files
+1 −1 src/Stat.cpp
5 changes: 0 additions & 5 deletions Sming/Components/Storage/src/include/Storage/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ class Device : public LinkedObjectTemplate<Device>
return getName() == name;
}

PartitionTable& partitions()
{
return mPartitions;
}

const PartitionTable& partitions() const
{
return mPartitions;
Expand Down
9 changes: 0 additions & 9 deletions Sming/Components/Storage/src/include/Storage/Partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,6 @@ class Partition
*/
String getDeviceName() const;

/**
* @brief Get storage device containing this partition
* @retval Device* null if device isn't registered
*/
Device* getDevice() const
{
return mDevice;
}

/**
* @brief Determine if given address contained within this partition
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PartitionTable
/**
* @brief Find the n'th OTA partition
*/
Partition findOta(uint8_t index)
Partition findOta(uint8_t index) const
{
using App = Partition::SubType::App;
auto subtype = App(uint8_t(App::ota0) + index);
Expand Down
2 changes: 1 addition & 1 deletion Sming/Libraries/LittleFS
Submodule LittleFS updated 1 files
+1 −1 src/FileSystem.cpp
2 changes: 2 additions & 0 deletions Sming/Libraries/Spiffs/src/FileMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ int SpiffsMetaBuffer::enumxattr(AttributeEnumCallback callback, void* buffer, si
continue;
}
e.set(tag, value, getAttributeSize(tag));
++count;
if(!callback(e)) {
return count;
}
Expand All @@ -72,6 +73,7 @@ int SpiffsMetaBuffer::enumxattr(AttributeEnumCallback callback, void* buffer, si
break;
}
e.set(AttributeTag(unsigned(AttributeTag::User) + tagIndex), &user[i], tagSize);
++count;
if(!callback(e)) {
break;
}
Expand Down

0 comments on commit abbdbbf

Please sign in to comment.