CakeML / cakeml

CakeML: A Verified Implementation of ML
https://cakeml.org
Other
964 stars 84 forks source link

Add support for directories to the filesystem FFI #640

Open xrchz opened 5 years ago

xrchz commented 5 years ago

This issue is for adding the ability to read the contents of directories using the CakeML basis. It is probably a requirement for #614.

hferee commented 5 years ago

Summary of what I think is required for this:

The last point introduces a major difficulty, avoided until now: model relative paths, and more generally, the directory structure. Everything currently assumes that a given file will always be addressed using the same filename (e.g. after creating file foo, $pwd/foo and foo do not represent the same inode). I suggest changing the fs.files field from (mlstring#mlstring) list to: a tree of such (mlstring#mlstring) list representing the regular files immediately in the directory ; its subdirectories being its children. This requires to define a tree lookup and update function (which understands _/_, .., .), as well as a path equivalence function.

xrchz commented 5 years ago

Great fleshing out of this issue! Should we perhaps be trying to tap into any existing formal file system models? I think there's been a lot of work on that by eg Tom Ridge, Philippa Gardner, ...

hferee commented 5 years ago

Yes (ECOOP18 seems good for this), especially as they model it with separation logic, when our current model is a big unseparable block. I don't see why inode_tbl and files could not be represented in a finer way (i.e. per file/inode), but afaik infds can't, as the knowledge of all the currently opened file descriptors is required to allocate a new one. I don't have time to work on this in the following weeks, but I will give it a thought later or provide help is anyone wants to jump in.