IFS Commands Give You Generic Access
October 3, 2007 Bruce Guetzkow
Note: The code accompanying this article is available for download here. Many i5/OS commands allow you to enter a generic name, such as OBJ*, to reference a collection of objects all beginning with the string OBJ. For example, the Delete File (DLTF) command allows you to delete a group of files using a generic name. Unfortunately there are some commands where generic names are not an option, like the Change Object Owner (CHGOBJOWN) command. The solution for some of these commands is to use their Integrated File System (IFS) equivalents. Starting at the Top The IFS is the part of i5/OS that supports files like those normally found on PC and Unix systems. Each of these systems can be accessed in a similar manner using a directory structure. The file system most familiar to many i5 professionals is the Library File System, also referred to as QSYS.LIB. In traditional Command Language (CL) commands and programs we reference an object using a library/name syntax. For example, a program named PGM123 in library BRUCE would be named BRUCE/PGM123, and its object type would be *PGM. However, you can also refer to the same object from the IFS perspective using a directory/object.type syntax. As in any PC-like directory structure, you build a path to an object from the top down. All objects on the System i are in library QSYS, so that is always the first component of the IFS name. If the object is in a library other than QSYS, that library is the next branch of the tree. The object and type follow. If the object is a database file, the member comes last. Each part of the path name must also be qualified with the type of object it represents. In my example we have an object of type *PGM in library BRUCE, and that library is in library QSYS. So, starting from the top we have the following: • QSYS.LIB • BRUCE.LIB • PGM123.PGM The object qualifier is the same as the object type without the leading asterisk (*). Putting this together in the form of a path name we get: /QSYS.LIB/BRUCE.LIB/PGM123.PGM If we take a physical file named BRUCE/MYFILE with a member of MYMBR, the equivalent IFS path name would be: /QSYS.LIB/BRUCE.LIB/MYFILE.FILE/MYMBR.MBR On the Right Path As is the norm with the Library File System, object names are not case-sensitive. The following are all references to the same object: • /QSYS.LIB/BRUCE.LIB/PGM123.PGM • /qsys.lib.bruce.lib/pgm123.pgm • /QSYS.lib/bruce.LIB/PgM123.pGm You can then take any path and insert an asterisk (*) into the last segment of the path to get a generic name. For example, to reference all programs in library BRUCE, you would specify a path of /QSYS.LIB/BRUCE.LIB/*.PGM. For all objects beginning with XYZ in the same library you would use /QSYS.LIB/BRUCE.LIB/XYZ*.*. If you are using independent Auxiliary Storage Pools (ASP) you need to also include the ASP-name ahead of QSYS, like this /asp-name/QSYS.LIB/BRUCE.LIB/PGM123A.PGM. Now that you can reference an IFS path name, you can make use of some IFS commands that work with the Library File System. To find a complete list of these commands, go to the IBM Information Center. (For V5R4, go to http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp.) Once in the Information Center, drill-down through “Files and File Systems” → “Integrated File System” → “File Systems” → “Library File System” (QSYS.LIB), and select “Integrated File System Commands and Displays” in the QSYS.LIB file system. Select the link “Accessing using CL commands” in the body of the document. Taking Command As I indicated, the CHGOBJOWN command does not allow the use of a generic object name. Instead we can now use the IFS-equivalent command: Change Owner (CHGOWN). This command accepts a path name for the object parameter, and will allow us to specify a generic name. The parameters for the two commands are similar. For CHGOBJOWN they are: • OBJ - Object name • OBJTYPE - Object type • ASPDEV - ASP device name • NEWOWN - New owner name (user profile) • CUROWNAUT - Revoke or leave current owner authorities For CHGOWN the parameters are: • OBJ - Object path (includes object type and ASP name if appropriate) • NEWOWN - New owner name (user profile) • RVKOLDAUT - Similar to CUROWNAUT above • SUBTREE - Applies to directories • SYMLNK - Applies to symbolic IFS links To change the owner of all data areas in library SMITH to user profile FRED and revoke the previous owner’s authority we specify: CHGOWN OBJ(/QSYS.LIB/SMITH.LIB/*.DTAARA) NEWOWN(FRED) The alternative is to run the CHGOBJOWN command for each object separately. As you can see, if there are a lot of qualifying objects, this can be cumbersome. However, using the CHGOWN command with a generic path simplifies the task greatly. Remember to specify your generic path name carefully as you can also easily affect objects you hadn’t intended to if you specify the wrong path. Time Savers The IFS-style commands that I find most useful with QSYS.LIB are: • CHGATR - Change Attribute • CHGAUD - Change Auditing Value • CHGOWN - Change Owner • DSPAUT - Display Authority • DSPLNK - Display Links • MOV - Move • RNM - Rename • WRKAUT - Work with Authority • WRKLNK - Work with Links Some of these commands require specific authority to use them with QSYS.LIB or have restricted uses, but any limitations are easily determined from the command help text. Here’s one more way to simplify the task. I’ve created the command Retrieve Object Path (RTVOBJPATH) to make it even easier to determine the path name for a QSYS.LIB object. The command parameters are as follows: • OBJECT - Object name with Library • MBR - Member name (default *NONE) • OBJTYPE - Object Type • VLDOBJ - Validate Object (default *NO) • PATH - Return value for path name (90-bytes) Simply specify the pertinent values and the path name is returned in the PATH parameter. (Since we don’t use independent ASPs where I work, there is no logic in the command to add that to the path, but you could easily add it if needed.) You can specify any object, even if it doesn’t exist, unless you indicate VLDOBJ(*YES) or if you use special values that need to be resolved (*LIBL, *FIRST, etc.). Error message ID CPF9897 is returned and can be monitored for the following conditions:
Now you have an easy way to use a generic object name by using the IFS path name, and an easy way to build that path name. So try out a new command and save yourself a little time.
|