com.ibm.jzos

Class FileAttribute

  • java.lang.Object
    • com.ibm.jzos.FileAttribute


  • public final class FileAttribute
    extends java.lang.Object
    A class with static methods for retrieving and setting USS specific file attributes.

    Uses C Library __chattr() and stat() APIs.

    For more information, refer to the __chattr() and stat() library functions in "z/OS XL C/C++ Run-Time Library Reference, SA22-7821". Or to the chattr and stat assembler services in "z/OS UNIX System Services Programming: Assembler Callable Services Reference, SA23-2281-00".

    Since:
    2.4.6
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  FileAttribute.Stat
      Contains USS file attribute values.
      static class  FileAttribute.Tag
      Represents a USS file tag.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static FileAttribute.Stat getStat(java.lang.String pathname)
      Retrieve file attributes associated with the given USS file.
      static void setApfAuthorized(java.lang.String pathname, boolean value)
      Given a USS file with the specified pathname, set its APF authorized extended attribute.
      static void setAuditorAuditInfo(java.lang.String pathname, int info)
      Given a USS file with the specified pathname, set its auditor audit flags.
      static void setChangeTime(java.lang.String pathname)
      Given a USS file with the specified pathname, set its change time attribute to the current time.
      static void setChangeTime(java.lang.String pathname, java.nio.file.attribute.FileTime time)
      Given a USS file with the specified pathname, set its change time attribute.
      static void setFormat(java.lang.String pathname, byte format)
      Given a USS file with the specified pathname, set its file format.
      static void setNoShareas(java.lang.String pathname, boolean value)
      Given a USS file with the specified pathname, set its no shareas extended attribute.
      static void setProgramControlled(java.lang.String pathname, boolean value)
      Given a USS file with the specified pathname, set its program controlled extended attribute.
      static void setSecurityLabel(java.lang.String pathname, java.lang.String label)
      Given a USS file with the specified pathname, set its security label.
      static void setSharedLibrary(java.lang.String pathname, boolean value)
      Given a USS file with the specified pathname, set its shared library extended attribute.
      static void setTag(java.lang.String pathname, FileAttribute.Tag tag)
      Given a USS file with the specified pathname, set its file tag.
      static void setUserAuditInfo(java.lang.String pathname, int info)
      Given a USS file with the specified pathname, set its user audit flags.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setSharedLibrary

        public static void setSharedLibrary(java.lang.String pathname,
                                            boolean value)
        Given a USS file with the specified pathname, set its shared library extended attribute.

        For more information on setting the shared library attribute, refer to the section titled "Defining UNIX files as shared library programs" in the reference "z/OS UNIX System Services Planning, GA22-7800".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        value - the shared library extended attribute value to set
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setNoShareas

        public static void setNoShareas(java.lang.String pathname,
                                        boolean value)
        Given a USS file with the specified pathname, set its no shareas extended attribute.

        For more information on extended attributes for files, refer to the "z/OS UNIX System Services Command Reference, SA22-7802".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        value - the no shareas extended attribute value to set
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setApfAuthorized

        public static void setApfAuthorized(java.lang.String pathname,
                                            boolean value)
        Given a USS file with the specified pathname, set its APF authorized extended attribute.

        For more information on setting the APF authorized attribute, refer to the section titled "Defining UNIX files as APF-authorized programs" in the reference "z/OS UNIX System Services Planning, GA22-7800".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        value - the APF authorized extended attribute value to set
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setProgramControlled

        public static void setProgramControlled(java.lang.String pathname,
                                                boolean value)
        Given a USS file with the specified pathname, set its program controlled extended attribute.

        For more information on setting the program controlled attribute, refer to the reference "z/OS UNIX System Services Planning, GA22-7800".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        value - the program controlled extended attribute value to set
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setAuditorAuditInfo

        public static void setAuditorAuditInfo(java.lang.String pathname,
                                               int info)
        Given a USS file with the specified pathname, set its auditor audit flags. Audit attributes determine whether or not accesses to a file are audited by the system authorization facility (SAF) interface.

        For more information on specifying file audit options, refer to the section titled "Auditing access to files and directories" in the reference "z/OS UNIX System Services Planning, GA22-7800".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        info - the auditor audit flags to set
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setUserAuditInfo

        public static void setUserAuditInfo(java.lang.String pathname,
                                            int info)
        Given a USS file with the specified pathname, set its user audit flags. Audit attributes determine whether or not accesses to a file are audited by the system authorization facility (SAF) interface.

        For more information on specifying file audit options, refer to the section titled "Auditing access to files and directories" in the reference "z/OS UNIX System Services Planning, GA22-7800".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        info - the user audit flags to set
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setChangeTime

        public static void setChangeTime(java.lang.String pathname)
        Given a USS file with the specified pathname, set its change time attribute to the current time.
        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setChangeTime

        public static void setChangeTime(java.lang.String pathname,
                                         java.nio.file.attribute.FileTime time)
        Given a USS file with the specified pathname, set its change time attribute. Use 64-bit JVM for setting time values beyond year 2038.
        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        time - the change time value to set, if null, will set the change time to the current time
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
        java.lang.IllegalArgumentException - if the time value is prior to 1970, or if the time value is beyond 2038 and running 31-bit JVM.
      • setFormat

        public static void setFormat(java.lang.String pathname,
                                     byte format)
        Given a USS file with the specified pathname, set its file format.

        For more information on specifying format of the file, refer to the "chattr" syscall command description in the reference "z/OS Using REXX and z/OS UNIX System Services, SA22-7806".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        format - the file format to set
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setTag

        public static void setTag(java.lang.String pathname,
                                  FileAttribute.Tag tag)
        Given a USS file with the specified pathname, set its file tag.

        For more information on tagging of files, refer to the section titled "Converting files between code pages" in the reference "z/OS UNIX System Services Planning, GA22-7800".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        tag - the file tag to set
        Throws:
        java.lang.NullPointerException - if pathname or tag is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
      • setSecurityLabel

        public static void setSecurityLabel(java.lang.String pathname,
                                            java.lang.String label)
        Given a USS file with the specified pathname, set its security label.

        For more information on security labels, refer to the section titled "Using security labels" in the reference "z/OS UNIX System Services Planning, GA22-7800".

        Parameters:
        pathname - full path of the USS file on which attribute value will be changed
        label - the security label to set, cannot be more than 8 characters. If less than 8 characters, the label will be padded on the right with blanks
        Throws:
        java.lang.NullPointerException - if pathname or label is null.
        ErrnoException - if the underlying __chattr() call was unsuccessful.
        java.lang.IllegalArgumentException - if the specified label is more than 8 characters long.
      • getStat

        public static FileAttribute.Stat getStat(java.lang.String pathname)
        Retrieve file attributes associated with the given USS file.
        Parameters:
        pathname - full path of the USS file
        Returns:
        file attributes associated with the given USS file.
        Throws:
        java.lang.NullPointerException - if pathname is null.
        ErrnoException - if the underlying stat() call was unsuccessful.
� Copyright IBM Corporation 2005, 2022.