}
}
+void filepath::set_trimmed() {
+ if (trimmed)
+ return;
+ // indicates that the path has been shortened.
+ path += "...";
+ trimmed = true;
+}
+
void filepath::set_path(std::string_view s) {
if (!s.empty() && s[0] == '/') {
path = s.substr(1);
class filepath {
inodeno_t ino = 0; // base inode. ino=0 implies pure relative path.
std::string path; // relative path.
+ // tells get_path() whether it should prefix path with "..." to indicate that
+ // it was shortened.
+ bool trimmed = false;
/** bits - path segments
* this is ['a', 'b', 'c'] for both the aboslute and relative case.
// accessors
inodeno_t get_ino() const { return ino; }
const std::string& get_path() const { return path; }
+ void set_trimmed();
const char *c_str() const { return path.c_str(); }
int length() const { return path.length(); }
void CDentry::make_path(filepath& fp, bool projected) const
{
- ceph_assert(dir);
- dir->inode->make_path(fp, projected);
- fp.push_dentry(get_name());
+ /* path_comp_count = path components count
+ *
+ * Printing more than 10 components of a path not only is not useful but also it
+ * makes reading logs harder (imagine path with 2000 components). Therefore,
+ * shorten path.
+ */
+ static int path_comp_count = 1;
+ fp.set_trimmed();
+
+ if (path_comp_count <= 10) {
+ ceph_assert(dir);
+ ++path_comp_count;
+ dir->inode->make_path(fp, projected);
+ fp.push_dentry(get_name());
+ } else {
+ // resetting the counter
+ path_comp_count = 1;
+ return;
+ }
}
/*