return rc;
}
-int Client::path_walk(InodeRef dirinode, const filepath& origpath, walk_dentry_result* result, const UserPerm& perms, const PathWalk_ExtraOptions& extra_options)
+int Client::path_walk(InodeRef dirinode, const filepath& origpath,
+ walk_dentry_result* result, const UserPerm& perms,
+ const PathWalk_ExtraOptions& extra_options,
+ std::string trimmed_path)
{
int rc = 0;
filepath path = origpath;
int symlinks = 0;
unsigned i = 0;
- ldout(cct, 10) << __func__ << ": cur=" << *diri << " path=" << path << dendl;
+ if (trimmed_path == "") {
+ std::string trimmed_path = path.get_trimmed_path();
+ }
+
+ ldout(cct, 10) << __func__ << ": cur=" << *diri << " path=" << trimmed_path << dendl;
if (path.depth() == 0) {
/* diri/dname can also be used as a filepath; or target */
int caps = 0;
dname = path[i];
ldout(cct, 10) << " " << i << " " << *diri << " " << dname << dendl;
- ldout(cct, 20) << " (path is " << path << ")" << dendl;
+ ldout(cct, 20) << " (path is " << trimmed_path << ")" << dendl;
InodeRef next;
if (should_check_perms()) {
int r = may_lookup(diri.get(), perms);
int Client::_rmdir(Inode *dir, const char *name, const UserPerm& perms, bool check_perms)
{
- ldout(cct, 8) << "_rmdir(" << dir->ino << " " << name << " uid "
+ std::string trimmed_path = filepath(name).get_trimmed_path();
+ ldout(cct, 8) << "_rmdir(" << dir->ino << " " << trimmed_path << " uid "
<< perms.uid() << " gid " << perms.gid() << ")" << dendl;
walk_dentry_result wdr;
- if (int rc = path_walk(dir, filepath(name), &wdr, perms, {.followsym = false}); rc < 0) {
+ if (int rc = path_walk(dir, filepath(name), &wdr, perms, {.followsym = false}, trimmed_path); rc < 0) {
return rc;
}
bool is_rename = false;
bool require_target = true;
};
- int path_walk(InodeRef dirinode, const filepath& fp, struct walk_dentry_result* result, const UserPerm& perms, const PathWalk_ExtraOptions& extra_options);
+ int path_walk(InodeRef dirinode, const filepath& fp, struct walk_dentry_result* result, const UserPerm& perms, const PathWalk_ExtraOptions& extra_options, std::string trimmed_path=std::string());
int path_walk(InodeRef dirinode, const filepath& fp, InodeRef *end, const UserPerm& perms, const PathWalk_ExtraOptions& extra_options);
// fake inode number for 32-bits ino_t
trimmed = true;
}
+ /* Trim given path to final 10 components and return it by prefixing it with
+ * "..." to indicate that the path has been trimmed. */
+ std::string get_trimmed_path() const
+ {
+ std::size_t n = 0;
+ for (int i = 1; i <= 10; ++i) {
+ n = path.rfind("/", n - 1);
+ if (n == std::string::npos) {
+ return std::string(path);
+ }
+ }
+
+ return std::string("..." + path.substr(n, -1));
+ }
+
void set_path(std::string_view s, inodeno_t b) {
path = s;
ino = b;