Using Directories

The concept of directories has been alluded to earlier in this book, and the DIRECTORY command was introduced (see "Displaying a List of Files (the DIRECTORY command)" above).

Directories provide a convenient way to organize related files into a hierarchical structure. If you imagine a file as a single sheet of paper, then the directory would be the folder containing the related papers. Papers that are related to one another are usually placed in the same folder for easy access. A folder usually has an external label on it, indicating its contents. Similarly, a directory has a name that should indicate which files it contains.

A directory may contain not only files, but other directories as well. A directory called 2003 may contain some individual files, as well as other directories called January, February, etc. Those directories may themselves contain files and yet more directories.

When your account is created, your system manager will create a top-level directory for you, sometimes called your root or home directory. When you log in, your default directly will automatically be set to your own top-level directory.

start sidebar
Default Versus Home Directory

Your default directory is always your current directory. When you move around directories, each one in turn becomes your default directory. On the other hand, your home directory does not change. It is the one created for you by the system manager. When you log in, your default directory is set to your home directory.

end sidebar

Construction of a Directory Specification

A directory specification is the following portion of a full file specification:

    [DIR.SUBDIR1.SUBDIR2(...)] 

Here are some examples:

    [MIKE]    [PAYROLL.2001.NOVEMBER]    [PAYROLL.1999.AUGUST]    [USERS.FRANK.HOBBIES.FISHING.GREAT_LAKES]    [USERS.FRANK.HOBBIES.BASKETBALL] 

Note 

While accessing an OpenVMS system through TCP/IP services such as FTP, it is often acceptable, and sometimes required, to use UNIX format, wherein [USERS.FRANK.HOBBIES]FILE.TXT would be expressed as /users/frank /hobbies/file.txt.

SHOW DEFAULT and SET DEFAULT

The SET DEFAULT directory command changes your current directory to the one you specify. It is equivalent to the CD or CHDIR commands of other operating systems. The SHOW DEFAULT command tells you your current device and directory:

    $ SET DEFAULT DKA100:[MIKE]    $ SHOW DEFAULT      DKA100:[MIKE]    $ SET DEFAULT [JAMES.REPORTS]    $ SHOW DEFAULT      DKA100:[JAMES.REPORTS] 

When you issue the SHOW DEFAULT command, DCL responds with your current disk (DKA100: above) and directory ([MIKE] and [JAMES.REPORTS]). When you issue a command that performs a file operation, your current directory will be assumed. Unless you specify another directory in a file specification, the activity will occur in that directory.

Let's say users MIKE and MURPHY each have a command procedure called SETUP.COM that performs some task for them. Even though the files share the same name, there is no confusion because each user has his own directory containing his own version of SETUP.COM.

When MIKE logs in, his current directory is DKA100:[MIKE], so his references to SETUP.COM refer to DKA100:[MIKE]SETUP.COM. When MURPHY logs in and references SETUP.COM, DKB400:[MURPHY]SETUP.COM is used.

If user MIKE wishes to use MURPHY's SETUP.COM, he may either use the DCL command SET DEFAULT DKB400:[MURPHY] to change to MURPHY's directory before using the file, or specify the file by its full name, DKB400:[MURPHY]SETUP.COM.

start sidebar
What the Command SET DEFAULT Really Means

While it is conceptually correct to think of yourself as being "in" a certain directory, that's not how it actually works. Your current directory is little more than an illusion. It is really only a text string used to fill in missing pieces of a full file specification. Let's say your current default directory is DKA100:[MIKE]. If you issue the command EDIT LOGIN.COM, the OpenVMS file system applies the default directory DKA100:[MIKE] to your file specification, resulting in DKA100:[MIKE]LOGIN.COM. The SET DEFAULT command sets your default directory string, giving the command it's name.

end sidebar

Moving Around Directories

Earlier in this book, directories were compared to folders within folders. There is another way of looking at the same setup: the directory tree. Figure 7-2 and Figure 7-3 present both ways of looking at the same directory organization:

click to expand
Figure 7-1: Directories As Folders

click to expand
Figure 7-2: Directories As a Tree Structure

For moving around various directories, many users may find the tree concept more intuitive. There are three ways of dealing with directories. They are:

  1. Staying in one directory and using full file specifications for files in other directories

  2. Moving directly from one directory to another

  3. Moving up and down the directory tree

All three of these methods are typically used in combination. Moving around directories is discussed in the following paragraphs.

Moving Directly to Another Directory

This is accomplished by using an absolute directory specification with the SET DEFAULT command:

    $ SHOW DEFAULT ! see our initial directory      DKA100:[KEVIN]    $ !    $ SET DEFAULT [KEVIN.TOOLS]    $ SHOW DEFAULT      DKA100:[KEVIN.TOOLS]    $ !    $ SET DEFAULT [KEVIN.REPORTS]    $ SHOW DEFAULT      DKA100:[KEVIN.REPORTS]    $ !    $ SET DEFAULT [KEVIN]    $ SHOW DEFAULT      DKA100:[KEVIN] 

Moving Around Relative to Your Current Directory

You may move around a directory tree using the relative notations "-" to move up one level and "." to move down one level. They may be used in combination. For example, to move to the TOOLS subdirectory of the current directory (down one level), specify [.TOOLS]. To move back from the TOOLS directory to the original directory (up one level), use [-]. To move over to an adjacent directory—for example REPORTS,—use [-.REPORTS] (this means to first move up one level and then down into the REPORTS subdirectory.)

The following performs the same steps as the previous example, but uses the relative notations:

    $ SHOW DEFAULT ! our original directory      DKA100:[KEVIN]    $ !    $ SET DEFAULT [.TOOLS]    $ SHOW DEFAULT      DKA100:[KEVIN.TOOLS]    $ !    $ SET DEFAULT [-.REPORTS]    $ SHOW DEFAULT      DKA100:[KEVIN.REPORTS]    $ !    $ SET DEFAULT [-]    $ SHOW DEFAULT      DKA100:[KEVIN] 

With long directory names, relative notations can save considerable effort:

    $ SET DEFAULT [MIKE.REPORTS.2002.MARCH.NORTHEAST]    $ SHOW DEFAULT      DKA0:[MIKE.REPORTS.2002.MARCH.NORTHEAST]    $ !    $ SET DEFAULT [-.NORTHWEST]    $ SHOW DEFAULT      DKA0:[MIKE.REPORTS.2002.MARCH.NORTHWEST]    $ !    $ SET DEFAULT [---.2003.MARCH]    $ SHOW DEFAULT      DKA0:[MIKE.REPORTS.2003.MARCH] 

Wildcards for Directory Operations

The wildcards already discussed (see "Working with Files: Wildcards," above) can be used with directories. In addition, directories support an additional wildcard consisting of an ellipsis (...), which means "from this point downward in the directory tree."

Some examples of wildcard directory specifications follow.

  • To search all top-level directories for each users LOGIN.COM:

          $ DIRECTORY [*]LOGIN.COM 

  • To search all directories on the disk for any files called ERROR.LOG:

          $ DIRECTORY [*...]ERROR.LOG       ! Excludes MFD      $ DIRECTORY [000000...]ERROR.LOG  ! Includes MFD 

  • To search all the subdirectories immediately below this one for files called BARRY.RPT:

          $ DIRECTORY [.*]BARRY.RPT 

  • To find all logfiles from this point downward (the current directory, all subdirectories of the current directory, all their subdirectories, etc.):

          $ DIRECTORY [...]*.LOG 

  • To perform the same search, but exclude the current directory:

          $ DIRECTORY [.*...]*.LOG 

  • To find all files in the directory above this one:

          $ DIRECTORY [-] 

Creating and Deleting Subdirectories

This section describes how you may create and delete subdirectories under your own directory. Creating top-level directories for a new user or under someone else's directory tree usually requires privileges not available to the general user and is shown here for information only.

Creating a Directory

To create a directory, the general command format is

    $ CREATE/DIRECTORY directory [/OWNER=user] 

The /OWNER qualifier should be used if the owner of the directory should differ from the owner of the parent directory. This is generally used for top-level directories.

Some examples follow:

    $ CREATE/DIRECTORY DKA100:[JONES]/OWNER=JONES  ! Top-level directory    $ CREATE/DIRECTORY [.REPORTS]                 ! Under current directory    $ CREATE/DIRECTORY DKB400:[BARRY.ARTICLES.JAN] 

Intervening directory levels need not already exist. In the last example above, the directories DKB400:[BARRY] and then DKB400:[BARRY.ARTICLES] would be created first, if necessary.

Creating a Subdirectory

Creating a subdirectory is a special case of creating a directory in general.

To create a subdirectory of the current directory, use the CREATE/DIRECTORY command. If you wished to create a subdirectory called REPORTS, you would use the following command:

    $ DIRECTORY ! To see the current directory first    Directory DKA100:[MURPHY]    LOGIN.COM;45    Total of 1 file.    $ CREATE/DIRECTORY [.REPORTS]    $ DIRECTORY    Directory DKA100:[MURPHY]    LOGIN.COM;45        REPORTS.DIR;1    Total of 2 files. 

You can see from this example that a directory is itself a file that can be seen using the DIRECTORY command. However, it is not an ordinary file, and you cannot manipulate it as you would other files. Changes to directory files are made automatically by the system as needed. The only time a user directly manipulates a directory file is while deleting it, which is shown next.

Deleting a Subdirectory

Deleting a subdirectory is not quite as straightforward as creating one because two conditions must first be met. First, the subdirectory must be empty. If a directory contains any files, OpenVMS will not delete it. Doing so would cause its files to be orphaned, meaning the files would still exist, but would not be listed in any directory.

Note 

The system manager can detect and recover orphaned files using built-in OpenVMS tools should the need arise. This occurs infrequently—usually when a directory file is somehow damaged.

Second, you must set the file protection of the directory so that you may delete it. (File protections are explained in detail later.) Directory files automatically have a higher level of protection than ordinary files. To delete a directory file, you must take the following steps:

     $ ! Delete the files within it, if any.  If [.REPORTS] itself has any     $ ! subdirectories, those must be emptied and deleted first.     $ !     $ delete [.reports]*.*;*     $ !     $ ! Now change the file protection on the REPORTS directory file so     $ ! that we may delete it (this requires CONTROL access to the directory)     $ !     $ set file/protection=(o:d) reports.dir ! (o:d) means "Owner may Delete"     $ !     $ ! Now delete the directory file     $ !     $ delete reports.dir;* 

Note 

In place of the SET FILE/PROTECTION command above, some experienced OpenVMS users may prefer SET SECURITY or SET PROTECTION. SET FILE /PROTECTION is shown because the availability and format of the other two commands vary somewhat among different OpenVMS versions.

The Directory Structure of a Files-11 ODS-2 Disk

To show how the general concepts of directories are carried out in practice, this section will briefly describe the actual layout of an OpenVMS disk. A little history is necessary to understand the terminology.

Files-11 is the file system used by OpenVMS. As one might imagine, the file system is that part of an operating system that controls the storage and manipulation of files.

ODS-2 stands for On-Disk Structure, Version 2. It describes the actual layout of files on the disk, including all control information needed to interpret the contents of the disk. Later versions of OpenVMS Alpha (and presumably, the upcoming Itanium version) also support a newer Files-11 structure level, ODS-5. ODS-2 and ODS-5 volumes may exist on the same system, so long as the system is running a compatible version of OpenVMS.

On ODS-2 disks, the top-level directory is called [000000]. This top-level directory is also known as the "MFD," or "Master File Directory."

New users may find it curious that directory listings of the [000000] directory include the file 000000.DIR. This is because the MFD includes an entry for itself, making it appear that the MFD "contains itself."

start sidebar
Why Call It 000000?

The unlikely-sounding name 000000 has a historical basis. On much older Digital systems, the directory name for each user took the form [gggmmm], where ggg was the UIC group number for that user, and mmm was the member number. So, [000000] (also denoted [000,000]) represented the MFD. (Try it: as of OpenVMS V7.3, the command DIRECTORY [0,0] still works as a substitute for DIRECTORY [000000] if you have the appropriate privileges.)

end sidebar

The MFD of an ODS-2 disk contains some reserved files. These are files with specific names and purposes that the OpenVMS file system uses to maintain information on disk. Among these are the following:

  • 000000.DIR—the MFD directory file. This file contains entries for all files in the top-level directory of the disk. Directories contain little information about files, mostly just their names and file IDs, which are used to locate the complete file information located in INDEXF.SYS.

  • BITMAP.SYS—a file containing information about which areas of the disk are in use and which are free. Used to locate space for newly created files.

  • INDEXF.SYS—also known as the Index file, this file stores all attributes (name, size, owner, location on disk, etc.) for each file on the disk. It is central to the management of files.

  • SYSx.DIR—the top of the directory tree in which OpenVMS resides if the disk contains a copy of the OpenVMS operating system (as opposed to a data-only disk). On standalone systems it is called SYS0. VMScluster disks have directories for each member of the cluster: SYS0, SYS1, SYS2, and so on. These directories do not duplicate the entire OpenVMS operating system in each cluster member's directory.

  • VMS$COMMON.DIR—also part of the directory tree containing OpenVMS. VMScluster systems need a mechanism to keep track of system-specific files versus cluster-common files. This directory is part of that mechanism. When a VMScluster system accesses a file in these directory trees, it looks first for that file in the system-specific directory. If one does not exist, it then looks in the common directory. In this way, more than one system can share a system disk, but still maintain member-specific files.

  • SYSLOST.DIR—contains orphaned files recovered by the ANALYZE /DISK_STRUCTURE command. Should a directory file be damaged, its files can be found and placed in this directory. It is rarely needed, but it provides insurance against data loss.

There are some other reserved files, mostly of lesser importance; some of them are obsolete or unused. They include BACKUP.SYS, BADBLK.SYS, BADLOG.SYS, CONTIN.SYS, CORIMG.SYS, SECURITY.SYS, and VOLSET.SYS. Some disks might have additional reserved files depending on whether they are part of a multi disk set.

The MFD contains entries for any other top-level directories as created by the system manager or users. They may include user directories or directories containing a particular software product, database, or any other files desired.

This example shows the top-level directory of a small AlphaStation disk used by the author. The author's user directory is shown in boldface:

     $ DIRECTORY DKA0:[000000]     Directory DKA0:[000000]     000000.DIR;1        BACKUP.SYS;1       BADBLK.SYS;1       BADLOG.SYS;1     BITMAP.SYS;1        CONTIN.SYS;1       CORIMG.SYS;1       DECC052.DIR;1     ENGINEERING.DIR;1   INDEXF.SYS;1       MIKE.DIR;1         MMK.DIR;1     SECURITY.SYS;1      SYS0.DIR;1         SYSLOST.DIR;1      TAR.DIR;1     TEMP.DIR;1          TIMESERVE.DIR;1    VMS$COMMON.DIR;1   VOLSET.SYS;1     Total of 20 files. 

Depending on your privileges and site security policy, you may or may not be able to view the top-level directory of a given disk. Many users will be able to view or modify only the contents of their own directories and any subdirectories below it. The inability to view the MFD will not interfere with your use of the system; simply continue as though your login directory is the top-level directory of your own tree.



Getting Started with OpenVMS(c) A Guide for New Users
Getting Started with OpenVMS: A Guide for New Users (HP Technologies)
ISBN: 1555582796
EAN: 2147483647
Year: 2005
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net