A new API for mounting filesystems
A new API for mounting filesystems
Posted Apr 3, 2017 6:34 UTC (Mon) by Cyberax (✭ supporter ✭, #52523)In reply to: A new API for mounting filesystems by Homer512
Parent article: A new API for mounting filesystems
12\n
INSTRUCTION1\n
23\n
/a/23/character/file/name\n
It's not terribly difficult to parse in pure C either.
Posted Apr 3, 2017 7:57 UTC (Mon)
by dany (guest, #18902)
[Link] (1 responses)
Posted Apr 3, 2017 7:59 UTC (Mon)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Posted Apr 3, 2017 14:29 UTC (Mon)
by sorokin (guest, #88478)
[Link] (6 responses)
Posted Apr 3, 2017 17:00 UTC (Mon)
by Cyberax (✭ supporter ✭, #52523)
[Link] (5 responses)
> You mentioned that having '\0' have some downsides, but you did not specify which ones exactly.
> On the other hand I see a (in my optinion) significant downside of your encoding. With known lengths of the values it is very easy to calculate the required buffer size with zero terminated strings. In your case calculating the buffer size in advance is complicated.
Posted Apr 3, 2017 17:33 UTC (Mon)
by Homer512 (subscriber, #85295)
[Link] (3 responses)
I think the point is that with \0-terminated strings, you can precalculate the buffer size by summing strlen() of the parts. With a prefixed string, you have to add ceil(log10(strlen())) + 1 or something like that to account for the length.
Posted Apr 3, 2017 17:34 UTC (Mon)
by Cyberax (✭ supporter ✭, #52523)
[Link] (2 responses)
Posted Apr 3, 2017 20:58 UTC (Mon)
by khim (subscriber, #9252)
[Link] (1 responses)
Posted Apr 3, 2017 21:02 UTC (Mon)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Posted Apr 4, 2017 5:01 UTC (Tue)
by jhoblitt (subscriber, #77733)
[Link]
Posted May 1, 2017 3:11 UTC (Mon)
by spigot (subscriber, #50709)
[Link]
A new API for mounting filesystems
A new API for mounting filesystems
A new API for mounting filesystems
Shouldn't we stop reinventing the wheel and go directly for XML? (trolling)
You mentioned that having '\0' have some downsides, but you did not specify which ones exactly. On the other hand I see a (in my optinion) significant downside of your encoding. With known lengths of the values it is very easy to calculate the required buffer size with zero terminated strings. In your case calculating the buffer size in advance is complicated.
You can appeal that we don't care about the performance of the mount system call. I would say that later the same format can be used in other places too. Making a format difficult to generate and to parse should not be based on the fact it will be rarely used.
A new API for mounting filesystems
Several languages make it difficult to work with \0-containing strings, like good old bash or C.
I don't follow. In a case of \0-terminated array of dynamically-sized strings calculating the total length would require traversal of the whole array with parsing along the way.
A new API for mounting filesystems
> I don't follow. In a case of \0-terminated array of dynamically-sized strings calculating the total length would require traversal of the whole array with parsing along the way.
The simplest workaround in plain old C is to use snprintf(NULL, 0, format, …) and use the return value to allocate the actual buffer.
A new API for mounting filesystems
A new API for mounting filesystems
A new API for mounting filesystems
A new API for mounting filesystems
Sounds similar to djb's netstrings proposal.
A new API for mounting filesystems