char buf[PATH_MAX], mntdir[PATH_MAX];
char *ptr, *ptr_end;
FILE *fp;
- int idx = 0, len = 0, mntlen, fd;
+ int idx = 0, mntlen = 0, fd;
int rc = -ENODEV;
int fsnamelen, mountlen;
rc = 0;
break;
/* Otherwise find the longest matching path */
- } else if ((strlen(path) >= mntlen) && (mntlen >= len) &&
+ } else if ((strlen(path) >= mntlen) &&
(strncmp(mnt.mnt_dir, path, mntlen) == 0)) {
+ /* check the path format */
+ if (strlen(path) > mntlen && path[mntlen] != '/')
+ continue;
strncpy(mntdir, mnt.mnt_dir, sizeof(mntdir) - 1);
mntdir[sizeof(mntdir) - 1] = '\0';
- len = mntlen;
if ((want & WANT_FSNAME) && fsname != NULL) {
strncpy(fsname, ptr, mountlen);
fsname[mountlen] = '\0';
}
rc = 0;
+ break;
}
}
endmntent(fp);
/* Found it */
if (rc == 0) {
if ((want & WANT_PATH) && path != NULL) {
- strncpy(path, mntdir, PATH_MAX);
- path[strlen(mntdir)] = '\0';
+ strncpy(path, mntdir, mntlen);
+ path[mntlen] = '\0';
}
if (want & WANT_FD) {
fd = open(mntdir, O_RDONLY | O_DIRECTORY | O_NONBLOCK);
* LL_IOC_LOV_GETSTRIPE returns only struct lov_user_md.
*/
if (type == GET_LMD_INFO)
- cmd = use_old_ioctl ? LL_IOC_MDC_GETINFO_OLD :
- LL_IOC_MDC_GETINFO;
+ cmd = use_old_ioctl ? LL_IOC_MDC_GETINFO_V1 :
+ LL_IOC_MDC_GETINFO_V2;
else
cmd = LL_IOC_LOV_GETSTRIPE;
retry_getinfo:
ret = ioctl(dir_fd, cmd, lmdbuf);
- if (ret < 0 && errno == ENOTTY && cmd == LL_IOC_MDC_GETINFO) {
- cmd = LL_IOC_MDC_GETINFO_OLD;
+ if (ret < 0 && errno == ENOTTY &&
+ cmd == LL_IOC_MDC_GETINFO_V2) {
+ cmd = LL_IOC_MDC_GETINFO_V1;
use_old_ioctl = true;
goto retry_getinfo;
}
- if (cmd == LL_IOC_MDC_GETINFO_OLD && !ret)
+ if (cmd == LL_IOC_MDC_GETINFO_V1 && !ret)
ret = convert_lmdbuf_v1v2(lmdbuf, lmdlen);
} else if (parent_fd >= 0) {
const char *fname = strrchr(path, '/');
errno = EINVAL;
else {
if (type == GET_LMD_INFO)
- cmd = use_old_ioctl ? IOC_MDC_GETFILEINFO_OLD :
- IOC_MDC_GETFILEINFO;
+ cmd = use_old_ioctl ? IOC_MDC_GETFILEINFO_V1 :
+ IOC_MDC_GETFILEINFO_V2;
else
cmd = IOC_MDC_GETFILESTRIPE;
retry_getfileinfo:
ret = ioctl(parent_fd, cmd, lmdbuf);
if (ret < 0 && errno == ENOTTY &&
- cmd == IOC_MDC_GETFILEINFO) {
- cmd = IOC_MDC_GETFILEINFO_OLD;
+ cmd == IOC_MDC_GETFILEINFO_V2) {
+ cmd = IOC_MDC_GETFILEINFO_V1;
use_old_ioctl = true;
goto retry_getfileinfo;
}
- if (cmd == IOC_MDC_GETFILEINFO_OLD && !ret)
+ if (cmd == IOC_MDC_GETFILEINFO_V1 && !ret)
ret = convert_lmdbuf_v1v2(lmdbuf, lmdlen);
}
}
* not active, just print the object affected by this
* failed target
**/
-static int print_failed_tgt(struct find_param *param, char *path, int type)
+static void print_failed_tgt(struct find_param *param, char *path, int type)
{
struct obd_statfs stat_buf;
struct obd_uuid uuid_buf;
- int ret;
+ int tgt_nr, i, *indexes;
+ int ret = 0;
- if (type != LL_STATFS_LOV && type != LL_STATFS_LMV)
- return -EINVAL;
+ if (type != LL_STATFS_LOV && type != LL_STATFS_LMV) {
+ llapi_error(LLAPI_MSG_NORMAL, ret, "%s: wrong statfs type(%d)",
+ __func__, type);
+ return;
+ }
- memset(&stat_buf, 0, sizeof(struct obd_statfs));
- memset(&uuid_buf, 0, sizeof(struct obd_uuid));
- ret = llapi_obd_statfs(path, type,
- type == LL_STATFS_LOV ? param->fp_obd_index :
- param->fp_mdt_index, &stat_buf,
- &uuid_buf);
- if (ret)
- llapi_error(LLAPI_MSG_NORMAL, ret, "obd_uuid: %s failed",
- param->fp_obd_uuid->uuid);
+ tgt_nr = (type == LL_STATFS_LOV) ? param->fp_obd_index :
+ param->fp_mdt_index;
+ indexes = (type == LL_STATFS_LOV) ? param->fp_obd_indexes :
+ param->fp_mdt_indexes;
- return ret;
+ for (i = 0; i < tgt_nr; i++) {
+ memset(&stat_buf, 0, sizeof(struct obd_statfs));
+ memset(&uuid_buf, 0, sizeof(struct obd_uuid));
+
+ ret = llapi_obd_statfs(path, type, indexes[i], &stat_buf,
+ &uuid_buf);
+ if (ret)
+ llapi_error(LLAPI_MSG_NORMAL, ret,
+ "%s: obd_uuid: %s failed",
+ __func__, param->fp_obd_uuid->uuid);
+ }
}
static int find_check_stripe_size(struct find_param *param)
ret = llapi_ioctl_pack(&data, &rawbuf, sizeof(raw));
if (ret != 0) {
llapi_error(LLAPI_MSG_ERROR, ret,
- "llapi_obd_statfs: error packing ioctl data");
+ "%s: error packing ioctl data", __func__);
goto out;
}
rc = llapi_ioctl_pack(&data, &rawbuf, sizeof(raw));
if (rc != 0) {
llapi_error(LLAPI_MSG_ERROR, rc,
- "llapi_obd_statfs: error packing ioctl data");
+ "%s: error packing ioctl data", __func__);
return rc;
}
rc = ioctl(root, OBD_IOC_QUOTACTL, qctl);
if (rc < 0)
rc = -errno;
+ if (rc == -ENOENT && LUSTRE_Q_CMD_IS_POOL(qctl->qc_cmd))
+ llapi_error(LLAPI_MSG_ERROR | LLAPI_MSG_NO_ERRNO, rc,
+ "Cannot find pool '%s'", qctl->qc_poolname);
close(root);
return rc;