[Vm-dev] Extending primitiveDirectoryEntry

Alistair Grant akgrant0710 at gmail.com
Tue Apr 25 09:25:50 UTC 2017


On Sun, Apr 23, 2017 at 07:10:10PM -0400, David T. Lewis wrote:
> 
> Sure, happy to help. You can find the VM plugin at
> http://www.squeaksource.com/DirectoryPlugin.
> 
> A small plugin is actually fairly simple to do, so take a look at the
> DirectoryPlugin as an example, and we can either add the functionality
> you want, or just use it as a pattern to make a plugin that does
> exactly what you need.
> 
> I have been thinking of splitting DirectoryPlugin into two smaller
> pieces, one of which would be called PosixFileStatPlugin. If we do
> that, we would have a small plugin that addresses only the Posix file
> stat functions, and we could fill it out to have it answer the fields
> that you are interested in (st_dev).

I finally have a Pharo VM with your DirectoryPlugin available and 
working, so I think I'm ready to proceed... :-)

>From what I can see, at the moment:

- DirectoryPlugin isn't a core part of Squeak, i.e. if I just download a
  VM and image from the website it won't be in the image or VM.

- The version of FilePlugin used in Pharo is different to that in Squeak 
  (even though there are the Pharo #ifdefs in the Squeak version).
  The Pharo version is at, e.g. (there are multiple copies, I haven't 
  looked to see if they are different from each other: 
  https://github.com/pharo-project/pharo-vm/tree/master/mc/VMMaker.oscog.package/FilePlugin.class
  E.g. the Pharo version has added primitiveDirectoryEntry

Assuming my understanding is correct, and based on comments from Tim and 
Eliot, does that mean that there's push to make DirectoryEntry a core 
part of Squeak?

Given that DirectoryEntry isn't part of Pharo, and the added complexity 
of the forked FilePlugin, I agree that creating a new 
PosixFileStatPlugin sounds like a good idea.

To meet what Pharo immediately needs, PosixFileStatPlugin would 
initially contain the following primitives:

- primitiveFileExists - answers a boolean indicating whether the file 
  exists.
- primitiveFileAccess - answers a mask indicating what access the VM has 
  to the file, i.e. read, write, execute, ???
- primitiveStatFile - answers an array which contains all the data 
  returned by the libc stat() function.

The reason for these three is that checking for file existence in Pharo 
is much more common than any other operation, so we want to make this as 
quick as possible.

After that, code in the base image looks at only one attribute at a
time, however based on Eliot's comments, it sounds like the primitive
call overhead is much larger than the object creation and garbage
collection overhead, so just return a single collection of all
information.  The smalltalk code can then be modified to allow the user
to access the attributes as required.

For Pharo at least, I'd probably add a FileAttributes hierarchy of 
classes that can be used to interpret the information and deal with 
cross-platform differences:

FileAttributes
    UnixFileAttributes
        MacFileAttributes
    WindowsFileAttributes
    ...

Please let me know what you'd do differently.

Thanks,
Alistair



More information about the Vm-dev mailing list