if (r < 0) {
return r;
}
- return _mkdir(dirinode.get(), relpath, mode, perm, 0, {}, std::move(alternate_name));
+
+ walk_dentry_result wdr;
+ if (int rc = path_walk(dirinode, filepath(relpath), &wdr, perm, {.require_target = false}); rc < 0) {
+ return rc;
+ }
+
+ return _mkdir(wdr, mode, perm, 0, {}, std::move(alternate_name));
}
int Client::mkdirs(const char *relpath, mode_t mode, const UserPerm& perms)
if (int rc = path_walk(cwd, path, &wdr, perms, {.followsym = false}); rc < 0) {
if (rc == -ENOENT) {
InodeRef in;
- rc = _mkdir(wdr.diri.get(), wdr.dname.c_str(), mode, perms, &in);
+ rc = _mkdir(wdr, mode, perms, &in);
switch (rc) {
case 0:
case EEXIST:
return -ENOTCONN;
std::scoped_lock l(client_lock);
- InodeRef in;
- if (int rc = path_walk(cwd, filepath(relpath), &in, perm, {}); rc < 0) {
+ walk_dentry_result wdr;
+ if (int rc = path_walk(cwd, filepath(relpath), &wdr, perm, {}); rc < 0) {
return rc;
}
- auto snapdir = open_snapdir(in.get());
- return _mkdir(snapdir.get(), name, mode, perm, nullptr, metadata);
+ auto snapdir = open_snapdir(wdr.target);
+ if (int rc = path_walk(std::move(snapdir), filepath(name), &wdr, perm, {.require_target = false}); rc < 0) {
+ return rc;
+ }
+ return _mkdir(wdr, mode, perm, nullptr, metadata);
}
int Client::rmsnap(const char *relpath, const char *name, const UserPerm& perms, bool check_perms)
return res;
}
-int Client::_mkdir(Inode *dir, const char *name, mode_t mode, const UserPerm& perm,
+int Client::_mkdir(const walk_dentry_result& wdr, mode_t mode, const UserPerm& perm,
InodeRef *inp, const std::map<std::string, std::string> &metadata,
std::string alternate_name)
{
- ldout(cct, 8) << "_mkdir(" << dir->ino << " " << name << ", 0" << oct
- << mode << dec << ", uid " << perm.uid()
+ ldout(cct, 8) << "_mkdir(" << wdr << ", 0o" << std::oct << mode << std::dec
+ << ", uid " << perm.uid()
<< ", gid " << perm.gid() << ")" << dendl;
- walk_dentry_result wdr;
- if (int rc = path_walk(dir, filepath(name), &wdr, perm, {.require_target = false}); rc < 0) {
- return rc;
- } else if (rc == 0 && wdr.target) {
+ if (wdr.target) {
return -EEXIST;
}
std::scoped_lock lock(client_lock);
+ walk_dentry_result wdr;
+ if (int rc = path_walk(parent, filepath(name), &wdr, perm, {.require_target = false}); rc < 0) {
+ return rc;
+ }
+
InodeRef in;
- int r = _mkdir(parent, name, mode, perm, &in);
+ int r = _mkdir(wdr, mode, perm, &in);
if (r == 0) {
fill_stat(in, attr);
_ll_get(in.get());
std::scoped_lock lock(client_lock);
+ walk_dentry_result wdr;
+ if (int rc = path_walk(parent, filepath(name), &wdr, perms, {.require_target = false}); rc < 0) {
+ return rc;
+ }
+
InodeRef in;
- int r = _mkdir(parent, name, mode, perms, &in);
+ int r = _mkdir(wdr, mode, perms, &in);
if (r == 0) {
fill_statx(in, statx_to_mask(flags, want), stx);
_ll_get(in.get());
int _link(Inode *diri_from, const char* path_from, Inode* diri_to, const char* path_to, const UserPerm& perm, std::string alternate_name);
int _unlink(Inode *dir, const char *name, const UserPerm& perm);
int _rename(Inode *olddir, const char *oname, Inode *ndir, const char *nname, const UserPerm& perm, std::string alternate_name);
- int _mkdir(Inode *dir, const char *name, mode_t mode, const UserPerm& perm,
+ int _mkdir(const walk_dentry_result& wdr, mode_t mode, const UserPerm& perm,
InodeRef *inp = 0, const std::map<std::string, std::string> &metadata={},
std::string alternate_name="");
int _rmdir(Inode *dir, const char *name, const UserPerm& perms, bool check_perms=true);