RISCOS.com

www.riscos.com Technical Support:
Acorn Omniclient User Guide

 

6 NFS file mapping


There are a number of differences between the UNIX and RISC OS models of a filing system, the more important being:

Because of these clashes changes have to be made when mapping RISC OS file names and attributes to UNIX ones, and vice versa. Generally the changes made when mapping one way are reversed when mapping the other way, so the system is as transparent as possible if only viewed from RISC OS. If you view the files using the remote filestore though, you'll notice some differences.

This chapter outlines how the mapping of file names takes place, and what differences you'll notice between the RISC OS view of a file and the UNIX view.

NFS - its file mapping from RISC OS to UNIX

This section describes how RISC OS NFS maps files from RISC OS to UNIX.

Filenames

Character translation

The first change RISC OS NFS makes to a filename is to translate the character `/' (the UNIX directory separator) to `.', for example:

RISC OS nameUNIX name
fred/cfred.c
/profile.profile

File type extensions

RISC OS NFS then adds a filename extension to store the RISC OS file type.

You can set the extension used for any given file type to one of your choice. To do so you must edit the extensions file, held within the Internet application. See the section Editing the extensions file.

If you haven't set up a filename extension for a given file type, then a default extension gets used instead. The default mapping of a RISC OS file called Fred is as follows:

RISC OS typeUNIX name Notes
TextFred
UNIX ExFred
Draw (&AFF)Fred,aff
Obey (&FEB)Fred,feb and other file types similarly…
dead †Fred,xxx
untypedFred,lxa
directoryFred

† A dead file is one that has been created but the contents of which are being updated. For example when NetFS copies a file to a file server it reserves space by creating a dead file before writing to it.

File contents

The contents of files are unchanged when transferring to UNIX, save for untyped files. These have their load and execute addresses appended to the file, making it 8 bytes longer:

…normal contents
L0
L1
L2
L3
E0
E1
E2
E3

The RISC OS file ended before L0, while the UNIX file ended after E3

L0 is the least significant byte of the load address, L3 the most significant. Bytes E0 to E3 are the execute address.

Access attributes

When creating a new file or directory

You can use the system variable NFS$CreateAccess to define the default read/write access attributes for user, group and other that RISC OS NFS sets when creating a file or directory on UNIX. This variable uses six of its lowest nine bits:

User
Group
Other
r
w
-
r
w
-
r
w
-

You can set it in octal by using a leading `0' (you'll find this familiar if you've ever used the UNIX chmod command with numbers), or in hexadecimal by using a leading `0x', or in decimal by just using a number. So the following would all set the variable to specify user read/write access, group read only access, and no access to others:

*Set NFS$CreateAccess 0640 (using octal)

*Set NFS$CreateAccess 0x1A0 (using hexadecimal)

*Set NFS$CreateAccess 416 (using decimal)

You can override the value of the NFS$CreateAccess variable for a specific mount by setting a system variable NFS$CreateAccess_mountname .

You should set these access variables in a boot file; see your RISC OS 3 User Guide if you need help on this.

If a relevant access variable exists then files and directories are created with the read/write access it specifies. Files of type UNIX Ex also have their execute attributes set to be the same as the corresponding read bits in the variable.

If no relevant access variable exists then files are created with user read/write access, and with user execute permission if the files' type is UNIX Ex. Directories are created with user read, write and execute permission.

When mapped from RISC OS

When RISC OS NFS sets the access to a UNIX file using RISC OS attributes they are mapped as follows:

RISC OS bitUNIX bit
owner readuser read
user execute is also set if owner read is set and the file's type is UNIX Ex
owner writeuser write
public readgroup read and other read
group execute and other execute are also both set if public read is set and the file's type is UNIX Ex.
public writegroup write and other write
locked(discarded)


Similarly, when RISC OS NFS sets the access to a UNIX directory using RISC OS attributes they are mapped as follows:

RISC OS bitUNIX bit
owner readignored - i.e. user read is left unchanged
owner writeignored - i.e. user write is left unchanged
user execute is always set
public readgroup read and other read
public writegroup write and other read
lockedNOT group execute and NOT other execute

Dates

UNIX date stamps any files just as usual if you use RISC OS NFS to create or amend them.

Finding an object

When RISC OS NFS is finding an object it searches in this order, using the first match it makes:

  1. It searches for an exact name match.
  2. It searches for an exact name match after any RISC OS specific extension has first been removed.
  3. It searches for a name match ignoring case, after any RISC OS specific extension has first been removed.

NFS - its file mapping from UNIX to RISC OS

This section describes how RISC OS NFS maps files from UNIX to RISC OS.

Filenames

File type extensions

The first change RISC OS NFS makes is to remove any filename extension used to store the RISC OS file type.

It starts by looking through the extensions file to see if the filename has an extension that matches one you specified; if so, the extension gets removed. You can in fact set up a different mapping for each direction of file transfer, so you can map many UNIX file extensions to single RISC OS file types. See the section Editing the extensions file.

If RISC OS NFS can't find a matching filename extension in the extensions file it then tries to remove any of its own default extensions; so the following all appear as Fred under RISC OS:

UNIX nameNotes
Fred
Fred,hhhhhh is 3 lower-case hex digits
Fred,xxx
Fred,lxa

Truncation

The next thing RISC OS NFS does to a filename is to truncate it to the length set by the system variable NFS$TruncateLength. By default this is set to the value 10 - the same length as the maximum that the desktop Filers can handle. It only gets read once, when the NFS module is loaded.

If you want a different truncate length use the *Set command, say in a boot file:

*Set NFS$TruncateLength 12

If you're using NFS from the command line you may want to override filename truncation. To do so set the variable to a large number, e.g. 1000000.

Character translation

The final change RISC OS NFS makes to a filename is to translate the character `.' (the Acorn directory separator) to `/', for example:

UNIX nameRISC OS name
fred.cfred/c
.profile/profile

File contents

RISC OS NFS makes the last 8 bytes of any file with a `,lxa' extension invisible; this is to hide the load and execute addresses it presumes itself to have appended.

If you generate a file in UNIX with a `,lxa' extension which is less than 8 bytes long, you will get unpredictable behaviour if you try to manipulate it from RISC OS.

Access attributes

When the access attributes of a UNIX file or directory get translated by RISC OS NFS they are mapped as follows:

UNIX bitRISC OS bit
user readowner read
user writeowner write
user execute(discarded)
group read(discarded)
group write(discarded)
group execute(discarded)
other readpublic read
other writepublic write
other execute(discarded for files)
NOT locked for directories

Dates

RISC OS NFS always uses the UNIX last modified date stamp to map to a RISC OS date stamp. It assumes the UNIX date stamp to be in GMT, and uses the value set by *TimeOffset to convert this to local time. See *TimeOffset.

File types

RISC OS NFS resolves file types by looking for any filename extension used to store the RISC OS file type. It does so at the same time as it resolves filenames - see also the earlier Filenamessection.

It starts by looking through the extensions file to see if the filename has an extension that matches one you specified; if so, it sets the file to the corresponding file type. See the section Editing the extensions file.

If RISC OS NFS can't find a matching filename extension in the extensions file it then sets the file type using its default file extensions. So, again taking the example of a file that will be displayed as Fred:

UNIX nameNotes RISC OS type
FredUNIX directoryDirectory
Fredno execute bit is set Text
Fredany execute bit is set UNIX Ex
Fred,hhhhhh is 3 lower case hex digits &hhh
Fred,xxxdead
Fred,lxanone, undated

See also the section Soft links.

Load and execute addresses

If a UNIX file has the extension `,lxa' then RISC OS NFS assumes it to be a RISC OS untyped file that it created on UNIX. It uses the last 8 bytes of the file to give the load and execute addresses. So if they were:

…normal contents
67
45
23
01
EF
CD
AB
89

(The RISC OS file ends before 67, while the UNIX file ends after 89.)

the load address would be &01234567, and the execute address would be &89ABCDEF.

Soft links

RISC OS NFS resolves soft links up to eight times - that is, whilst following a soft link, it only allows eight soft links to be traversed. If this traversal reaches an existing object other than a soft link:

In other words soft links behave transparently except that, where there is more than one soft link to a file, its type may differ depending on which soft link you use to view it.

RISC OS NFS can't traverse a soft link that leaves a mount. If a UNIX link name starts with the character `/' then RISC OS NFS treats it as the root of its mount. Consequently absolute soft links will only work if you've mounted the UNIX root directory `/' and if the soft link does not leave the root filing system. For example, if you had mounted /usr then this UNIX soft link in the /usr directory would be traversed:

lrwxrwxrwx 1 root wheel 11 Feb 23 17:19 man -> ./share/man

whereas this one wouldn't be:

lrwxrwxrwx 1 root wheel 11 Feb 23 17:19 man -> /usr/share/man

We advise that when you make soft links on UNIX you always make relative links (i.e. start them with `.' or `..') rather than absolute ones.

If a soft link does not resolve to an existing non-soft-link object within eight expansions it's displayed as a file with type `SoftLink' (&FDC). You can't do anything from RISC OS with one of these dead soft links.

Other object types

Block and character special files and named sockets are displayed as UNIX Ex files. Fiddle with these from RISC OS at your peril!

Editing the extensions file

The extensions file is held in the files subdirectory of the Internet application, and configures the mapping of RISC OS file types to UNIX filename extensions. To add your own filename extensions for specific RISC OS file types you need to edit this file:

  1. Load Edit onto the icon bar - if it's not already loaded.
  2. Open the directory display containing the !Internet application - if it's not already open.
  3. Open the !Internet application directory by holding down the Shift key while you double-click on the !Internet icon.
  4. Open the files directory.
  5. Load it into Edit by dragging its icon to the Edit icon on the icon bar.
  6. Add to the file your own mappings of file type to UNIX file extension.

RISC_OS_file_type new_extension [anything]

The RISC OS file type can be the name of a file type, or its file type number in hexadecimal. So to give Data files (type &FFD) the extension `.dat' you could use either of these lines:

Data .dat

ffd .dat

When moving to UNIX the extension is only added if it's not already present. So if the line were to read:

ffd .dat sticky

the Data file output would be renamed output.dat , whereas the Data file output.dat would not be renamed.

When returning from UNIX the extension doesn't get removed; otherwise it's handled the same as ever, so the file type gets set using this extension.

We expect you'll want the `To extensions:' part to duplicate the entries in the `From extensions' part, so any extension that gets added when a file is transferred to UNIX gets removed again if the file returns to RISC OS. However, there may be a lot of UNIX extensions that you wish to convert to a single RISC OS file type. For example, you may have several UNIX applications each of which generates text files with different extensions - say `.txt', `.doc' and `-asc'. To do so, just add extra entries to the `To extensions', thus:

Text .txt
Text .doc
Text -asc

When you've added all the extensions you want to, save the edited extensions file, overwriting the old one.

This edition Copyright © 3QD Developments Ltd 2015
Last Edit: Tue,03 Nov 2015