Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

Although MFS are used for a great variety of purposes, the basic structure and logic is much the same for any MFS. This section provides general information about the construction and programming of an MFS.

MFS Basics

An MFS is a subroutine like any other in OpenInsight. Because of this, developers are free to create an MFS in any manner they choose, as long as the calling protocols for the subroutine are observed. An MFS can be written in BASIC+, in C, C++, or in assembly language. Developers can choose the language best suited to the application of the MFS, and to their coding preference. For example, an MFS that compresses data might best be coded in a low-level language for speed purposes.

Info
All MFSes must be located in the SYSPROG account.  OpenInsight does not do any inheritance checking.   Thus it is not possible for different versions of an MFS in different accounts to be recognized.

Filing System Access

OpenInsight file operation requests originate in BASIC+ commands such as READ, WRITE, DELETE, LOCK, UNLOCK, SELECT, READNEXT, or in System Monitor routines such as ATTACH_TABLE, DELETE_ROW and LIST_TABLES. Developers write these commands into their programs, or execute the routines from the System Monitor, to control the flow of data to and from the file.

When a program or routine executes, each file-oriented statement becomes a call to the filing system. For example, if an BASIC+ program encounters a READ statement, and the file being read is a Linear Hash file, OpenInsight generates a call to the program RTP57, the Linear Hash BFS, with the appropriate "read" code.

Because BASIC+ is independent of filing systems, the call arguments for filing system subroutines use a standard protocol.  BASIC+ produces the same subroutine call for all filing systems, always using the same arguments. A

READ statement, for example, always produces the same BFS call, regardless of what filing system is actually being accessed by the read logic. By extension, all MFSs must use the same calling conventions.

 

Code Block
declare subroutine fsmsg , attach_table, msg
OPEN 'SYSTABLES' TO FILES.FILE ELSE
  fsmsg()
  return
end
OPEN 'SYSVOLUMES' TO VOLUMES.FILE ELSE
  fsmsg()
  return
end
FILENAME = 'TESTFILE'
MFS.NAME = 'MYMFS.MFS'
READ FILES.REC FROM FILES.FILE, FILENAME ELSE
  fsmsg()
  return
END
VOLUME.NAME = FILES.REC<1> ; * get the name of the volume
READ VOLUME.REC FROM VOLUMES.FILE, VOLUME.NAME ELSE
  fsmsg()
  return
END
* construct the file handle for the REVMEDIA map in question
MEDIA.HANDLE = VOLUME.REC<4> : @VM : VOLUME.REC<5>
* construct the key (file.name*account.name) for the file.
* this information is stored in the SYSTABLES file
MEDIA.MAP.KEY = FILES.REC<2> :"*": FILES.REC<3>
* update the media map entry with the MFS info. MFS lists are
* stored as the 2nd attribute of the media map entry for a file
READ MEDIA.MAP.REC FROM MEDIA.HANDLE, MEDIA.MAP.KEY THEN
* put new MFS name on front of existing MFS list
  OLD.MFS.LIST = MEDIA.MAP.REC<2>
  NEW.MFS.LIST = MFS.NAME : @VM : OLD.MFS.LIST
  MEDIA.MAP.REC<2> = NEW.MFS.LIST
  WRITE MEDIA.MAP.REC TO MEDIA.HANDLE, MEDIA.MAP.KEY ELSE
     fsmsg()
     return
  END
  * reattach file to update SYSTABLES entry
  Attach_Table(FILES.REC<1>,FILES.REC<2>,'','')
END ELSE
   MSG(@window, "Cannot read ":MEDIA.MAP.KEY,'')
   return
END ; * read media.map rec
RETURN 0