public static RequiredPrivileges getPrivilegesFromFS(Path filePath, HiveConf conf,
      String userName) throws HiveAuthzPluginException {
    // get the 'available privileges' from file system

    RequiredPrivileges availPrivs = new RequiredPrivileges();
    // check file system permission
    FileSystem fs;
    try {
      fs = FileSystem.get(filePath.toUri(), conf);
      FileStatus[] fileMatches = fs.globStatus(filePath);

      // There are a couple of possibilities to consider here to see if we should recurse or not.
      // a) Path is a regex, and may match multiple entries - if so, this is likely a load and
      //        we should listStatus for all relevant matches, and recurse-check each of those.
      //        Simply passing the filestatus on as recurse=true makes sense for this.
      // b) Path is a singular directory/file and exists
      //        recurse=true to check all its children if applicable
      // c) Path is a singular entity that does not exist
      //        recurse=false to check its parent - this is likely a case of
      //        needing to create a dir that does not exist yet.

      if ((fileMatches != null ) && (fileMatches.length > 1)){
        LOG.debug("Checking fs privileges for multiple files that matched {}",
            filePath.toString());
        addPrivilegesFromFS(userName, availPrivs, fs, fileMatches, true);
      } else {
        FileStatus fileStatus = FileUtils.getFileStatusOrNull(fs, filePath);
        boolean pickParent = (fileStatus == null); // did we find the file/dir itself?
        if (pickParent){
          fileStatus = FileUtils.getPathOrParentThatExists(fs, filePath.getParent());
        }
        Path path = fileStatus.getPath();
        if (pickParent){
          LOG.debug("Checking fs privileges for parent path {} for nonexistent {}",
              path.toString(), filePath.toString());
          addPrivilegesFromFS(userName, availPrivs, fs, fileStatus, false);
        } else {
          LOG.debug("Checking fs privileges for path itself {}, originally specified as {}",
              path.toString(), filePath.toString());
          addPrivilegesFromFS(userName, availPrivs, fs, fileStatus, true);
        }
      }
    } catch (Exception e) {
      String msg = "Error getting permissions for " + filePath + ": " + e.getMessage();
      throw new HiveAuthzPluginException(msg, e);
    }
    return availPrivs;
  }
Map permissions for this uri to SQL Standard privileges
@param filePath
@param conf
@param userName
@return
@throws HiveAuthzPluginException
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/SQLAuthorizationUtils.java