Squeak file handling limitations regarding transactions

John M McIntosh johnmci at smalltalkconsulting.com
Thu Jul 13 00:03:14 UTC 2000


on 7/12/00 12:37 PM, Duane Maxwell at dmaxwell at exobox.com wrote:

> Paul Fernhout writes:
>> * You can't truncate files (this comment indicated because the Mac
>> can't?).
> 
> I've always wondered about this.
> 
> Clearly the MacOS is perfectly capable of truncating files, but the comment
> Paul is referring to (the class comment for FileStream) implies that it
> can't.  Can someone with some knowledge of the history shed some light on
> this?
> 
> -- Duane
> 

Well there are a few notes about this at Apple web site. First the flush
issue

http://developer.apple.com/technotes/fl/fl_16.html

Really I think there should be a primitive for this and we hook it up to the
platforms (OS) file flush logic.

I see the async file primitive is the only place where we issue a
flushvolume after closing the file, which of course flushs the file as part
of the close logic. The flush volume flushs all the open files etc etc. Much
like a sync on Unix. Kinda of expensive. Do we need it? If so howcome it's
not part of the rest of the file logic for normal files?

Rummaging about in the Metrowerks standard C library (CW11) shows that nope
it doesn't flush the volume on a fclose(). Interesting enough fflush
doesn't! flush the file, rather it flushs the internal C buffers to disk, or
should I say the OS cache. But that's what the man pages for fflush imply,
which isn't the same time as sync of course. I guess the question here is
fflush safe for a transaction oriented system? Perhaps fsync eh?

And the truncate issue.

http://developer.apple.com/techpubs/mac/Files/Files-50.html

Can't say where I see how to truncate a file in the unix layer, what's the
call (Oh ftruncate)? Doesn't seem to have support for it in the Metrowerks
Standard C Libarary, beyond truncating a file on open, or setting the EOF
past the actual end of file on an llseek.

SetEOF is documented in my printed copy of Inside macintosh 1984.
But it seems you can't get to it via the supported Unix interface, so on the
face of it isn't 'unsupported'

Thoughts? 

None of these are show stoppers, just some Smalltalk code needs to be
written and some more C glue! I'm not sure we want to issue sync, however
one could expose as a primitive to allow the paranoid access.


Thus we need 

flush: aFile
sync
truncate: aNumber

MMm if I talk further I could end up getting to do the macintosh version,
but who will do the Window, unix etc versions, and where's the Smalltalker
needed to write the high level stuff.


--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================
Custom Macintosh programming & various Smalltalk dialects
PGP Key: DSS/Diff/46FC3BE6
Fingerprint=B22F 7D67 92B7 5D52 72D7  E94A EE69 2D21 46FC 3BE6
===========================================================================





More information about the Squeak-dev mailing list