Conversation
|
Strong "no" to the use of errno. |
sys/fs/fs.c
Outdated
There was a problem hiding this comment.
Superfluous. The variable is auto initialized with zeroes.
|
What's wrong with errno? |
sys/include/fs.h
Outdated
There was a problem hiding this comment.
I see no advantage in having this as a static inline instead of a regular function.
There was a problem hiding this comment.
I thought that all of them will be just wrappers of two function calls, this might save memory.
There was a problem hiding this comment.
Actually I don't think that this will safe memory, on the contrary. The static inline function is quite big, as it employs to function calls.
There was a problem hiding this comment.
Yes, but it goes into the ROM, rather than the RAM, and on most devices ROM >> RAM.
There was a problem hiding this comment.
(On the contrary: a non-inline function would build up RAM space through its parameters)
There was a problem hiding this comment.
I think the static inline function will neither safe RAM nor ROM. :)
|
errno is not thread safe / reentrant. |
|
Does it have to here? |
|
There is virtually no advantage in setting errno since it is not reentrant. All reads to the variable are spurious. |
sys/include/fs.h
Outdated
There was a problem hiding this comment.
Where did you find this list? Fuse?
|
At many lines the semicola are missing. |
|
I like the idea, and think that we will need FS support (and SD card support for MSB-A2) and a proper VFS. |
|
There is SD card support for the MSB-A2. |
|
@Kijewski regarding errno: better this way? |
|
Squashed and rebased to master |
|
@authmillenon, yes, I like using the return code. 👍 |
sys/fs/fs.c
Outdated
There was a problem hiding this comment.
It's not necessary to use strncmp. strcmp (without n) will do the work.
There was a problem hiding this comment.
Confirmed.
Also, please use strcmp with != 0, because it's not quite a boolean value.
There was a problem hiding this comment.
Well the idea is to only compare up to the length of the mount point's path. As far as I understand it strcmp() would yield < 0 if I compare for example fs_table[i].mount_point == "/mnt" with path == "/mnt/where/ever/files/go". But about != 0 you are right
There was a problem hiding this comment.
(But it should be == 0 to be equivalent to !strncmp ;-))
There was a problem hiding this comment.
I miss understood the function. In that case of course strncmp() :-).
sys/fs/fs.c
Outdated
There was a problem hiding this comment.
Right now you are looking for the last match. This could be easified by reverse iterating the list and exiting eagerly.
But don't you have to find the longest prefix?
And maybe the mount point could memoize it's strlen?
There was a problem hiding this comment.
Yes I search for the longest prefix. You are right, I have to save the length, too :/
There was a problem hiding this comment.
Maybe an all-on-one solution?
size_t is_prefix_len(const char *restrict prefix, const char *restrict str)
{
size_t len = 0;
while (1) {
if (!*prefix) {
return len;
}
else if (*prefix != *str) {
return 0;
}
else {
++prefix;
++str;
++len;
}
}
}|
@kaspar030 FatFS is a full library for FAT for embedded systems. We don't need to do anything, exept providing an interface ;-) |
|
@gebart I guess OT: |
|
@authmillenon FatFS as a pkg sounds like a good solution. btw, do any of the RIOT boards have an implementation for SDHC so far? |
|
The msba2 has at least a microSD slot, but I don't now if it is SDHC or just SD and if a driver implementation for this exists. Maybe @OlegHahm can shed some light on this. |
|
@authmillenon I meant SD host controller interface, sorry about the unclear acronym. |
|
I do not have any time to work on this at the moment either, maybe I will adopt this later when things clear up, but for now this one may be up for grabs. |
|
👍 |
|
@x3ro started also to think/work about a file system for RIOT. Maybe he can join the discussion. |
|
Thanks for the ping @waehlisch :) My plan is to be working on bringing SDHC and filesystem support to RIOT over the next couple of months as part of my masters thesis. @authmillenon Would it be an option for me to adopt this PR?
As far as I know there is no such driver. I played with the msba2 at the last Hack&Ack to see if I can talk to the SD card but have so far been unsuccessful. |
@x3ro, of course. GitHub has no feature however to just let me give it to you. You have to check out my corresponding branch and open your own PR with it. Then we can close this one. |
Why should this be a problem? AFAIK it shouldn't be a problem to include BSD/MIT/... code into a (L)GPL project - but of course not via versa.
ccn-lite is also a non-package stemming from an external source - and currently it seems to me that this was a bad idea (although it looked wise back when the decision was originally made). Hence, I would also vote for "packaging" wherever possible.
I used to work with micro SDHC cards on the MSB-A2 and RIOT (though it was still named µkleos back then) about three years ago, which worked more or less fine (see also #127). However, I haven't tested for a looong time. |
I am sorry, I did not think this through before I wrote it. You are right, AFAIK we are allowed to use BSD sources within an LGPL project such as this. I also found this document regarding different open source licenses and their interoperability: http://wiki.osdev.org/Licensing @authmillenon , @OlegHahm What would be a reasonable way to integrate Contiki's CFS into RIOT? Can we add it as a pkg with some script to fetch a git revision and strip everything except the CFS pieces? |
|
I think that could be one way to do this, but probably not the most elegant way. Maybe we should reach out to the Contiki people and see if we can maintain CFS as an external library together on the long run. |
|
Some thought on file descriptors I had I'd like to share: Maybe any value of |
|
@authmillenon watch out for the FDs of stdout, stdin, stderr though. They are defined as 0, 1, and 2 in most implementations. |
|
Damn you're right. It's even specified this way: http://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html |
|
Sorry for my idleness so far 🐌 If nobody objects I would open a new pull request from my fork, adding a summary of the discussion so far to that PR. This thread could then be closed and the discussion would continue in the new PR. Does that make sense? |
|
@x3ro That makes sense. |
|
👍 |
There was a problem hiding this comment.
Can anyone explain what this does/should do? 😕
There was a problem hiding this comment.
I think they meant to do return 0; or return 1; or something
There was a problem hiding this comment.
I guess this was meant to be this, too.
|
Should we close this as a memo now? |
|
Yes |
This PR creates a common interface for all filesystems to use.
STILL WIP