| 15963 | } |
| 15964 | |
| 15965 | int Client::_create(const walk_dentry_result& wdr, int flags, mode_t mode, |
| 15966 | InodeRef *inp, Fh **fhp, int stripe_unit, int stripe_count, |
| 15967 | int object_size, const char *data_pool, bool *created, |
| 15968 | const UserPerm& perms, std::string alternate_name, |
| 15969 | FSCrypt_Options fscrypt_options) |
| 15970 | { |
| 15971 | ldout(cct, 8) << "_create(" << *wdr.diri << " " << wdr.dname << ", 0" << oct << |
| 15972 | mode << dec << " " << perms << ")" << dendl; |
| 15973 | |
| 15974 | auto& dir = wdr.diri; |
| 15975 | |
| 15976 | if (dir->snapid != CEPH_NOSNAP) { |
| 15977 | return -EROFS; |
| 15978 | } |
| 15979 | |
| 15980 | if (is_quota_files_exceeded(dir.get(), perms)) { |
| 15981 | return -EDQUOT; |
| 15982 | } |
| 15983 | |
| 15984 | // use normalized flags to generate cmode |
| 15985 | int cflags = ceph_flags_sys2wire(flags); |
| 15986 | if (cct->_conf.get_val<bool>("client_force_lazyio")) |
| 15987 | cflags |= CEPH_O_LAZY; |
| 15988 | |
| 15989 | int cmode = ceph_flags_to_mode(cflags); |
| 15990 | |
| 15991 | int64_t pool_id = -1; |
| 15992 | if (data_pool && *data_pool) { |
| 15993 | pool_id = objecter->with_osdmap( |
| 15994 | std::mem_fn(&OSDMap::lookup_pg_pool_name), data_pool); |
| 15995 | if (pool_id < 0) |
| 15996 | return -EINVAL; |
| 15997 | if (pool_id > 0xffffffffll) |
| 15998 | return -ERANGE; // bummer! |
| 15999 | } |
| 16000 | |
| 16001 | MetaRequest *req = new MetaRequest(CEPH_MDS_OP_CREATE); |
| 16002 | |
| 16003 | req->set_inode_owner_uid_gid(perms.uid(), perms.gid()); |
| 16004 | |
| 16005 | req->set_filepath(wdr.getpath()); |
| 16006 | req->set_alternate_name(alternate_name.empty() ? wdr.alternate_name : alternate_name); |
| 16007 | req->set_inode(wdr.diri); |
| 16008 | if (fscrypt_options.fscrypt_auth.size()) |
| 16009 | req->fscrypt_auth = fscrypt_options.fscrypt_auth; |
| 16010 | #if defined(__linux__) |
| 16011 | else |
| 16012 | wdr.diri->gen_inherited_fscrypt_auth(&req->fscrypt_auth); |
| 16013 | #endif |
| 16014 | if (fscrypt_options.fscrypt_file.size()) |
| 16015 | req->fscrypt_file = fscrypt_options.fscrypt_file; |
| 16016 | |
| 16017 | req->head.args.open.flags = cflags | CEPH_O_CREAT; |
| 16018 | |
| 16019 | req->head.args.open.stripe_unit = stripe_unit; |
| 16020 | req->head.args.open.stripe_count = stripe_count; |
| 16021 | req->head.args.open.object_size = object_size; |
| 16022 | if (cct->_conf->client_debug_getattr_caps) |
nothing calls this directly
no test coverage detected