VM Maker: VMMaker.oscog-nice.2233.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMaker.oscog-nice.2233.mcz

commits-2
 
Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2233.mcz

==================== Summary ====================

Name: VMMaker.oscog-nice.2233
Author: nice
Time: 5 June 2017, 6:13:56.418116 pm
UUID: ff8286e4-b96f-4ce6-9cb5-e7b286679e03
Ancestors: VMMaker.oscog-eem.2232

Integrate changes from monty to sqFileOpenNew.

There must be a way to check if failure is due to existence of file (implemented via PrimErrInappropriate).
If we would test existence afterward, the file could have been deleted in interim leading to another race condition.

This VMMaker change requires a coordinated platform source change (adding a 4th parameter to sqFileOpenNew).

=============== Diff against VMMaker.oscog-eem.2232 ===============

Item was changed:
  ----- Method: FilePlugin>>fileOpenNewName:size:secure: (in category 'file primitives') -----
  fileOpenNewName: nameIndex size: nameSize secure: secureFlag
  "Open the new named file, possibly checking security. Answer the file oop."
  | file fileOop okToOpen |
  <var: #file type: 'SQFile *'>
  <var: 'nameIndex' type: 'char *'>
  <export: true>
  fileOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self fileRecordSize.
  file := self fileValueOf: fileOop.
  interpreterProxy failed
  ifFalse: [ secureFlag ifTrue: [
  "If the security plugin can be loaded, use it to check for permission.
  If not, assume it's ok"
  sCOFfn ~= 0
+ ifTrue: [
+ okToOpen := self cCode: '((sqInt (*) (char *, sqInt, sqInt)) sCOFfn)(nameIndex, nameSize, true)' inSmalltalk:[true].
- ifTrue: [okToOpen := self cCode: '((sqInt (*) (char *, sqInt, sqInt)) sCOFfn)(nameIndex, nameSize, true)' inSmalltalk:[true].
  okToOpen
  ifFalse: [interpreterProxy primitiveFail]]]].
  interpreterProxy failed
+ ifFalse: [| exists |
+ exists := false.
+ self cCode: 'sqFileOpenNew(file, nameIndex, nameSize, &exists)' inSmalltalk: [file].
+ (interpreterProxy failed
+ and: [exists])
+ ifTrue: [interpreterProxy primitiveFailFor: PrimErrInappropriate]].
- ifFalse: [self cCode: 'sqFileOpenNew(file, nameIndex, nameSize)' inSmalltalk: [file]].
  ^ fileOop!

Item was changed:
  ----- Method: FilePluginSimulator>>fileOpenNewName:size:secure: (in category 'file primitives') -----
  fileOpenNewName: nameIndex size: nameSize secure: secureFlag
  "Open the new named file, possibly checking security. Answer the file oop."
  | path f index |
  openFiles size >= maxOpenFiles ifTrue:
  [^interpreterProxy primitiveFailFor: PrimErrLimitExceeded].
  path := interpreterProxy interpreter asString: nameIndex size: nameSize.
  "the #defaultAction for FileExistsException creates a dialog,
  so it is caught and resignaled as a generic Error"
  [f := FileStream newFileNamed: nameIndex]
  on: FileExistsException
+ do: [:error | ^ interpreterProxy primitiveFailFor: PrimErrInappropriate].
- do: [:error | Error signal: 'File already exists: ', nameIndex].
  f ifNil: [^interpreterProxy primitiveFail].
  f binary.
  index := openFiles size + 1.
  openFiles at: index put: f.
  ^interpreterProxy integerObjectOf: index!