public static OpenAction getOpenAction(int flag) {
    // open flags must contain one of O_RDONLY(0), O_WRONLY(1), O_RDWR(2)
    // O_ACCMODE is mask of read write(3)
    // Alluxio fuse only supports read-only for completed file
    // and write-only for file that does not exist or contains open flag O_TRUNC
    // O_RDWR will be treated as read-only if file exists and no O_TRUNC,
    // write-only otherwise
    switch (OpenFlags.valueOf(flag & O_ACCMODE.intValue())) {
      case O_RDONLY:
        return OpenAction.READ_ONLY;
      case O_WRONLY:
        return OpenAction.WRITE_ONLY;
      case O_RDWR:
        return OpenAction.READ_WRITE;
      default:
        // Should not fall here
        return OpenAction.NOT_SUPPORTED;
    }
  }
@Test
  public void readOnly() {
    int[] readFlags = new int[]{0x8000, 0x9000};
    for (int readFlag : readFlags) {
      Assert.assertEquals(AlluxioFuseOpenUtils.OpenAction.READ_ONLY,
          AlluxioFuseOpenUtils.getOpenAction(readFlag));
    }
  }