Commons IO
  1. Commons IO
  2. IO-109

FileSystemUtils freeSpaceUnix does not work for HP-UX 11

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.4
    • Component/s: Utilities
    • Labels:
      None
    • Environment:

      uname -a
      HP-UX mbfwdv B.11.11 U 9000/800 3509210950 unlimited-user license

      Description

      The freeSpaceUnix method does not work under HP-UX. The df command under HP-UX is the old System V varient and the fields are not in the correct order. This diff modifies the code to use the 'bdf' command when HP-UX is detected:

      — FileSystemUtils.java 2006-03-19 12:42:48.000000000 -0800
      +++ FileSystemUtils-HP-UX-Fix.java 2007-01-11 13:05:34.844269000 -0800
      @@ -51,13 +51,15 @@
      private static final int WINDOWS = 1;
      /** Operating system state flag for Unix. */
      private static final int UNIX = 2;
      + /** Unix variant name */
      + private static String osName = null;

      /** The operating system flag. */
      private static final int OS;
      static {
      int os = OTHER;
      try {

      • String osName = System.getProperty("os.name");
        + osName = System.getProperty("os.name");
        if (osName == null) { throw new IOException("os.name not found"); }

        @@ -287,9 +289,18 @@
        }
        path = FilenameUtils.normalize(path);

      + // HP-UX sucks we need to use bdf instead
      + String dfCmd = "df";
      + String dfOpts = "-k";
      + if (osName.indexOf("hp-ux") != -1)
      +

      { + dfCmd = "bdf"; + dfOpts = ""; + }

      +
      // build and run the 'dir' command
      String[] cmdAttribs =

      • (kb ? new String[] {"df", "-k", path}

        : new String[]

        {"df", path}

        );
        + (kb ? new String[]

        {dfCmd, dfOpts, path}

        : new String[]

        {dfCmd, path}

        );

      // read the output from the command until we come to the second line
      long bytes = -1;

        Issue Links

          Activity

          Hide
          Henri Yandell added a comment - - edited

          Thanks Michael,

          The easiest would be to test whether "df -kP" works, and that its output has the same format as "df -k" does on Linux.

          Alternatively - whether FileSystemUtils.freeSpaceKb("/home/michael") works happily.

          Either would be great

          Show
          Henri Yandell added a comment - - edited Thanks Michael, The easiest would be to test whether "df -kP" works, and that its output has the same format as "df -k" does on Linux. Alternatively - whether FileSystemUtils.freeSpaceKb("/home/michael") works happily. Either would be great
          Hide
          michaelo added a comment - - edited

          Henri,

          we have some HP-UX 11i servers, at work. What do you want me to test exactly?

          Show
          michaelo added a comment - - edited Henri, we have some HP-UX 11i servers, at work. What do you want me to test exactly?
          Hide
          Henri Yandell added a comment -

          Looking at http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds2/df.htm it seems to imply that -P exists on System V. So marking this as FIXED.

          If anyone has access to HP-UX, it'd be great to test this and let us know.

          Show
          Henri Yandell added a comment - Looking at http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds2/df.htm it seems to imply that -P exists on System V. So marking this as FIXED. If anyone has access to HP-UX, it'd be great to test this and let us know.
          Hide
          Niall Pemberton added a comment -

          As theres been no response can we close this as fixed in 1.3?

          Show
          Niall Pemberton added a comment - As theres been no response can we close this as fixed in 1.3?
          Hide
          Henri Yandell added a comment -

          Marking these as 1.4 fix versions - not that we'll have any access to said platforms so it's more a question of cleaning these issues up if we don't hear back by the time of 1.4.

          Show
          Henri Yandell added a comment - Marking these as 1.4 fix versions - not that we'll have any access to said platforms so it's more a question of cleaning these issues up if we don't hear back by the time of 1.4.
          Hide
          Stephen Colebourne added a comment -

          The new IO v1.3 release is going to use -kP. Let us know if this works.

          Show
          Stephen Colebourne added a comment - The new IO v1.3 release is going to use -kP. Let us know if this works.

            People

            • Assignee:
              Unassigned
              Reporter:
              Christopher Olsen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development