|
62 | 62 | printf("\t%-14s = %-25s (0x%lx)\n",#val,PATTERN_STR(val, int_str),val); \ |
63 | 63 | } |
64 | 64 |
|
| 65 | +#ifdef HAVE_LLAPI_GET_OBD_COUNT |
| 66 | + |
| 67 | +/*----< get_total_avail_osts() >---------------------------------------------*/ |
| 68 | +static |
| 69 | +int get_total_avail_osts(const char *path) |
| 70 | +{ |
| 71 | + char *dir_name=NULL, *path_dup=NULL; |
| 72 | + int err, ost_count=0, is_mdt=0; |
| 73 | + struct stat sb; |
| 74 | + |
| 75 | + path_dup = NCI_Strdup(path); |
| 76 | + |
| 77 | + err = stat(path_dup, &sb); |
| 78 | + if (errno == ENOENT) { /* file does not exist, try folder */ |
| 79 | + /* get the parent folder name */ |
| 80 | + dir_name = dirname(path_dup); |
| 81 | + err = stat(dir_name, &sb); |
| 82 | + } |
| 83 | + if (err != 0) { |
| 84 | + printf("Warning at %s (%d): path \"%s\" stat() failed (%s)\n", |
| 85 | + __func__,__LINE__,path,strerror(errno)); |
| 86 | + goto err_out; |
| 87 | + } |
| 88 | + |
| 89 | + /* llapi_get_obd_count() only works for directories */ |
| 90 | + if (S_ISDIR(sb.st_mode)) |
| 91 | + dir_name = (dir_name == NULL) ? path_dup : dir_name; |
| 92 | + else |
| 93 | + /* get the parent folder name */ |
| 94 | + dir_name = dirname(path_dup); |
| 95 | + |
| 96 | + err = llapi_get_obd_count(dir_name, &ost_count, is_mdt); |
| 97 | + if (err != 0) { |
| 98 | + printf("Warning at %d: path \"%s\" llapi_get_obd_count() failed (%s)\n", |
| 99 | + __LINE__,dir_name,strerror(errno)); |
| 100 | + ost_count = 0; |
| 101 | + } |
| 102 | + |
| 103 | +err_out: |
| 104 | + if (path_dup != NULL) NCI_Free(path_dup); |
| 105 | + |
| 106 | + return ost_count; |
| 107 | +} |
| 108 | + |
| 109 | +#else |
| 110 | + |
65 | 111 | /*----< get_total_avail_osts() >---------------------------------------------*/ |
66 | 112 | static |
67 | 113 | int get_total_avail_osts(const char *filename) |
@@ -192,6 +238,7 @@ int get_total_avail_osts(const char *filename) |
192 | 238 |
|
193 | 239 | return num_members; |
194 | 240 | } |
| 241 | +#endif |
195 | 242 |
|
196 | 243 | static |
197 | 244 | int compare(const void *a, const void *b) |
|
0 commit comments