Difference between revisions of "OSFILE"

From BeebWiki
Jump to: navigation, search
m (Fixed broken formatting.)
 
m
Line 29: Line 29:
 
| colspan="2" | '''Functions'''
 
| colspan="2" | '''Functions'''
 
|- valign="top"
 
|- valign="top"
| &FD  || Read file system information (System Internal Name). The attributes field is returned holding the sector start address.
+
| &FC || Write file system information (HADFS).
 
|- valign="top"
 
|- valign="top"
| &FE  || Verify file. Control block is as for A=&FF, Load. If the verification is successful, A is returned holding &01 and the control block holds the file information. If the verification fails, A is returned holding &00 and the load address is returned holding the address where the verification failed. If the file does not exist or is a directory or does not have read access, then an error is generated.
+
| &FD || Read file system information (System Internal Name). The attributes field is returned holding the sector start address.
 +
|- valign="top"
 +
| &FE  || Verify file. Control block is as for A=&FF, Load. If the verification is successful, A is returned holding &01 and the control block holds the file information. If the verification fails, A is returned holding &00 and the load address is returned holding the address where the verification failed. If the file does not exist or is a directory or does not have read access, then an error is generated.
 
|- valign="top"
 
|- valign="top"
 
| &FF  || Load a file into memory. If the low byte of the execution address is zero, the file's own load address is used, else the supplied address is used to load to. If the filename does not exist, or is a directory, or an execute-only file, or does not have read access, then an error is generated.
 
| &FF  || Load a file into memory. If the low byte of the execution address is zero, the file's own load address is used, else the supplied address is used to load to. If the filename does not exist, or is a directory, or an execute-only file, or does not have read access, then an error is generated.
Line 136: Line 138:
  
 
===HADFS===
 
===HADFS===
HADFS implements &FD, &FF to &08.
+
HADFS implements &FC, &FD, &FF to &08.
  
 
[[User:Jgharston|Jgharston]] 16:59, 6 November 2009 (UTC)
 
[[User:Jgharston|Jgharston]] 16:59, 6 November 2009 (UTC)

Revision as of 21:04, 15 December 2013

File and directory information

Specification

 6502   Z80   6809   PDP11   80x86   32016   ARM  On entry: On exit:
A A A R0 AL R1 R0 = function code object type or preserved if function unsupported
XY HL X R1 BX =>control block undefined, control block updated
Control block
&00 R2 R1 R1 =>filename undefined
&02 R3 R2 R2 Load address Load address
&06 R4 R3 R3 Execution address Execution address
&0A R5 R4 R4 Start address Length
&0E R6 R5 R5 End address or Attributes  Attributes
&12


Functions
&FC Write file system information (HADFS).
&FD Read file system information (System Internal Name). The attributes field is returned holding the sector start address.
&FE   Verify file. Control block is as for A=&FF, Load. If the verification is successful, A is returned holding &01 and the control block holds the file information. If the verification fails, A is returned holding &00 and the load address is returned holding the address where the verification failed. If the file does not exist or is a directory or does not have read access, then an error is generated.
&FF   Load a file into memory. If the low byte of the execution address is zero, the file's own load address is used, else the supplied address is used to load to. If the filename does not exist, or is a directory, or an execute-only file, or does not have read access, then an error is generated.
&00 Save a file. If a file already exists with the same name, it is overwritten, with the file access staying the same. If the file is locked, or a directory exists with the same name, then an error is generated.
&01 Write a file's reload address, execution address and attributes.
&02 Write a file's reload address.
&03 Write a file's execution address.
&04 Write a file's attributes.
&05 Read object's catalogue information into the control block.
&06 Delete object. If the object does not exist, A returned as &00. If the object is locked, or is not owned, then an error is generated.
&07 Create an empty file of defined length. Block as for SAVE.
&08 Create a directory. If a directory already exists, there is no error. The created directory is locked. If a file already exists, an error is generated.
Object types returned in A are:
&FF   Execute-only file
&00   Object not found
&01   File found
&02   Directory found
&03   Image file found (file accessible as a directory)
&04   Symbolic link found

Note: The Tube protocol masks off bit 7 of the return value from OSFILE, so A=&FF is returned as A=&7F.

File attributes: These are held in four bytes as follows:
Byte &0E bit 7 Private bit 3   Locked
bit 6 Executable by others bit 2   Executable by owner
bit 5 Writable by others bit 1   Writable by owner
bit 4 Readable by others bit 0   Readable by owner
Byte &0F bits 0-4 Date: day of month bits 5-7   Date: year since 1981, bits 4-6
Byte &10 bits 0-3 Date: month of year bits 4-7   Date: year since 1981, bits 0-3
Byte &11 bits 0-7 Undefined (returned as zero)

Note that lots and lots of documentation incorrectly describe the access byte as being not readable, etc. This is further propagated by DFS using a restricted and mangled access byte. Each bit being not readable, etc., is incorrect. Each bit is set if the corresponding access permission is present.

The normal access of WR/WR results in an access byte of &33. See also File access.

Calling from BBC BASIC

  • LOAD fn$ calls OSFILE &FF
  • CHAIN fn$ calls OSFILE &FF
  • SAVE fn$ calls OSFILE &00

Entry points

  • BBC BASIC Entry Address: &FFDD
  • 6502 Entry Address: &FFDD, vectors via &0212
  • Z80 Entry Address: &FFDD, vectors via &FFDE
  • 6809 Entry Address: &FFDD, vectors via &FFDE
  • 80x86 Entry Address: INT &45, vectors via &0000:0114
  • 32000 Entry Address: SVC &0A
  • PDP-11 Entry Address: EMT 7, vector &07
  • ARM Entry Address: SWI &08 "OS_File", vector &08

Implementations

CFS

CFS implements functions &00 and &FF, and interprets any nonzero value of A as A=&FF (LOAD).

ROMFS

ROMFS gives an error for &00 and all other values as &FF (LOAD) {needs checking}.

DFS

Acorn DFS and contemporary filing systems implement functions &00 to &06 and &FF.

As Acorn DFS and its clones allocate a single bit for attribute storage, when reading the attributes byte &0E is returned =&08 if the file is Locked, =&00 otherwise. When setting attributes the file is Locked if bits 1 or 3 of byte &0E are set (ie Locked or Writable). See also File access.

Some clones of Acorn DFS always return A=1, causing an error instead if no file is found.

HDFS

Andrew Duggan's Hierarchial DFS implements &FF to &06 and &08. It also implements functions &07 and &09, but with different parameters.

  • A=7 Create an object, but with the control block set up as with OSFILE &05, not OSFILE &00.
  • A=9 Changes the length of an existing file.
  • A=10 Changes the attributes, load and execution addresses, and length of a file. This is like OSFILE 1, but the length is also changed.

HDFS also inverts the File access byte.

ADFS

ADFS implements &FF to &08.

HADFS

HADFS implements &FC, &FD, &FF to &08.

Jgharston 16:59, 6 November 2009 (UTC)