fdt_region.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. // SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause
  2. /*
  3. * libfdt - Flat Device Tree manipulation
  4. * Copyright (C) 2013 Google, Inc
  5. * Written by Simon Glass <sjg@chromium.org>
  6. */
  7. #include <fdt_support.h>
  8. #include <linux/libfdt_env.h>
  9. #include <fdt_region.h>
  10. #ifndef USE_HOSTCC
  11. #include <fdt.h>
  12. #include <linux/libfdt.h>
  13. #else
  14. #include "fdt_host.h"
  15. #endif
  16. #define FDT_MAX_DEPTH 32
  17. static int str_in_list(const char *str, char * const list[], int count)
  18. {
  19. int i;
  20. for (i = 0; i < count; i++)
  21. if (!strcmp(list[i], str))
  22. return 1;
  23. return 0;
  24. }
  25. int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
  26. char * const exc_prop[], int exc_prop_count,
  27. struct fdt_region region[], int max_regions,
  28. char *path, int path_len, int add_string_tab)
  29. {
  30. int stack[FDT_MAX_DEPTH] = { 0 };
  31. char *end;
  32. int nextoffset = 0;
  33. uint32_t tag;
  34. int count = 0;
  35. int start = -1;
  36. int depth = -1;
  37. int want = 0;
  38. int base = fdt_off_dt_struct(fdt);
  39. bool expect_end = false;
  40. end = path;
  41. *end = '\0';
  42. do {
  43. const struct fdt_property *prop;
  44. const char *name;
  45. const char *str;
  46. int include = 0;
  47. int stop_at = 0;
  48. int offset;
  49. int len;
  50. offset = nextoffset;
  51. tag = fdt_next_tag(fdt, offset, &nextoffset);
  52. stop_at = nextoffset;
  53. /* If we see two root nodes, something is wrong */
  54. if (expect_end && tag != FDT_END)
  55. return -FDT_ERR_BADLAYOUT;
  56. switch (tag) {
  57. case FDT_PROP:
  58. include = want >= 2;
  59. stop_at = offset;
  60. prop = fdt_get_property_by_offset(fdt, offset, NULL);
  61. str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
  62. if (!str)
  63. return -FDT_ERR_BADSTRUCTURE;
  64. if (str_in_list(str, exc_prop, exc_prop_count))
  65. include = 0;
  66. break;
  67. case FDT_NOP:
  68. include = want >= 2;
  69. stop_at = offset;
  70. break;
  71. case FDT_BEGIN_NODE:
  72. depth++;
  73. if (depth == FDT_MAX_DEPTH)
  74. return -FDT_ERR_BADSTRUCTURE;
  75. name = fdt_get_name(fdt, offset, &len);
  76. /* The root node must have an empty name */
  77. if (!depth && *name)
  78. return -FDT_ERR_BADLAYOUT;
  79. if (end - path + 2 + len >= path_len)
  80. return -FDT_ERR_NOSPACE;
  81. if (end != path + 1)
  82. *end++ = '/';
  83. strcpy(end, name);
  84. end += len;
  85. stack[depth] = want;
  86. if (want == 1)
  87. stop_at = offset;
  88. if (str_in_list(path, inc, inc_count))
  89. want = 2;
  90. else if (want)
  91. want--;
  92. else
  93. stop_at = offset;
  94. include = want;
  95. break;
  96. case FDT_END_NODE:
  97. /* Depth must never go below -1 */
  98. if (depth < 0)
  99. return -FDT_ERR_BADSTRUCTURE;
  100. include = want;
  101. want = stack[depth--];
  102. while (end > path && *--end != '/')
  103. ;
  104. *end = '\0';
  105. if (depth == -1)
  106. expect_end = true;
  107. break;
  108. case FDT_END:
  109. include = 1;
  110. break;
  111. }
  112. if (include && start == -1) {
  113. /* Should we merge with previous? */
  114. if (count && count <= max_regions &&
  115. offset == region[count - 1].offset +
  116. region[count - 1].size - base)
  117. start = region[--count].offset - base;
  118. else
  119. start = offset;
  120. }
  121. if (!include && start != -1) {
  122. if (count < max_regions) {
  123. region[count].offset = base + start;
  124. region[count].size = stop_at - start;
  125. }
  126. count++;
  127. start = -1;
  128. }
  129. } while (tag != FDT_END);
  130. if (nextoffset != fdt_size_dt_struct(fdt))
  131. return -FDT_ERR_BADLAYOUT;
  132. /* Add a region for the END tag and the string table */
  133. if (count < max_regions) {
  134. region[count].offset = base + start;
  135. region[count].size = nextoffset - start;
  136. if (add_string_tab)
  137. region[count].size += fdt_size_dt_strings(fdt);
  138. }
  139. count++;
  140. return count;
  141. }
  142. /**
  143. * fdt_add_region() - Add a new region to our list
  144. * @info: State information
  145. * @offset: Start offset of region
  146. * @size: Size of region
  147. *
  148. * The region is added if there is space, but in any case we increment the
  149. * count. If permitted, and the new region overlaps the last one, we merge
  150. * them.
  151. */
  152. static int fdt_add_region(struct fdt_region_state *info, int offset, int size)
  153. {
  154. struct fdt_region *reg;
  155. reg = info->region ? &info->region[info->count - 1] : NULL;
  156. if (info->can_merge && info->count &&
  157. info->count <= info->max_regions &&
  158. reg && offset <= reg->offset + reg->size) {
  159. reg->size = offset + size - reg->offset;
  160. } else if (info->count++ < info->max_regions) {
  161. if (reg) {
  162. reg++;
  163. reg->offset = offset;
  164. reg->size = size;
  165. }
  166. } else {
  167. return -1;
  168. }
  169. return 0;
  170. }
  171. static int region_list_contains_offset(struct fdt_region_state *info,
  172. const void *fdt, int target)
  173. {
  174. struct fdt_region *reg;
  175. int num;
  176. target += fdt_off_dt_struct(fdt);
  177. for (reg = info->region, num = 0; num < info->count; reg++, num++) {
  178. if (target >= reg->offset && target < reg->offset + reg->size)
  179. return 1;
  180. }
  181. return 0;
  182. }
  183. /**
  184. * fdt_add_alias_regions() - Add regions covering the aliases that we want
  185. *
  186. * The /aliases node is not automatically included by fdtgrep unless the
  187. * command-line arguments cause to be included (or not excluded). However
  188. * aliases are special in that we generally want to include those which
  189. * reference a node that fdtgrep includes.
  190. *
  191. * In fact we want to include only aliases for those nodes still included in
  192. * the fdt, and drop the other aliases since they point to nodes that will not
  193. * be present.
  194. *
  195. * This function scans the aliases and adds regions for those which we want
  196. * to keep.
  197. *
  198. * @fdt: Device tree to scan
  199. * @region: List of regions
  200. * @count: Number of regions in the list so far (i.e. starting point for this
  201. * function)
  202. * @max_regions: Maximum number of regions in @region list
  203. * @info: Place to put the region state
  204. * @return number of regions after processing, or -FDT_ERR_NOSPACE if we did
  205. * not have enough room in the regions table for the regions we wanted to add.
  206. */
  207. int fdt_add_alias_regions(const void *fdt, struct fdt_region *region, int count,
  208. int max_regions, struct fdt_region_state *info)
  209. {
  210. int base = fdt_off_dt_struct(fdt);
  211. int node, node_end, offset;
  212. int did_alias_header;
  213. node = fdt_subnode_offset(fdt, 0, "aliases");
  214. if (node < 0)
  215. return -FDT_ERR_NOTFOUND;
  216. /*
  217. * Find the next node so that we know where the /aliases node ends. We
  218. * need special handling if /aliases is the last node.
  219. */
  220. node_end = fdt_next_subnode(fdt, node);
  221. if (node_end == -FDT_ERR_NOTFOUND)
  222. /* Move back to the FDT_END_NODE tag of '/' */
  223. node_end = fdt_size_dt_struct(fdt) - sizeof(fdt32_t) * 2;
  224. else if (node_end < 0) /* other error */
  225. return node_end;
  226. node_end -= sizeof(fdt32_t); /* Move to FDT_END_NODE tag of /aliases */
  227. did_alias_header = 0;
  228. info->region = region;
  229. info->count = count;
  230. info->can_merge = 0;
  231. info->max_regions = max_regions;
  232. for (offset = fdt_first_property_offset(fdt, node);
  233. offset >= 0;
  234. offset = fdt_next_property_offset(fdt, offset)) {
  235. const struct fdt_property *prop;
  236. const char *name;
  237. int target, next;
  238. prop = fdt_get_property_by_offset(fdt, offset, NULL);
  239. name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
  240. target = fdt_path_offset(fdt, name);
  241. if (!region_list_contains_offset(info, fdt, target))
  242. continue;
  243. next = fdt_next_property_offset(fdt, offset);
  244. if (next < 0)
  245. next = node_end;
  246. if (!did_alias_header) {
  247. fdt_add_region(info, base + node, 12);
  248. did_alias_header = 1;
  249. }
  250. fdt_add_region(info, base + offset, next - offset);
  251. }
  252. /* Add the FDT_END_NODE tag */
  253. if (did_alias_header)
  254. fdt_add_region(info, base + node_end, sizeof(fdt32_t));
  255. return info->count < max_regions ? info->count : -FDT_ERR_NOSPACE;
  256. }
  257. /**
  258. * fdt_include_supernodes() - Include supernodes required by this node
  259. * @info: State information
  260. * @depth: Current stack depth
  261. *
  262. * When we decided to include a node or property which is not at the top
  263. * level, this function forces the inclusion of higher level nodes. For
  264. * example, given this tree:
  265. *
  266. * / {
  267. * testing {
  268. * }
  269. * }
  270. *
  271. * If we decide to include testing then we need the root node to have a valid
  272. * tree. This function adds those regions.
  273. */
  274. static int fdt_include_supernodes(struct fdt_region_state *info, int depth)
  275. {
  276. int base = fdt_off_dt_struct(info->fdt);
  277. int start, stop_at;
  278. int i;
  279. /*
  280. * Work down the stack looking for supernodes that we didn't include.
  281. * The algortihm here is actually pretty simple, since we know that
  282. * no previous subnode had to include these nodes, or if it did, we
  283. * marked them as included (on the stack) already.
  284. */
  285. for (i = 0; i <= depth; i++) {
  286. if (!info->stack[i].included) {
  287. start = info->stack[i].offset;
  288. /* Add the FDT_BEGIN_NODE tag of this supernode */
  289. fdt_next_tag(info->fdt, start, &stop_at);
  290. if (fdt_add_region(info, base + start, stop_at - start))
  291. return -1;
  292. /* Remember that this supernode is now included */
  293. info->stack[i].included = 1;
  294. info->can_merge = 1;
  295. }
  296. /* Force (later) generation of the FDT_END_NODE tag */
  297. if (!info->stack[i].want)
  298. info->stack[i].want = WANT_NODES_ONLY;
  299. }
  300. return 0;
  301. }
  302. enum {
  303. FDT_DONE_NOTHING,
  304. FDT_DONE_MEM_RSVMAP,
  305. FDT_DONE_STRUCT,
  306. FDT_DONE_END,
  307. FDT_DONE_STRINGS,
  308. FDT_DONE_ALL,
  309. };
  310. int fdt_first_region(const void *fdt,
  311. int (*h_include)(void *priv, const void *fdt, int offset,
  312. int type, const char *data, int size),
  313. void *priv, struct fdt_region *region,
  314. char *path, int path_len, int flags,
  315. struct fdt_region_state *info)
  316. {
  317. struct fdt_region_ptrs *p = &info->ptrs;
  318. /* Set up our state */
  319. info->fdt = fdt;
  320. info->can_merge = 1;
  321. info->max_regions = 1;
  322. info->start = -1;
  323. p->want = WANT_NOTHING;
  324. p->end = path;
  325. *p->end = '\0';
  326. p->nextoffset = 0;
  327. p->depth = -1;
  328. p->done = FDT_DONE_NOTHING;
  329. return fdt_next_region(fdt, h_include, priv, region,
  330. path, path_len, flags, info);
  331. }
  332. /***********************************************************************
  333. *
  334. * Theory of operation
  335. *
  336. * Note: in this description 'included' means that a node (or other part
  337. * of the tree) should be included in the region list, i.e. it will have
  338. * a region which covers its part of the tree.
  339. *
  340. * This function maintains some state from the last time it is called.
  341. * It checks the next part of the tree that it is supposed to look at
  342. * (p.nextoffset) to see if that should be included or not. When it
  343. * finds something to include, it sets info->start to its offset. This
  344. * marks the start of the region we want to include.
  345. *
  346. * Once info->start is set to the start (i.e. not -1), we continue
  347. * scanning until we find something that we don't want included. This
  348. * will be the end of a region. At this point we can close off the
  349. * region and add it to the list. So we do so, and reset info->start
  350. * to -1.
  351. *
  352. * One complication here is that we want to merge regions. So when we
  353. * come to add another region later, we may in fact merge it with the
  354. * previous one if one ends where the other starts.
  355. *
  356. * The function fdt_add_region() will return -1 if it fails to add the
  357. * region, because we already have a region ready to be returned, and
  358. * the new one cannot be merged in with it. In this case, we must return
  359. * the region we found, and wait for another call to this function.
  360. * When it comes, we will repeat the processing of the tag and again
  361. * try to add a region. This time it will succeed.
  362. *
  363. * The current state of the pointers (stack, offset, etc.) is maintained
  364. * in a ptrs member. At the start of every loop iteration we make a copy
  365. * of it. The copy is then updated as the tag is processed. Only if we
  366. * get to the end of the loop iteration (and successfully call
  367. * fdt_add_region() if we need to) can we commit the changes we have
  368. * made to these pointers. For example, if we see an FDT_END_NODE tag,
  369. * we will decrement the depth value. But if we need to add a region
  370. * for this tag (let's say because the previous tag is included and this
  371. * FDT_END_NODE tag is not included) then we will only commit the result
  372. * if we were able to add the region. That allows us to retry again next
  373. * time.
  374. *
  375. * We keep track of a variable called 'want' which tells us what we want
  376. * to include when there is no specific information provided by the
  377. * h_include function for a particular property. This basically handles
  378. * the inclusion of properties which are pulled in by virtue of the node
  379. * they are in. So if you include a node, its properties are also
  380. * included. In this case 'want' will be WANT_NODES_AND_PROPS. The
  381. * FDT_REG_DIRECT_SUBNODES feature also makes use of 'want'. While we
  382. * are inside the subnode, 'want' will be set to WANT_NODES_ONLY, so
  383. * that only the subnode's FDT_BEGIN_NODE and FDT_END_NODE tags will be
  384. * included, and properties will be skipped. If WANT_NOTHING is
  385. * selected, then we will just rely on what the h_include() function
  386. * tells us.
  387. *
  388. * Using 'want' we work out 'include', which tells us whether this
  389. * current tag should be included or not. As you can imagine, if the
  390. * value of 'include' changes, that means we are on a boundary between
  391. * nodes to include and nodes to exclude. At this point we either close
  392. * off a previous region and add it to the list, or mark the start of a
  393. * new region.
  394. *
  395. * Apart from the nodes, we have mem_rsvmap, the FDT_END tag and the
  396. * string list. Each of these dealt with as a whole (i.e. we create a
  397. * region for each if it is to be included). For mem_rsvmap we don't
  398. * allow it to merge with the first struct region. For the stringlist,
  399. * we don't allow it to merge with the last struct region (which
  400. * contains at minimum the FDT_END tag).
  401. *
  402. *********************************************************************/
  403. int fdt_next_region(const void *fdt,
  404. int (*h_include)(void *priv, const void *fdt, int offset,
  405. int type, const char *data, int size),
  406. void *priv, struct fdt_region *region,
  407. char *path, int path_len, int flags,
  408. struct fdt_region_state *info)
  409. {
  410. int base = fdt_off_dt_struct(fdt);
  411. int last_node = 0;
  412. const char *str;
  413. info->region = region;
  414. info->count = 0;
  415. if (info->ptrs.done < FDT_DONE_MEM_RSVMAP &&
  416. (flags & FDT_REG_ADD_MEM_RSVMAP)) {
  417. /* Add the memory reserve map into its own region */
  418. if (fdt_add_region(info, fdt_off_mem_rsvmap(fdt),
  419. fdt_off_dt_struct(fdt) -
  420. fdt_off_mem_rsvmap(fdt)))
  421. return 0;
  422. info->can_merge = 0; /* Don't allow merging with this */
  423. info->ptrs.done = FDT_DONE_MEM_RSVMAP;
  424. }
  425. /*
  426. * Work through the tags one by one, deciding whether each needs to
  427. * be included or not. We set the variable 'include' to indicate our
  428. * decision. 'want' is used to track what we want to include - it
  429. * allows us to pick up all the properties (and/or subnode tags) of
  430. * a node.
  431. */
  432. while (info->ptrs.done < FDT_DONE_STRUCT) {
  433. const struct fdt_property *prop;
  434. struct fdt_region_ptrs p;
  435. const char *name;
  436. int include = 0;
  437. int stop_at = 0;
  438. uint32_t tag;
  439. int offset;
  440. int val;
  441. int len;
  442. /*
  443. * Make a copy of our pointers. If we make it to the end of
  444. * this block then we will commit them back to info->ptrs.
  445. * Otherwise we can try again from the same starting state
  446. * next time we are called.
  447. */
  448. p = info->ptrs;
  449. /*
  450. * Find the tag, and the offset of the next one. If we need to
  451. * stop including tags, then by default we stop *after*
  452. * including the current tag
  453. */
  454. offset = p.nextoffset;
  455. tag = fdt_next_tag(fdt, offset, &p.nextoffset);
  456. stop_at = p.nextoffset;
  457. switch (tag) {
  458. case FDT_PROP:
  459. stop_at = offset;
  460. prop = fdt_get_property_by_offset(fdt, offset, NULL);
  461. str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
  462. val = h_include(priv, fdt, last_node, FDT_IS_PROP, str,
  463. strlen(str) + 1);
  464. if (val == -1) {
  465. include = p.want >= WANT_NODES_AND_PROPS;
  466. } else {
  467. include = val;
  468. /*
  469. * Make sure we include the } for this block.
  470. * It might be more correct to have this done
  471. * by the call to fdt_include_supernodes() in
  472. * the case where it adds the node we are
  473. * currently in, but this is equivalent.
  474. */
  475. if ((flags & FDT_REG_SUPERNODES) && val &&
  476. !p.want)
  477. p.want = WANT_NODES_ONLY;
  478. }
  479. /* Value grepping is not yet supported */
  480. break;
  481. case FDT_NOP:
  482. include = p.want >= WANT_NODES_AND_PROPS;
  483. stop_at = offset;
  484. break;
  485. case FDT_BEGIN_NODE:
  486. last_node = offset;
  487. p.depth++;
  488. if (p.depth == FDT_MAX_DEPTH)
  489. return -FDT_ERR_BADSTRUCTURE;
  490. name = fdt_get_name(fdt, offset, &len);
  491. if (p.end - path + 2 + len >= path_len)
  492. return -FDT_ERR_NOSPACE;
  493. /* Build the full path of this node */
  494. if (p.end != path + 1)
  495. *p.end++ = '/';
  496. strcpy(p.end, name);
  497. p.end += len;
  498. info->stack[p.depth].want = p.want;
  499. info->stack[p.depth].offset = offset;
  500. /*
  501. * If we are not intending to include this node unless
  502. * it matches, make sure we stop *before* its tag.
  503. */
  504. if (p.want == WANT_NODES_ONLY ||
  505. !(flags & (FDT_REG_DIRECT_SUBNODES |
  506. FDT_REG_ALL_SUBNODES))) {
  507. stop_at = offset;
  508. p.want = WANT_NOTHING;
  509. }
  510. val = h_include(priv, fdt, offset, FDT_IS_NODE, path,
  511. p.end - path + 1);
  512. /* Include this if requested */
  513. if (val) {
  514. p.want = (flags & FDT_REG_ALL_SUBNODES) ?
  515. WANT_ALL_NODES_AND_PROPS :
  516. WANT_NODES_AND_PROPS;
  517. }
  518. /* If not requested, decay our 'p.want' value */
  519. else if (p.want) {
  520. if (p.want != WANT_ALL_NODES_AND_PROPS)
  521. p.want--;
  522. /* Not including this tag, so stop now */
  523. } else {
  524. stop_at = offset;
  525. }
  526. /*
  527. * Decide whether to include this tag, and update our
  528. * stack with the state for this node
  529. */
  530. include = p.want;
  531. info->stack[p.depth].included = include;
  532. break;
  533. case FDT_END_NODE:
  534. include = p.want;
  535. if (p.depth < 0)
  536. return -FDT_ERR_BADSTRUCTURE;
  537. /*
  538. * If we don't want this node, stop right away, unless
  539. * we are including subnodes
  540. */
  541. if (!p.want && !(flags & FDT_REG_DIRECT_SUBNODES))
  542. stop_at = offset;
  543. p.want = info->stack[p.depth].want;
  544. p.depth--;
  545. while (p.end > path && *--p.end != '/')
  546. ;
  547. *p.end = '\0';
  548. break;
  549. case FDT_END:
  550. /* We always include the end tag */
  551. include = 1;
  552. p.done = FDT_DONE_STRUCT;
  553. break;
  554. }
  555. /* If this tag is to be included, mark it as region start */
  556. if (include && info->start == -1) {
  557. /* Include any supernodes required by this one */
  558. if (flags & FDT_REG_SUPERNODES) {
  559. if (fdt_include_supernodes(info, p.depth))
  560. return 0;
  561. }
  562. info->start = offset;
  563. }
  564. /*
  565. * If this tag is not to be included, finish up the current
  566. * region.
  567. */
  568. if (!include && info->start != -1) {
  569. if (fdt_add_region(info, base + info->start,
  570. stop_at - info->start))
  571. return 0;
  572. info->start = -1;
  573. info->can_merge = 1;
  574. }
  575. /* If we have made it this far, we can commit our pointers */
  576. info->ptrs = p;
  577. }
  578. /* Add a region for the END tag and a separate one for string table */
  579. if (info->ptrs.done < FDT_DONE_END) {
  580. if (info->ptrs.nextoffset != fdt_size_dt_struct(fdt))
  581. return -FDT_ERR_BADSTRUCTURE;
  582. if (fdt_add_region(info, base + info->start,
  583. info->ptrs.nextoffset - info->start))
  584. return 0;
  585. info->ptrs.done++;
  586. }
  587. if (info->ptrs.done < FDT_DONE_STRINGS) {
  588. if (flags & FDT_REG_ADD_STRING_TAB) {
  589. info->can_merge = 0;
  590. if (fdt_off_dt_strings(fdt) <
  591. base + info->ptrs.nextoffset)
  592. return -FDT_ERR_BADLAYOUT;
  593. if (fdt_add_region(info, fdt_off_dt_strings(fdt),
  594. fdt_size_dt_strings(fdt)))
  595. return 0;
  596. }
  597. info->ptrs.done++;
  598. }
  599. return info->count > 0 ? 0 : -FDT_ERR_NOTFOUND;
  600. }