Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (C) 2010, Linaro |
| 3 | * Copyright (C) 2010, IBM Corporation |
| 4 | * |
| 5 | * This file is part of PowerDebug. |
| 6 | * |
| 7 | * All rights reserved. This program and the accompanying materials |
| 8 | * are made available under the terms of the Eclipse Public License v1.0 |
| 9 | * which accompanies this distribution, and is available at |
| 10 | * http://www.eclipse.org/legal/epl-v10.html |
| 11 | * |
| 12 | * Contributors: |
| 13 | * Amit Arora <amit.arora@linaro.org> (IBM Corporation) |
| 14 | * - initial API and implementation |
| 15 | *******************************************************************************/ |
| 16 | |
| 17 | #include "powerdebug.h" |
Amit Arora | ed3e565 | 2010-10-27 12:02:53 +0530 | [diff] [blame] | 18 | #include "clocks.h" |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 19 | #include <errno.h> |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 20 | #include <sys/stat.h> |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 21 | |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 22 | //static int clk_tree_level = 1; |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 23 | static char clk_dir_path[PATH_MAX]; |
| 24 | static char highlighted_path[PATH_MAX]; |
| 25 | static char clk_name[NAME_MAX]; |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 26 | static int bold[MAX_LINES]; |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 27 | |
| 28 | void init_clock_details(void) |
| 29 | { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 30 | char *path = debugfs_locate_mpoint(); |
| 31 | struct stat buf; |
Amit Arora | ed3e565 | 2010-10-27 12:02:53 +0530 | [diff] [blame] | 32 | |
| 33 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 34 | if (path) |
| 35 | strcpy(clk_dir_path, path); |
| 36 | else { |
| 37 | fprintf(stderr, "powerdebug: Unable to locate debugfs mount" |
| 38 | " point. Mount debugfs and try again..\n"); |
| 39 | exit(1); |
| 40 | } |
| 41 | sprintf(clk_dir_path, "%s/clock", clk_dir_path); |
Amit Arora | 97006e5 | 2010-10-28 11:56:08 +0530 | [diff] [blame] | 42 | //strcpy(clk_dir_path, "/debug/clock"); // Hardcoded for testing.. |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 43 | if (stat(clk_dir_path, &buf)) { |
| 44 | fprintf(stderr, "powerdebug: Unable to find clock tree" |
| 45 | " information at %s. Exiting..\n", clk_dir_path); |
| 46 | exit(1); |
| 47 | } |
| 48 | strcpy(clk_name, ""); |
| 49 | strcpy(highlighted_path, ""); |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 50 | } |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 51 | |
| 52 | int get_int_from(char *file) |
| 53 | { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 54 | FILE *filep; |
| 55 | char result[NAME_MAX]; |
| 56 | int ret; |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 57 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 58 | filep = fopen(file, "r"); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 59 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 60 | if (!filep) |
| 61 | return -1; //TBD : What should we return on failure, here ? |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 62 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 63 | ret = fscanf(filep, "%s", result); |
| 64 | fclose(filep); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 65 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 66 | return atoi(result); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 67 | } |
| 68 | |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 69 | int read_and_print_clock_info(int verbose, int hrow, int selected) |
| 70 | { |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 71 | int i, count = 0; |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 72 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 73 | (void)verbose; |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 74 | (void)hrow; |
| 75 | (void)selected; |
| 76 | read_clock_info(clk_dir_path); |
Amit Arora | 29cb757 | 2010-10-05 17:40:29 +0530 | [diff] [blame] | 77 | |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 78 | if (!clocks_info->num_children) { |
| 79 | fprintf(stderr, "powerdebug: No clocks found. Exiting..\n"); |
| 80 | exit(1); |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 81 | } |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 82 | |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 83 | print_clock_header(1); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 84 | |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 85 | for (i = 0; i < clocks_info->num_children; i++) |
| 86 | add_clock_details_recur(clocks_info->children[i]); |
| 87 | |
| 88 | while (clock_lines[count] && strcmp(clock_lines[count], "")) { |
| 89 | print_one_clock(count, clock_lines[count], bold[count]); |
| 90 | count++; |
| 91 | } |
| 92 | |
| 93 | clock_line_no = 0; |
| 94 | destroy_clocks_info(); |
| 95 | |
| 96 | return 1; |
| 97 | } |
| 98 | |
| 99 | void add_clock_details_recur(struct clock_info *clock) |
| 100 | { |
| 101 | int i; |
| 102 | char *unit = " Hz"; |
| 103 | char rate_str[64]; |
| 104 | double drate = (double)clock->rate; |
| 105 | |
| 106 | if (drate > 1000 && drate < 1000000) { |
| 107 | unit = "KHz"; |
| 108 | drate /= 1000; |
| 109 | } |
| 110 | if (drate > 1000000) { |
| 111 | unit = "MHz"; |
| 112 | drate /= 1000000; |
| 113 | } |
| 114 | if (clock->usecount) |
| 115 | bold[clock_line_no] = 1; |
| 116 | else |
| 117 | bold[clock_line_no] = 0; |
| 118 | |
| 119 | sprintf(rate_str, "%.2f %s", drate, unit); |
| 120 | sprintf(clock_lines[clock_line_no++], "%-55s %-4d %-12s %-12d", |
| 121 | clock->name, clock->flags, rate_str, clock->usecount); |
| 122 | |
| 123 | if (clock->expanded && clock->num_children) |
| 124 | for (i = 0; i < clock->num_children; i++) |
| 125 | add_clock_details_recur(clock->children[i]); |
| 126 | strcpy(clock_lines[clock_line_no], ""); |
| 127 | } |
| 128 | |
| 129 | void destroy_clocks_info(void) |
| 130 | { |
| 131 | int i; |
| 132 | |
| 133 | if (clocks_info->num_children) { |
| 134 | for (i = (clocks_info->num_children - 1); i >= 0 ; i--) { |
| 135 | destroy_clocks_info_recur(clocks_info->children[i]); |
| 136 | if (!i) { |
| 137 | free(clocks_info->children); |
| 138 | clocks_info->children = NULL; |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | free(clocks_info); |
| 143 | clocks_info = NULL; |
| 144 | } |
| 145 | |
| 146 | void destroy_clocks_info_recur(struct clock_info *clock) |
| 147 | { |
| 148 | int i; |
| 149 | |
| 150 | if (clock && clock->num_children) { |
| 151 | for (i = (clock->num_children - 1); i >= 0; i--) { |
| 152 | fflush(stdin); |
| 153 | destroy_clocks_info_recur(clock->children[i]); |
| 154 | if (!i) { |
| 155 | char name[128]; |
| 156 | |
| 157 | strcpy(name, clock->children[0]->name); |
| 158 | free(clock->children); |
| 159 | clock->children = NULL; |
| 160 | clock->num_children = 0; |
| 161 | } |
| 162 | } |
| 163 | } |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 164 | } |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 165 | |
| 166 | void dump_clock_info(int verbose) |
| 167 | { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 168 | (void)verbose; |
| 169 | printf("Clock Tree :\n"); |
| 170 | printf("**********\n"); |
| 171 | read_clock_info(clk_dir_path); |
| 172 | print_clock_info(clocks_info, 1, 1); |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 173 | } |
| 174 | |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 175 | void read_clock_info(char *clkpath) |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 176 | { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 177 | DIR *dir; |
| 178 | struct dirent *item; |
| 179 | char filename[NAME_MAX], clockname[NAME_MAX]; |
| 180 | struct clock_info *child; |
| 181 | struct clock_info *cur; |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 182 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 183 | dir = opendir(clkpath); |
| 184 | if (!dir) |
| 185 | return; |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 186 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 187 | clocks_info = (struct clock_info *)malloc(sizeof(struct clock_info)); |
| 188 | memset(clocks_info, 0, sizeof(clocks_info)); |
| 189 | strcpy(clocks_info->name, "/"); |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 190 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 191 | while ((item = readdir(dir))) { |
| 192 | /* skip hidden dirs except ".." */ |
| 193 | if (item->d_name[0] == '.') |
| 194 | continue; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 195 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 196 | strcpy(clockname, item->d_name); |
| 197 | sprintf(filename, "%s/%s", clkpath, item->d_name); |
| 198 | cur = (struct clock_info *)malloc(sizeof(struct clock_info)); |
| 199 | memset(cur, 0, sizeof(cur)); |
| 200 | strcpy(cur->name, clockname); |
| 201 | cur->parent = clocks_info; |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 202 | cur->num_children = 0; |
| 203 | cur->expanded = 0; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 204 | insert_children(&clocks_info, cur); |
| 205 | child = read_clock_info_recur(filename, 2, cur); |
| 206 | } |
| 207 | closedir(dir); |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | struct clock_info *read_clock_info_recur(char *clkpath, int level, |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 211 | struct clock_info *parent) |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 212 | { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 213 | int ret = 0; |
| 214 | DIR *dir; |
| 215 | char filename[PATH_MAX]; |
| 216 | struct dirent *item; |
| 217 | struct clock_info *cur = NULL; |
| 218 | struct stat buf; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 219 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 220 | dir = opendir(clkpath); |
| 221 | if (!dir) |
| 222 | return NULL; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 223 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 224 | while ((item = readdir(dir))) { |
| 225 | struct clock_info *child; |
| 226 | /* skip hidden dirs except ".." */ |
| 227 | if (item->d_name[0] == '.' ) |
| 228 | continue; |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 229 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 230 | sprintf(filename, "%s/%s", clkpath, item->d_name); |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 231 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 232 | ret = stat(filename, &buf); |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 233 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 234 | if (ret < 0) { |
| 235 | printf("Error doing a stat on %s\n", filename); |
| 236 | exit(1); |
| 237 | } |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 238 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 239 | if (S_ISREG(buf.st_mode)) { |
| 240 | if (!strcmp(item->d_name, "flags")) |
| 241 | parent->flags = get_int_from(filename); |
| 242 | if (!strcmp(item->d_name, "rate")) |
| 243 | parent->rate = get_int_from(filename); |
| 244 | if (!strcmp(item->d_name, "usecount")) |
| 245 | parent->usecount = get_int_from(filename); |
| 246 | continue; |
| 247 | } |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 248 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 249 | if (!S_ISDIR(buf.st_mode)) |
| 250 | continue; |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 251 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 252 | cur = (struct clock_info *)malloc(sizeof(struct clock_info)); |
| 253 | memset(cur, 0, sizeof(cur)); |
| 254 | strcpy(cur->name, item->d_name); |
| 255 | cur->children = NULL; |
| 256 | cur->parent = NULL; |
| 257 | cur->num_children = 0; |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 258 | cur->expanded = 0; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 259 | child = read_clock_info_recur(filename, level + 1, cur); |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 260 | insert_children(&parent, cur); |
| 261 | cur->parent = parent; |
| 262 | } |
| 263 | closedir(dir); |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 264 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 265 | return cur; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | void insert_children(struct clock_info **parent, struct clock_info *clk) |
| 269 | { |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 270 | if (!(*parent)->num_children || (*parent)->children == NULL) { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 271 | (*parent)->children = (struct clock_info **) |
| 272 | malloc(sizeof(struct clock_info *)*2); |
| 273 | (*parent)->num_children = 0; |
| 274 | } else |
| 275 | (*parent)->children = (struct clock_info **) |
| 276 | realloc((*parent)->children, |
| 277 | sizeof(struct clock_info *) * |
| 278 | ((*parent)->num_children + 2)); |
| 279 | if ((*parent)->num_children > 0) |
| 280 | (*parent)->children[(*parent)->num_children - 1]->last_child |
| 281 | = 0; |
| 282 | clk->last_child = 1; |
| 283 | (*parent)->children[(*parent)->num_children] = clk; |
| 284 | (*parent)->children[(*parent)->num_children + 1] = NULL; |
| 285 | (*parent)->num_children++; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | |
| 289 | void print_clock_info(struct clock_info *clk, int level, int bmp) |
| 290 | { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 291 | int i, j; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 292 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 293 | if (!clk) |
| 294 | return; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 295 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 296 | for (i = 1, j = 0; i < level; i++, j = (i - 1)) { |
| 297 | if (i == (level - 1)) { |
| 298 | if (clk->last_child) |
| 299 | printf("`-- "); |
| 300 | else |
| 301 | printf("|-- "); |
| 302 | } else { |
| 303 | if ((1<<j) & bmp) |
| 304 | printf("| "); |
| 305 | else |
| 306 | printf(" "); |
| 307 | } |
| 308 | } |
Amit Arora | 031263a | 2010-11-09 11:12:41 +0530 | [diff] [blame^] | 309 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 310 | if (clk == clocks_info) |
| 311 | printf("%s\n", clk->name); |
| 312 | else { |
| 313 | char *unit = "Hz"; |
| 314 | double drate = (double)clk->rate; |
| 315 | |
| 316 | if (drate > 1000 && drate < 1000000) { |
| 317 | unit = "KHz"; |
| 318 | drate /= 1000; |
| 319 | } |
| 320 | if (drate > 1000000) { |
| 321 | unit = "MHz"; |
| 322 | drate /= 1000000; |
| 323 | } |
| 324 | printf("%s (flags:%d,usecount:%d,rate:%5.2f %s)\n", |
| 325 | clk->name, clk->flags, clk->usecount, drate, unit); |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 326 | } |
| 327 | if (clk->children) { |
| 328 | int tbmp = bmp; |
| 329 | int xbmp = -1; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 330 | |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 331 | if (clk->last_child) { |
| 332 | xbmp ^= 1 << (level - 2); |
| 333 | |
| 334 | xbmp = tbmp & xbmp; |
| 335 | } else |
| 336 | xbmp = bmp; |
| 337 | for (i = 0; i < clk->num_children; i++) { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 338 | tbmp = xbmp | (1 << level); |
| 339 | print_clock_info(clk->children[i], level + 1, tbmp); |
| 340 | } |
| 341 | } |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 342 | } |
Amit Arora | ed3e565 | 2010-10-27 12:02:53 +0530 | [diff] [blame] | 343 | |
| 344 | char *debugfs_locate_mpoint(void) |
| 345 | { |
| 346 | int ret; |
| 347 | FILE *filep; |
| 348 | char **path; |
| 349 | char fsname[64]; |
| 350 | struct statfs sfs; |
| 351 | |
| 352 | path = likely_mpoints; |
| 353 | while (*path) { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 354 | ret = statfs(*path, &sfs); |
| 355 | if (ret >= 0 && sfs.f_type == (long)DEBUGFS_MAGIC) |
Amit Arora | ed3e565 | 2010-10-27 12:02:53 +0530 | [diff] [blame] | 356 | return *path; |
| 357 | path++; |
| 358 | } |
| 359 | |
| 360 | filep = fopen("/proc/mounts", "r"); |
| 361 | if (filep == NULL) { |
| 362 | fprintf(stderr, "powerdebug: Error opening /proc/mounts."); |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 363 | exit(1); |
| 364 | } |
Amit Arora | ed3e565 | 2010-10-27 12:02:53 +0530 | [diff] [blame] | 365 | |
| 366 | while (fscanf(filep, "%*s %s %s %*s %*d %*d\n", |
| 367 | debugfs_mntpoint, fsname) == 2) |
| 368 | if (!strcmp(fsname, "debugfs")) |
| 369 | break; |
| 370 | fclose(filep); |
| 371 | |
| 372 | if (strcmp(fsname, "debugfs")) |
| 373 | return NULL; |
| 374 | |
| 375 | return debugfs_mntpoint; |
| 376 | } |