#define LLAPI_MSG_NO_ERRNO 0x00000010
extern void llapi_msg_set_level(int level);
-extern void llapi_error(int level, int rc, char *fmt, ...);
-#define llapi_err_noerrno(level, fmt, a...) \
+
+void llapi_error(int level, int rc, const char *fmt, ...)
+ __attribute__((__format__(__printf__, 3, 4)));
+#define llapi_err_noerrno(level, fmt, a...) \
llapi_error((level) | LLAPI_MSG_NO_ERRNO, 0, fmt, ## a)
-extern void llapi_printf(int level, char *fmt, ...);
+void llapi_printf(int level, const char *fmt, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+
extern int llapi_file_create(const char *name, unsigned long long stripe_size,
int stripe_offset, int stripe_count,
int stripe_pattern);
*/
int read_proc_entry(char *proc_path, char *buf, int len)
{
- int rc, fd;
+ int rc, fd;
- memset(buf, 0, len);
+ memset(buf, 0, len);
- fd = open(proc_path, O_RDONLY);
- if (fd == -1) {
- llapi_error(LLAPI_MSG_ERROR, -errno, "open('%s') failed: %s\n",
- proc_path);
- return -2;
- }
+ fd = open(proc_path, O_RDONLY);
+ if (fd < 0) {
+ llapi_error(LLAPI_MSG_ERROR, -errno, "cannot open '%s'",
+ proc_path);
+ return -2;
+ }
- rc = read(fd, buf, len - 1);
- if (rc < 0) {
- llapi_error(LLAPI_MSG_ERROR, -errno,
- "read('%s') failed: %s\n", proc_path);
- rc = -3;
- } else if (rc == 0) {
- llapi_err_noerrno(LLAPI_MSG_ERROR,
- "read('%s') zero bytes\n", proc_path);
- rc = -4;
- } else if (/* rc > 0 && */ buf[rc - 1] == '\n') {
- buf[rc - 1] = '\0'; /* Remove trailing newline */
- }
- close(fd);
+ rc = read(fd, buf, len - 1);
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, -errno,
+ "error reading from '%s'", proc_path);
+ rc = -3;
+ } else if (rc == 0) {
+ llapi_err_noerrno(LLAPI_MSG_ERROR,
+ "read zero bytes from '%s'", proc_path);
+ rc = -4;
+ } else if (buf[rc - 1] == '\n') {
+ buf[rc - 1] = '\0'; /* Remove trailing newline */
+ }
- return (rc);
+ close(fd);
+
+ return rc;
}
int compare(struct lov_user_md *lum_dir, struct lov_user_md *lum_file1,
int i;
FILE *fp;
- fp = popen("\\ls -d /proc/fs/lustre/lov/*clilov* | head -1", "r");
- if (!fp) {
- llapi_error(LLAPI_MSG_ERROR, -errno,
- "open(lustre/lov/*clilov*) failed: %s\n");
- return 2;
- }
- if (fscanf(fp, "%s", lov_path) < 1) {
- llapi_error(LLAPI_MSG_ERROR, -EINVAL,
- "read(lustre/lov/*clilov*) failed: %s\n");
- pclose(fp);
- return 3;
+ fp = popen("\\ls -d /proc/fs/lustre/lov/*clilov* | head -1", "r");
+ if (fp == NULL) {
+ llapi_error(LLAPI_MSG_ERROR, -errno,
+ "open(lustre/lov/*clilov*) failed");
+ return 2;
}
+
+ if (fscanf(fp, "%s", lov_path) < 1) {
+ llapi_error(LLAPI_MSG_ERROR, -EINVAL,
+ "read(lustre/lov/*clilov*) failed");
+ pclose(fp);
+ return 3;
+ }
+
pclose(fp);
snprintf(tmp_path, sizeof(tmp_path) - 1, "%s/stripecount",
*
* This particular tool can also import an existing HSM archive.
*/
-
+#include <stdint.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <errno.h>
#include <utime.h>
#include <sys/xattr.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <sys/errno.h>
#include <lustre/lustre_idl.h>
#include <lustre/lustreapi.h>
if ((opt.o_archive_cnt >= MAX_ARCHIVE_CNT) ||
(atoi(optarg) >= MAX_ARCHIVE_CNT)) {
CT_ERROR("archive number must be less"
- "than %lu\n", MAX_ARCHIVE_CNT);
+ "than %zu\n", MAX_ARCHIVE_CNT);
return -E2BIG;
}
opt.o_archive_id[opt.o_archive_cnt] = atoi(optarg);
rc = lseek(src_fd, hai->hai_extent.offset, SEEK_SET);
if (rc < 0) {
- CT_ERROR("'%s' seek to read to "LPU64" (len %zu)"
+ CT_ERROR("'%s' seek to read to "LPU64" (len %jd)"
" failed (%s)\n",
- src, hai->hai_extent.offset, src_st.st_size,
+ src, hai->hai_extent.offset, (intmax_t)src_st.st_size,
strerror(errno));
rc = -errno;
goto out;
rc = ftruncate(dst_fd, src_st.st_size);
if (rc < 0) {
rc = -errno;
- CT_ERROR("'%s' final truncate to %lu failed (%s)\n",
- dst, src_st.st_size, strerror(-rc));
+ CT_ERROR("'%s' final truncate to %jd failed (%s)\n",
+ dst, (intmax_t)src_st.st_size, strerror(-rc));
err_major++;
}
}
}
/* llapi_error will preserve errno */
-void llapi_error(int level, int _rc, char *fmt, ...)
+void llapi_error(int level, int _rc, const char *fmt, ...)
{
va_list args;
int tmp_errno = errno;
}
/* llapi_printf will preserve errno */
-void llapi_printf(int level, char *fmt, ...)
+void llapi_printf(int level, const char *fmt, ...)
{
va_list args;
int tmp_errno = errno;
}
if ((stripe_size & (LOV_MIN_STRIPE_SIZE - 1))) {
rc = -EINVAL;
- llapi_error(LLAPI_MSG_ERROR, rc, "error: bad stripe_size %lu, "
+ llapi_error(LLAPI_MSG_ERROR, rc, "error: bad stripe_size %llu, "
"must be an even multiple of %d bytes",
stripe_size, page_size);
return rc;
param->lmd = malloc(sizeof(lstat_t) + param->lumlen);
if (param->lmd == NULL) {
llapi_error(LLAPI_MSG_ERROR, -ENOMEM,
- "error: allocation of %d bytes for ioctl",
+ "error: allocation of %zu bytes for ioctl",
sizeof(lstat_t) + param->lumlen);
return -ENOMEM;
}
close(fd);
if (rc < sizeof(random)) {
llapi_error(LLAPI_MSG_ERROR, errno,
- "Cannot read %d bytes from /dev/urandom\n",
+ "cannot read %zu bytes from /dev/urandom",
sizeof(random));
return -errno;
}
for (rc = 0; rc < archive_count; rc++) {
if (archives[rc] > 8 * sizeof(ct->archives)) {
llapi_err_noerrno(LLAPI_MSG_ERROR,
- "Maximum of %d archives supported",
+ "maximum of %zu archives supported",
8 * sizeof(ct->archives));
goto out_err;
}