Whamcloud - gitweb
LU-6803 gss: add printf format checking to printerr()
[fs/lustre-release.git] / lustre / utils / lhsmtool_posix.c
index d1fc084..0f9c793 100644 (file)
 #include <getopt.h>
 #include <pthread.h>
 #include <time.h>
+#include <unistd.h>
 #include <utime.h>
 #include <sys/time.h>
 #include <sys/xattr.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
+#include <libcfs/util/string.h>
 #include <lustre/lustre_idl.h>
 #include <lustre/lustreapi.h>
 
@@ -347,7 +349,7 @@ static int ct_parseopts(int argc, char * const *argv)
        CT_TRACE("action=%d src=%s dst=%s mount_point=%s",
                 opt.o_action, opt.o_src, opt.o_dst, opt.o_mnt);
 
-       if (!opt.o_dry_run && opt.o_hsm_root == NULL) {
+       if (opt.o_hsm_root == NULL) {
                rc = -EINVAL;
                CT_ERROR(rc, "must specify a root directory for the backend");
                return rc;
@@ -517,7 +519,7 @@ static int ct_copy_data(struct hsm_copyaction_private *hcp, const char *src,
        struct stat              dst_st;
        char                    *buf = NULL;
        __u64                    write_total = 0;
-       __u64                    length;
+       __u64                    length = hai->hai_extent.length;
        time_t                   last_report_time;
        int                      rc = 0;
        double                   start_ct_now = ct_now();
@@ -559,8 +561,8 @@ static int ct_copy_data(struct hsm_copyaction_private *hcp, const char *src,
        }
 
        /* Don't read beyond a given extent */
-       length = min(hai->hai_extent.length,
-                    src_st.st_size - hai->hai_extent.offset);
+       if (length > src_st.st_size - hai->hai_extent.offset)
+               length = src_st.st_size - hai->hai_extent.offset;
 
        start_time = last_bw_print = last_report_time = time(NULL);
 
@@ -1650,7 +1652,7 @@ static int ct_rebind_list(const char *list)
        if (line)
                free(line);
 
-       /* return 0 if all rebinds were sucessful */
+       /* return 0 if all rebinds were successful */
        CT_TRACE("%u lines read from '%s', %u rebind successful", nl, list, ok);
 
        return ok == nl ? 0 : -1;