File

From VSI OpenVMS Wiki
Jump to: navigation, search

A file is a data structure for storing information on a storage media, an ordered collection of logically related records treated as a unit. File operations are provided by the Record Management Services. Files are identified by file IDs which contain the location of the file header. File headers stored in INDEXF.SYS contain file metadata and pointers to where the file data is stored on disk.

File Organization

RMS supports the following file organization types:

To find out the organization of a particular file, do a DIRECTORY/FULL.

Record Access Mode RMS provides two record access modes: sequential access and random access. Random access can be further catalogued as one of the three following modes:

  • Random access by key value
  • Random access by relative record number
  • Random access by record file address (RFA)

Although you cannot change its file organization after you create a file, you can change the record access mode each time you access a record in the file. For example, a relative file can be processed in sequential access mode one time and in a random access mode the next time.

Access Mode File Organization
Sequential Relative Indexed
Sequential Yes Yes Yes
Random by relative record number Permitted with fixed-length record format on disk devices only Yes No
Random by key value No No Yes
Random by record file address Permitted on disk devices only Yes No

FID

A file is idenitified by the file ID (for example, "277058,4,0") which consists of three numbers:

  • the file number - the offset into INDEXF.SYS where the file header is stored
  • the file sequence number specifying how many times this file number has been used
  • the relative volume number specifying the number of the volume in the volume set where the file is stored

Aliases

Several directory entries with different names possibly found in different directories can point to the same File_ID and thus same data on disk. This is called aliases or links.

In the following example, an alias is created for REPORT.DAT:

$ dir

Directory DKA0:[JDOE]

DATA.DIR;1          REPORT.DAT;1

Total of 2 files.
$ set file/enter=report_alias.dat
_File: report.dat
$ dir

Directory DKA0:[JDOE]

DATA.DIR;1          REPORT.DAT;1        REPORT_ALIAS.DAT;1

Total of 3 files.
$ dir /file_id

Directory DKA0:[JDOE]

DATA.DIR;1           (6170,17222,0)
REPORT.DAT;1         (6169,17222,0)
REPORT_ALIAS.DAT;1   (6169,17222,0)

Total of 3 files.

 

Normally when a file that has an alias is deleted, a dangling directory entry appears - that is, the alias cannot be used to access the file header and the file is "lost":

$ delete report.dat;1
$ type REPORT_ALIAS.DAT;1
%TYPE-W-OPENIN, error opening DKA0:[JDOE]REPORT_ALIAS.DAT;1 as input
-RMS-E-FNF, file not found
 

ODS-5 volumes with hardlinks enabled support hard links: that is, aliases that can act like files. On a volume with hard links enabled, you can delete the original file, and if there is at least one alias pointing to the file header, the file data is accessible.

Directory Files

Directory files are special files that contain the list of files in a directory and their FIDs. Directory files always have the extension of .DIR and version 1 (files with version numbers greater than one cannot be used as directory files). With sufficient privileges, the directory label can be removed from a file with SET FILE/NODIRECTORY. You can see if a file is a directory file with DIRECTORY/FULL; running F$FILE_ATTRIBUTES(filespec,"DIRECTORY") on a file returns "TRUE" if it is a directory file.

Metadata

File metadata are stored in the file header in INDEXF.SYS. You can view it with DIRECTORY/FULL or DUMP/HEADER:

$ dir/full data.dir

Directory DKA0:[JDOE]

DATA.DIR;1                    File ID:  (6170,17222,0)
Size:            1/16         Owner:    [JDOE]
Created:    29-MAR-2019 15:56:38.74
Modified:   29-MAR-2019 15:56:38.74 (0)
Expires:    <None specified>
Backup:     <No backup recorded>
Effective:  <None specified>
Recording:  <None specified>
Accessed:   <None specified>
Attr Mod:   <None specified>
Data Mod:   <None specified>
Linkcount:  1
File organization:  Sequential
Shelved state:      Online
Caching attribute:  Writethrough
File attributes:    Allocation: 16, Extend: 0, Global buffer count: 0
                    No default version limit, Contiguous, MoveFile disabled
                    Directory file
Record format:      Variable length, maximum 512 bytes, longest 512 bytes
Record attributes:  No carriage control, Non-spanned
RMS attributes:     None
Journaling enabled: None
File protection:    System:RWE, Owner:RWE, Group:RE, World:E
Access Cntrl List:  None
Client attributes:  None

Total of 1 file, 1/16 blocks.
 

See also