[Vm-dev] FilePlugin argument checking - primitiveFailed vs PrimErrBadArgument

David T. Lewis lewis at mail.msen.com
Sun Mar 4 15:04:37 UTC 2018


On Sun, Mar 04, 2018 at 11:24:41AM +0000, Alistair Grant wrote:
>  
> On Thu, Mar 01, 2018 at 02:20:23PM -0800, tim Rowledge wrote:
> > 
> > > On 01-03-2018, at 11:21 AM, Alistair Grant <akgrant0710 at gmail.com> wrote:
> > > 
> > > Hi Everyone,
> > > 
> > > I'm currently extending FilePlugin to allow files to be opened using
> > > either a file descriptor or FILE*.  
> > 
> 
> > If you have some time, and the interest, to do stuff for FilePlugin 
> > then please, please, consider doing a real rewrite. For some time (as 
> > in "since 1997") we've needed better file connections. The original 
> > file primitives (way befor eplugins were even imagined) were written 
> > to make use of the most basic posix library. Thus we get the utter 
> > insanity of the 'set file pointer' and 'write to file pinter' 
> > separation.
> > 
> > It would be nice if the prims that need a file name would only accept 
> > instances of a class specifically for filenames, so we can separate 
> > out deriving the file path from plain String stuff. It would be nice 
> > to have a prim that asks the OS to canonicalise the name - ie take 
> > 'fred.jpg' and work out the full, exact, name for us. RISC OS has a 
> > nice call to do exactly this [1] and it's hard to imagine other OSs 
> > can't do the same; after all they have to do it at *some* point 
> > anyway. I guess the prim could fail if needed and defer to image code 
> > that tries to do The Right Thing.
> > 
> > Merging in your file attributes would be nice. Dave Lewis did some 
> > directory related plugin stuff a while back. Being able to read & set 
> > modes and permissions and metadata would help. That ancient and 
> > horrible FileCopyPlugin I wrote? Needed only because you couldn't read 
> > nor write such stuff and it was essential to copying vmmaker related 
> > scripts etc.
> > 
> > We ought to do so much better. There have been plenty of discussions 
> > over the years but no real change. Maybe you can effect some?
> 
> I'm a little nervous about taking on a complete rewrite of FilePlugin at 
> the moment. :-)  I agree with your comments about being able to set file 
> attributes, and they are a practical small step that can be taken.  It 
> is also reasonable to add that functionality to FileAttributesPlugin.
> 
> Dave, I took a quick look at DirectoryPlugin and it looks like there 
> isn't any support for setting file attributes there.  But please correct 
> me if I'm wrong.

Correct, there is no support for setting file attributes in DirectoryPlugin.

I did make some change about a year ago that may be of interest. I decided
that DirectoryPlugin was too much of a mashup of unrelated concepts, so
I split it into two separate plugins, and added a better primitive for
reading file attributes. But there is nothing there for setting attributes.

Here are the changes that I did:

   Name: VMConstruction-Plugins-DirectoryPlugin-dtl.9
   Author: dtl
   Time: 27 April 2017, 6:53:25.9 pm
   UUID: 4e2e427e-be7a-4ed5-a7e7-626598b3ea9d
   Ancestors: VMConstruction-Plugins-DirectoryPlugin-dtl.8
   
   DirectoryPlugin was originally developed to improve directory access
   performance, and it implemented both directory stream and file stat primitives.
   Improvements elsewhere in the image or VM make the directory stream primitives
   less useful, but the file stat primitives still have value.
   
   Directory streams and file access checks are reasonably distinct concepts.
   Therefore split DirectoryPlugin in two, PosixDirectoryStreamPlugin and
   PosixFileStatPlugin. For now, retain the original DirectoryPlugin for
   reference, but it may be removed in the future.
   
   Name: VMConstruction-Plugins-DirectoryPlugin-dtl.10
   Author: dtl
   Time: 29 April 2017, 8:34:18.983 pm
   UUID: 9c1d225b-0f9e-4a29-a466-06cb88bb6dbb
   Ancestors: VMConstruction-Plugins-DirectoryPlugin-dtl.9
   
   Implement primitiveStatStruct to answer a complete array of stat structure
   values. This is different from primitiveStat, which answers an array with
   values suitable for use in creating directory entries in Smalltalk.


The new primitive is:

	<primitive: 'primitiveStatStruct' module: 'PosixFileStatPlugin'>

The primitive answers an array with:

	st_dev  	/* ID of device containing file */
	st_ino   	/* inode number */
	st_mode 	/* protection */
	st_nlink 	/* number of hard links */
	st_uid   	/* user ID of owner */
	st_gid   	/* group ID of owner */
	st_rdev 	/* device ID (if special file) */
	st_size		/* total size, in bytes */
	st_blksize	/* blocksize for filesystem I/O */
	st_blocks	/* number of 512B blocks allocated */
	st_atime	/* time of last access */
	st_mtime	/* time of last modification */
	st_ctime	/* time of last status change */ "

Please feel free to borrow or adapt anything that might be useful. The
repository is at http://www.squeaksource.com/DirectoryPlugin.

Dave



More information about the Vm-dev mailing list