- if (ret) {
- if (errno == ENOTTY) {
- /* ioctl is not supported, it is not a lustre fs.
- * Do the regular lstat(2) instead. */
- ret = lstat_f(path, st);
- if (ret) {
- ret = -errno;
- llapi_error(LLAPI_MSG_ERROR, ret,
- "error: %s: lstat failed for %s",
- __func__, path);
- }
- } else if (errno == ENOENT) {
- ret = -errno;
- llapi_error(LLAPI_MSG_WARN, ret,
- "warning: %s: %s does not exist",
- __func__, path);
- } else if (errno != EISDIR) {
- ret = -errno;
- llapi_error(LLAPI_MSG_ERROR, ret,
- "%s ioctl failed for %s.",
- dir ? "LL_IOC_MDC_GETINFO" :
- "IOC_MDC_GETFILEINFO", path);
- } else {
+ ret = snprintf(lmdbuf, lmdlen, "%s", fname);
+ if (ret < 0)
+ errno = -ret;
+ else if (ret >= lmdlen || ret++ == 0)
+ errno = EINVAL;
+ else
+ ret = ioctl(parent_fd, type == GET_LMD_INFO ?
+ IOC_MDC_GETFILEINFO :
+ IOC_MDC_GETFILESTRIPE, lmdbuf);
+ }
+
+ if (ret && type == GET_LMD_INFO) {
+ if (errno == ENOTTY) {
+ /* ioctl is not supported, it is not a lustre fs.
+ * Do the regular lstat(2) instead.
+ */
+ ret = lstat_f(path, st);
+ if (ret) {
+ ret = -errno;
+ llapi_error(LLAPI_MSG_ERROR, ret,
+ "error: %s: lstat failed for %s",
+ __func__, path);
+ }
+ } else if (errno == ENOENT) {
+ ret = -errno;
+ llapi_error(LLAPI_MSG_WARN, ret,
+ "warning: %s does not exist", path);
+ } else if (errno != EISDIR && errno != ENODATA) {