Whamcloud - gitweb
LU-12514 utils: add "lustre_tgt" filesystem type
[fs/lustre-release.git] / lustre / utils / liblustreapi.c
index 600e732..9a29475 100644 (file)
@@ -69,6 +69,7 @@
 #endif
 #include <poll.h>
 #include <time.h>
+#include <inttypes.h>
 
 #include <libcfs/util/ioctl.h>
 #include <libcfs/util/param.h>
@@ -405,7 +406,7 @@ int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset,
                rc = -EINVAL;
                llapi_error(LLAPI_MSG_ERROR, rc, "error: bad stripe_size %llu, "
                                "must be an even multiple of %d bytes",
-                               stripe_size, page_size);
+                               (unsigned long long)stripe_size, page_size);
                goto out;
        }
        if (!llapi_stripe_index_is_valid(stripe_offset)) {
@@ -424,7 +425,7 @@ int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset,
                rc = -EINVAL;
                llapi_error(LLAPI_MSG_ERROR, rc,
                            "error: stripe size '%llu' over 4GB limit",
-                           stripe_size);
+                           (unsigned long long)stripe_size);
                goto out;
        }
 
@@ -1260,6 +1261,7 @@ int get_root_path(int want, char *fsname, int *outfd, char *path, int index)
        FILE *fp;
        int idx = 0, len = 0, mntlen, fd;
        int rc = -ENODEV;
+       int fsnamelen, mountlen;
 
         /* get the mount point */
        fp = setmntent(PROC_MOUNTS, "r");
@@ -1293,18 +1295,20 @@ int get_root_path(int want, char *fsname, int *outfd, char *path, int index)
                        ptr_end++;
 
                /* Check the fsname for a match, if given */
+               mountlen = ptr_end - ptr;
                 if (!(want & WANT_FSNAME) && fsname != NULL &&
-                   (strlen(fsname) > 0) &&
-                   (strncmp(ptr, fsname, ptr_end - ptr) != 0))
-                        continue;
+                   (fsnamelen = strlen(fsname)) > 0 &&
+                   (fsnamelen != mountlen ||
+                   (strncmp(ptr, fsname, mountlen) != 0)))
+                                       continue;
 
                 /* If the path isn't set return the first one we find */
                if (path == NULL || strlen(path) == 0) {
                        strncpy(mntdir, mnt.mnt_dir, sizeof(mntdir) - 1);
                        mntdir[sizeof(mntdir) - 1] = '\0';
                        if ((want & WANT_FSNAME) && fsname != NULL) {
-                               strncpy(fsname, ptr, ptr_end - ptr);
-                               fsname[ptr_end - ptr] = '\0';
+                               strncpy(fsname, ptr, mountlen);
+                               fsname[mountlen] = '\0';
                        }
                        rc = 0;
                        break;
@@ -1315,8 +1319,8 @@ int get_root_path(int want, char *fsname, int *outfd, char *path, int index)
                        mntdir[sizeof(mntdir) - 1] = '\0';
                        len = mntlen;
                        if ((want & WANT_FSNAME) && fsname != NULL) {
-                               strncpy(fsname, ptr, ptr_end - ptr);
-                               fsname[ptr_end - ptr] = '\0';
+                               strncpy(fsname, ptr, mountlen);
+                               fsname[mountlen] = '\0';
                        }
                        rc = 0;
                }
@@ -2703,10 +2707,10 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                ver = (__u32)(lmm_oi_id(&lum->lmm_oi) >> 32);
                if (yaml)
                        llapi_printf(LLAPI_MSG_NORMAL, DFID_NOBRACE"\n",
-                                    seq, oid, ver);
+                                    (unsigned long long)seq, oid, ver);
                else
                        llapi_printf(LLAPI_MSG_NORMAL, DFID"\n",
-                                    seq, oid, ver);
+                                    (unsigned long long)seq, oid, ver);
        }
 
        if (verbose & VERBOSE_STRIPE_COUNT) {
@@ -2766,8 +2770,8 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                        /* Extension size is in KiB */
                        llapi_printf(LLAPI_MSG_NORMAL, "%llu",
                                     extension ?
-                                    lum->lmm_stripe_size * SEL_UNIT_SIZE :
-                                    lum->lmm_stripe_size);
+                                    (unsigned long long)(lum->lmm_stripe_size * SEL_UNIT_SIZE) :
+                                    (unsigned long long)lum->lmm_stripe_size);
                }
                if (!yaml && is_dir)
                        separator = " ";
@@ -3185,7 +3189,7 @@ static void lov_dump_comp_v1_entry(struct find_param *param,
                                     "%4slcme_timestamp:      ", " ");
                if (yaml) {
                        llapi_printf(LLAPI_MSG_NORMAL, "%llu",
-                                                       entry->lcme_timestamp);
+                                    (unsigned long long)entry->lcme_timestamp);
                } else {
                        time_t stamp = entry->lcme_timestamp;
                        char *date_str = asctime(localtime(&stamp));
@@ -3203,7 +3207,7 @@ static void lov_dump_comp_v1_entry(struct find_param *param,
                        llapi_printf(LLAPI_MSG_NORMAL,
                                     "%4slcme_extent.e_start: ", " ");
                llapi_printf(LLAPI_MSG_NORMAL, "%llu",
-                            entry->lcme_extent.e_start);
+                            (unsigned long long)entry->lcme_extent.e_start);
                separator = "\n";
        }
 
@@ -3216,7 +3220,7 @@ static void lov_dump_comp_v1_entry(struct find_param *param,
                        llapi_printf(LLAPI_MSG_NORMAL, "%s", "EOF");
                else
                        llapi_printf(LLAPI_MSG_NORMAL, "%llu",
-                                       entry->lcme_extent.e_end);
+                                    (unsigned long long)entry->lcme_extent.e_end);
                separator = "\n";
        }
 
@@ -5338,7 +5342,7 @@ int llapi_target_check(int type_num, char **obd_type, char *dir)
 /* Is this a lustre fs? */
 int llapi_is_lustre_mnttype(const char *type)
 {
-        return (strcmp(type, "lustre") == 0 || strcmp(type,"lustre_lite") == 0);
+       return strcmp(type, "lustre") == 0 || strcmp(type, "lustre_tgt") == 0;
 }
 
 /* Is this a lustre client fs? */