-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
smartfs: add partial support for FIOC_FILEPATH ioctl #13584
Conversation
I am not 100 % forcing this to be merged. It provides SmartFS with least partial support for inotify but does not handle correctly subdirectories and there is no way how to detect it at runtime and return error if subdirectory is present. On the other hand, there are both compile time and runtime warning describing this issue, so the user gets the memo. I would generally prefer to merge this, but I understand if it is rejected. I currently don't have time to dive into SmartFS properly and rewrite it to provide the full support, but maybe it will inspire someone to finish this. |
one simple method is that smartfs_open cache the path into smartfs_ofile_s. |
Yes, but can we afford it for smaller microcontrollers with less memory? The maximum path length is 4 KBs if I remember correctly, although yes, the entire length won't be used in 99 % cases. But I suppose that's why most of the file systems do not store the entire path and iterate backwards to get it. |
But if smartfs can't restore the full path from the leaf node like littlefs, the full path has to be record in open callback.
But in most case, the path is less than 128bytes. |
d3ceef2
to
8f615d8
Compare
Ok, then we can simplify this quite a lot. Updated to store the path during |
0a6aee4
to
ede98e3
Compare
ede98e3
to
ecfa50b
Compare
The FIOC_FILEPATH ioctl call is required if smartfs is to be used together with inotify monitoring system. This implements the call support to smartfs file system. The path to the file has to be stored in smartfs_ofile_s structure during file open (and is freed during close) as smartfs currently is not able to obtain the path knowing only the file node. The full path is concatenated with the file name and creates the full path needed for inotify to detect whether the file is on the watchlist. Signed-off-by: Michal Lenc <[email protected]>
ecfa50b
to
734dbb6
Compare
Summary
The
FIOC_FILEPATH
ioctl call is required if smartfs is to be used together with inotify monitoring system. This partially implements the call support to smartfs file system.The call currently does not work correctly if subdirectories are in the file's path. For example
/dir/file
will be returned correctly, but/dir/subdir/file
will exclude thesubdir
part and return only/dir/file
. The full support is complicated due to the SmartFS design.The correct procedure would be to take the inode's path obtained by inode_getpath and let SmartFS recursively get the full path from the file. However, SmartFS entries do not keep the information about their parents and it is not possible to obtain the full path by going backwards. The file system currently takes the advantage of knowing the full path during the node creation/remove/rename/etc and does the forward search with node by node string comparison.
This possible solution would require the introduction of parent field in the entry structure and going backwards to obtain the full path. This would mean the modification of SmartFS structures including the ones stored in the NOR flash, most likely causing the incompatibility with previous versions.
Impact
SmartFS now at least partially work with inotify for calls that do not have direct knowledge of the full file path.