The IFS_OBJECT_STATISTICS table function has always returned whether the object in the IFS is a symbolic link, *SYMLNK, but not where its links. As part of the last of the latest round of Technology Refreshes a new column has been added to the table function's results to give us that information.
I feel I need to explain what a symbolic link is before I give an example from IFS_OBJECT_STATISTICS.
Symbolic links are a special kind of object only found in the IFS. They are identified by their own object type, *SYMLNK. Think of them like a Windows shortcut. These files contain the path name to another file or location in your partition.
You create symbolic links with the Add Link command, ADDLNK:
01 ADDLNK OBJ('/www') 02 NEWLNK('/home/MyFolder/subfolder1') 03 LNKTYPE(*SYMBOLIC) |
In the above example I wanted to create a symbolic link to the www folder.
Line 1: The Object parameter, OBJ, contains the name of the destination path. In this case it is the www folder.
Line 2: The New Link parameter, NEWLNK, is path of the symbolic link that will be created.
Line 3: I need to tell the command what kind of object to create by using the Link Type parameter, LNKTYPE. I am sure it does not come as a surprise that *SYMBOLIC is the link type for a symbolic link.
If I want to delete a symbolic link I can use the Remove Link command, RMVLNK.
Now I can show you what this new column looks like.
01 SELECT PATH_NAME,OBJECT_TYPE,SYMBOLIC_LINK 02 FROM TABLE (QSYS2.IFS_OBJECT_STATISTICS( 03 START_PATH_NAME => '/home/MyFolder/')) ; |
Line 1: I wanted returned the path name, PATH_NAME, object type, OBJECT_TYPE, and the new column for the symbolic link's destination, SYMBOLIC_LINK.
Line 3: I am using the Start Path Name parameter to limit the results to the contents of my folder.
The results look like:
OBJECT SYMBOLIC PATH_NAME _TYPE _LINK --------------------------- ------- -------- /home/MyFolder/ *DIR <NULL> /home/MyFolder/subfolder1 *SYMLNK /www /home/MyFolder/testfile.csv *STMF <NULL> /home/MyFolder/subfolder2 *DIR <NULL> |
Most of the results return null in the symbolic link column as they are not symbolic links. Only the link I created above has a value in the column, which is the destination of the symbolic link.
To see this new symbolic link in action I open the "Integrate File System" tool in ACS. I get there from one of my 5250 sessions by using: Actions > Integrated File System.
This picture shows the contents of my folder. I know that it is hard to see but the logo for subfolder1 has a little arrow on it, like the Windows shortcut logo.
If I double click on subfolder1 I am sent to the symbolic link's destination. In the image below on the left is how the symbolic link's destination is displayed. Notice that in the "Directory" field is the symbolic link, not the actual destination's path. To compare on the right is the contents of the www folder if I go there directly.
I can show better examples of the usefulness of the SYMBOLIC_LINK columns when I expand the range of my results:
01 SELECT PATH_NAME,OBJECT_TYPE,SYMBOLIC_LINK 02 FROM TABLE (QSYS2.IFS_OBJECT_STATISTICS( 03 START_PATH_NAME => '/', 04 SUBTREE_DIRECTORIES => 'YES', 05 OBJECT_TYPE_LIST => '*SYMLNK' )) 06 WHERE OBJECT_TYPE = '*SYMLNK' ; |
Line 1: The same three columns as I used in the Select statement for my folder.
Line 3: This time I want to start at the root folder ( / ).
Line 4: And include all subfolders/subdirectories in the root folder.
Line 5: Only looking for symbolic links.
Line 6: This line may appear redundant as I have already asked for only symbolic links in my results. I am returned the subfolders in the root in my results too. As I do not want those to show I have this Where clause to only select objects that have the type of *SYMLNK.
OBJECT SYMBOLIC PATH_NAME _TYPE _LINK --------------------------- ------- -------- /bin *SYMLNK /usr/bin /lib *SYMLNK /usr/lib /lib64 *SYMLNK /usr/lib64 /QOpenSys/QOpenSys *SYMLNK . /QOpenSys/bin *SYMLNK usr/bin /QOpenSys/lib *SYMLNK usr/lib /QOpenSys/lib64 *SYMLNK usr/lib64 |
These are not all of the results from the partition I am using. They are just a sample to show how IBM has created symbolic links in its own folders.
In my opinion this new column, SYMBOLIC_LINK, is a good addition to IFS_OBJECT_STATISTICS as now I know the destination of any symbolic link in my results.
You can learn more about this from the IBM website:
This article was written for IBM i 7.4 TR4 and 7.3 TR10.
Excelente...
ReplyDeleteEXCELLENT! Needed with the types of applications we're now writing.
ReplyDelete