Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
LU-16977 utils: access_log_reader accesses beyond batch array
[fs/lustre-release.git]
/
lustre
/
utils
/
liblustreapi_pcc.c
diff --git
a/lustre/utils/liblustreapi_pcc.c
b/lustre/utils/liblustreapi_pcc.c
index
398239d
..
47192e5
100644
(file)
--- a/
lustre/utils/liblustreapi_pcc.c
+++ b/
lustre/utils/liblustreapi_pcc.c
@@
-105,7
+105,7
@@
int llapi_pcc_attach(const char *path, __u32 id, enum lu_pcc_type type)
{
int rc;
- switch (type) {
+ switch (type
& LU_PCC_TYPE_MASK
) {
case LU_PCC_READWRITE:
rc = llapi_readwrite_pcc_attach(path, id);
break;
@@
-143,7
+143,7
@@
int llapi_pcc_attach_fid(const char *mntpath, const struct lu_fid *fid,
{
int rc;
- switch (type) {
+ switch (type
& LU_PCC_TYPE_MASK
) {
case LU_PCC_READWRITE:
rc = llapi_readwrite_pcc_attach_fid(mntpath, fid, id);
break;
@@
-193,6
+193,9
@@
int llapi_pcc_detach_fd(int fd, __u32 option)
detach.pccd_opt = option;
rc = ioctl(fd, LL_IOC_PCC_DETACH, &detach);
+ /* If error, save errno value */
+ rc = rc ? -errno : 0;
+
return rc;
}
@@
-212,7
+215,7
@@
int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid,
int fd;
struct lu_pcc_detach_fid detach;
- rc =
get_root_path(WANT_FD, NULL, &fd, (char *)mntpath, -1
);
+ rc =
llapi_root_path_open(mntpath, &fd
);
if (rc) {
llapi_error(LLAPI_MSG_ERROR, rc, "cannot get root path: %s",
mntpath);
@@
-228,7
+231,10
@@
int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid,
*/
detach.pccd_fid = *fid;
detach.pccd_opt = option;
+
rc = ioctl(fd, LL_IOC_PCC_DETACH_BY_FID, &detach);
+ rc = rc ? -errno : 0;
+
close(fd);
return rc;
}
@@
-344,7
+350,7
@@
int llapi_pccdev_set(const char *mntpath, const char *cmd)
rc = llapi_getname(mntpath, buf, sizeof(buf));
if (rc < 0) {
llapi_error(LLAPI_MSG_ERROR, rc,
- "cannot get name for '%s'
\n
", mntpath);
+ "cannot get name for '%s'", mntpath);
return rc;
}
@@
-365,12
+371,12
@@
int llapi_pccdev_set(const char *mntpath, const char *cmd)
rc = errno;
if (errno != EIO)
llapi_error(LLAPI_MSG_ERROR, rc,
- "error: setting llite.%s.pcc=
\"%s\"\n
",
+ "error: setting llite.%s.pcc=
'%s'
",
buf, cmd);
} else if (count < strlen(cmd)) { /* Truncate case */
rc = -EINVAL;
llapi_error(LLAPI_MSG_ERROR, rc,
- "setting llite.%s.pcc=
\"%s\": wrote only %zd\n
",
+ "setting llite.%s.pcc=
'%s': wrote only %zd
",
buf, cmd, count);
}
close(fd);
@@
-394,7
+400,7
@@
int llapi_pccdev_get(const char *mntpath)
rc = llapi_getname(mntpath, pathbuf, sizeof(pathbuf));
if (rc < 0) {
llapi_error(LLAPI_MSG_ERROR, rc,
- "cannot get name for '%s'
\n
", mntpath);
+ "cannot get name for '%s'", mntpath);
return rc;
}
@@
-407,7
+413,7
@@
int llapi_pccdev_get(const char *mntpath)
if (fd < 0) {
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc,
- "error: pccdev_get: opening '%s'
\n
",
+ "error: pccdev_get: opening '%s'",
path.gl_pathv[0]);
goto out_free_param;
}
@@
-416,7
+422,7
@@
int llapi_pccdev_get(const char *mntpath)
if (buf == NULL) {
rc = -ENOMEM;
llapi_error(LLAPI_MSG_ERROR, rc,
- "error: pccdev_get: allocating '%s' buffer
\n
",
+ "error: pccdev_get: allocating '%s' buffer",
path.gl_pathv[0]);
goto out_close;
}
@@
-430,8
+436,7
@@
int llapi_pccdev_get(const char *mntpath)
rc = -errno;
if (errno != EIO) {
llapi_error(LLAPI_MSG_ERROR, rc,
- "error: pccdev_get: "
- "reading failed\n");
+ "error: pccdev_get: reading failed");
}
break;
}
@@
-439,7
+444,7
@@
int llapi_pccdev_get(const char *mntpath)
if (fwrite(buf, 1, count, stdout) != count) {
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc,
- "error: get_param: write to stdout
\n
");
+ "error: get_param: write to stdout");
break;
}
}