Review Board 1.7.22


SQOOP-339 Use of non-portable mknod utility causes build problems on Mac OS X

Review Request #1938 - Created Sept. 16, 2011 and submitted

Joey Echeverria
SQOOP-339
Reviewers
Sqoop
sqoop-trunk
Replaced the use of mknod with mkfifo in NamedFifo to improve compatibility with Mac OS X.
No new tests as the functionality is covered by an existing unit test. I ran the existing unit test and it worked. I don't have a Mac to test on right now, so it might be good to run the unit tests on one before commit.

Diff revision 2

This is not the most recent revision of the diff. The latest diff is revision 6. See what's changed.

1 2 3 4 5 6
1 2 3 4 5 6

  1. src/java/com/cloudera/sqoop/io/NamedFifo.java: Loading...
src/java/com/cloudera/sqoop/io/NamedFifo.java
Revision 38656cb New Change
[20] 56 lines
[+20] [+] public File getFile() {
57
    create(0600);
57
    create(0600);
58
  }
58
  }
59

    
   
59

   
60
  /**
60
  /**
61
   * Create a named FIFO object with the specified fs permissions.
61
   * Create a named FIFO object with the specified fs permissions.
62
   * This depends on the 'mknod' system utility existing. (for example,
62
   * This depends on the 'mknod' or 'mkfifo' (Mac OS X) system utility
63
   * provided by Linux coreutils). This object will be deleted when
63
   * existing. (for example, provided by Linux coreutils). This object
64
   * the process exits.
64
   * will be deleted when the process exits.
65
   * @throws IOException on failure.
65
   * @throws IOException on failure.
66
   */
66
   */
67
  public void create(int permissions) throws IOException {
67
  public void create(int permissions) throws IOException {
68
    String filename = fifoFile.toString();
68
    String filename = fifoFile.toString();
69

    
   
69

   
70
    // Format permissions as a mode string in base 8.
70
    // Format permissions as a mode string in base 8.
71
    String modeStr = Integer.toString(permissions, 8);
71
    String modeStr = Integer.toString(permissions, 8);
72

    
   
72

   
73
    // Create the FIFO itself.
73
    // Create the FIFO itself.

    
   
74
    if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {

    
   
75
      Shell.execCommand("mkfifo", "-m", "0" + modeStr, filename);

    
   
76
    } else {
74
    Shell.execCommand("mknod", "--mode=0" + modeStr, filename, "p");
77
      Shell.execCommand("mknod", "--mode=0" + modeStr, filename, "p");

    
   
78
    }
75

    
   
79

   
76
    // Schedule the FIFO to be cleaned up when we exit.
80
    // Schedule the FIFO to be cleaned up when we exit.
77
    this.fifoFile.deleteOnExit();
81
    this.fifoFile.deleteOnExit();
78
  }
82
  }
79
}
83
}
80

    
   
84

   
  1. src/java/com/cloudera/sqoop/io/NamedFifo.java: Loading...