* Because a non-directory inode may have multiple links, the use_parent * argument allows selecting which parent to use for path construction. This * argument is only meaningful for the final component (i.e. the first of the * nested calls) because directories cannot have multiple hard links. If * use_parent is NULL and projected is true, the primary parent's projected * inode is used all the
| 1093 | * generate full path. |
| 1094 | */ |
| 1095 | void CInode::make_path_string(string& s, bool projected, |
| 1096 | const CDentry *use_parent, |
| 1097 | int path_comp_count) const |
| 1098 | { |
| 1099 | if (!use_parent) { |
| 1100 | use_parent = projected ? get_projected_parent_dn() : parent; |
| 1101 | } |
| 1102 | |
| 1103 | if (use_parent) { |
| 1104 | if (path_comp_count == -1) { |
| 1105 | use_parent->make_path_string(s, projected, path_comp_count); |
| 1106 | } else if (path_comp_count >= 1) { |
| 1107 | --path_comp_count; |
| 1108 | use_parent->make_path_string(s, projected, path_comp_count); |
| 1109 | } else if (path_comp_count == 0) { |
| 1110 | // this indicates that path has been shortened. |
| 1111 | s = "..."; |
| 1112 | return; |
| 1113 | } |
| 1114 | } else if (is_root()) { |
| 1115 | s = ""; |
| 1116 | } else if (is_mdsdir()) { |
| 1117 | char t[40]; |
| 1118 | uint64_t eino(ino()); |
| 1119 | eino -= MDS_INO_MDSDIR_OFFSET; |
| 1120 | snprintf(t, sizeof(t), "~mds%" PRId64, eino); |
| 1121 | s = t; |
| 1122 | } else { |
| 1123 | char n[40]; |
| 1124 | uint64_t eino(ino()); |
| 1125 | snprintf(n, sizeof(n), "#%" PRIx64, eino); |
| 1126 | s += n; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | /* XXX Generating more than 10 components of a path for printing in logs will |
| 1131 | * consume too much time when the path is too long (imagine a path with 2000 |
no test coverage detected