Whamcloud - gitweb
LU-960 utils: bad stripe count report, and validate stripe size
[fs/lustre-release.git] / lustre / utils / liblustreapi.c
index e08bef0..2994cdd 100644 (file)
@@ -177,6 +177,9 @@ int parse_size(char *optarg, unsigned long long *size,
 {
         char *end;
 
+        if (strncmp(optarg, "-", 1) == 0)
+                return -1;
+
         if (*size_units == 0)
                 *size_units = 1;
 
@@ -657,6 +660,31 @@ int llapi_search_fsname(const char *pathname, char *fsname)
         return rc;
 }
 
+int llapi_getname(const char *path, char *buf, size_t size)
+{
+        struct obd_uuid uuid_buf;
+        char *uuid = uuid_buf.uuid;
+        int rc, nr;
+
+        memset(&uuid_buf, 0, sizeof(uuid_buf));
+        rc = llapi_file_get_lov_uuid(path, &uuid_buf);
+        if (rc)
+                return rc;
+
+        /* We want to turn lustre-clilov-ffff88002738bc00 into
+         * lustre-ffff88002738bc00. */
+
+        nr = snprintf(buf, size, "%.*s-%s",
+                      (int) (strlen(uuid) - 24), uuid,
+                      uuid + strlen(uuid) - 16);
+
+        if (nr >= size)
+                rc = -ENAMETOOLONG;
+
+        return rc;
+}
+
+
 /* return the first file matching this pattern */
 static int first_match(char *pattern, char *buffer)
 {
@@ -1629,7 +1657,7 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                                                               &scount, NULL,
                                                               NULL);
                                 if (rc == 0)
-                                        llapi_printf(LLAPI_MSG_NORMAL, "%u%c",
+                                        llapi_printf(LLAPI_MSG_NORMAL, "%d%c",
                                                      scount, nl);
                                 else
                                         llapi_error(LLAPI_MSG_ERROR, rc,
@@ -1673,6 +1701,14 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                              lum->lmm_pattern, nl);
         }
 
+        if ((verbose & VERBOSE_GENERATION) && !is_dir) {
+                if (verbose & ~VERBOSE_GENERATION)
+                        llapi_printf(LLAPI_MSG_NORMAL, "%slayout_gen:     ",
+                                     prefix);
+                llapi_printf(LLAPI_MSG_NORMAL, "%u%c",
+                             (int)lum->u.lum_layout_gen, nl);
+        }
+
         if (verbose & VERBOSE_OFFSET) {
                 if (verbose & ~VERBOSE_OFFSET)
                         llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_offset:  ",
@@ -1901,7 +1937,7 @@ static int find_time_check(lstat_t *st, struct find_param *param, int mds)
         /* Check if file is accepted. */
         if (param->atime) {
                 ret = find_value_cmp(st->st_atime, param->atime,
-                                     param->asign, param->exclude_atime, 
+                                     param->asign, param->exclude_atime,
                                      24 * 60 * 60, mds);
                 if (ret < 0)
                         return ret;
@@ -1910,7 +1946,7 @@ static int find_time_check(lstat_t *st, struct find_param *param, int mds)
 
         if (param->mtime) {
                 ret = find_value_cmp(st->st_mtime, param->mtime,
-                                     param->msign, param->exclude_mtime, 
+                                     param->msign, param->exclude_mtime,
                                      24 * 60 * 60, mds);
                 if (ret < 0)
                         return ret;
@@ -2513,7 +2549,6 @@ int llapi_target_iterate(int type_num, char **obd_type,
                 char *obd_name = NULL;
                 char *obd_uuid = NULL;
                 char *bufp = buf;
-                struct obd_ioctl_data datal = { 0, };
                 struct obd_statfs osfs_buffer;
 
                 while(bufp[0] == ' ')
@@ -2527,9 +2562,6 @@ int llapi_target_iterate(int type_num, char **obd_type,
 
                 memset(&osfs_buffer, 0, sizeof (osfs_buffer));
 
-                datal.ioc_pbuf1 = (char *)&osfs_buffer;
-                datal.ioc_plen1 = sizeof(osfs_buffer);
-
                 for (i = 0; i < type_num; i++) {
                         if (strcmp(obd_type_name, obd_type[i]) != 0)
                                 continue;