Difference between revisions of "File"

From VSI OpenVMS Wiki
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
[[RMS]] supports the following file organization types:
 
[[RMS]] supports the following file organization types:
  
* sequential
+
* [[Sequential File|sequential]]
* relative
+
* [[Relative File|relative]]
* indexed
+
* [[Indexed File|indexed]]
  
To find out the organization of a particular file, do a DIRECTORY/FULL.
+
To find out the organization of a particular file, do a [[DIRECTORY (command) |DIRECTORY]]/FULL.
 
 
==Sequential File Organization==
 
In sequential file organization, records are arranges one after the other in the order in which they are stored. When editing a sequential file, new records cannot be inserted between existing records because no physical space separates them - you can only add records to the end of the file.
 
 
 
Sequential file organization is supported for all device types; this is the only file organization for non-disk devices. A sequential file is created by default when you use the CREATE command.
 
 
 
==Relative File Organization==
 
The relative file organization allows sequential and random access of records. A relative file consists of a series of numbered fixed-length records; RMS uses the relative record number - the record's position relative to the beginning of the file - to randomly access records. Relative files allow random get and put operations and can be write-shared.
 
 
 
==Indexed File Organization==
 
Indexed files store data records in an index structure ordered by the primary key; data can be retrieved using index structures ordered by primary or alternate keys.
 
  
 
Record Access Mode
 
Record Access Mode
Line 59: Line 48:
  
 
=FID=
 
=FID=
A file is idenitified by the [[File_ID|file ID]] which consists of three numbers:
+
A file is idenitified by the [[File_ID|file ID]] (for example, "277058,4,0") which consists of three numbers:
 
* the file number - the offset into [[INDEXF.SYS]] where the [[File header|file header]] is stored
 
* the file number - the offset into [[INDEXF.SYS]] where the [[File header|file header]] is stored
 
* the file sequence number specifying how many times this file number has been used
 
* the file sequence number specifying how many times this file number has been used
Line 110: Line 99:
  
 
=Directory Files=
 
=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.
+
[[Directory file|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()|F$FILE_ATTRIBUTES]](filespec,"DIRECTORY") on a file returns "TRUE" if it is a directory file.
  
 
=Metadata=
 
=Metadata=

Latest revision as of 08:45, 6 July 2023

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