| 12087 | } |
| 12088 | |
| 12089 | int Client::write(int fd, const char *buf, loff_t size, loff_t offset) |
| 12090 | { |
| 12091 | RWRef_t mref_reader(mount_state, CLIENT_MOUNTING); |
| 12092 | if (!mref_reader.is_state_satisfied()) |
| 12093 | return -ENOTCONN; |
| 12094 | |
| 12095 | tout(cct) << "write" << std::endl; |
| 12096 | tout(cct) << fd << std::endl; |
| 12097 | tout(cct) << size << std::endl; |
| 12098 | tout(cct) << offset << std::endl; |
| 12099 | |
| 12100 | std::scoped_lock lock(client_lock); |
| 12101 | Fh *fh = get_filehandle(fd); |
| 12102 | if (!fh) |
| 12103 | return -EBADF; |
| 12104 | #if defined(__linux__) && defined(O_PATH) |
| 12105 | if (fh->flags & O_PATH) |
| 12106 | return -EBADF; |
| 12107 | #endif |
| 12108 | #if defined(__linux__) |
| 12109 | /* We can't return bytes written larger than INT_MAX, clamp size to |
| 12110 | * that or FSCRYPT_MAXIO_SIZE*/ |
| 12111 | Inode *in = fh->inode.get(); |
| 12112 | if (in->is_fscrypt_enabled()) { |
| 12113 | size = std::min(size, (loff_t)FSCRYPT_MAXIO_SIZE); |
| 12114 | } else { |
| 12115 | size = std::min(size, (loff_t)INT_MAX); |
| 12116 | } |
| 12117 | #else |
| 12118 | size = std::min(size, (loff_t)INT_MAX); |
| 12119 | #endif |
| 12120 | bufferlist bl; |
| 12121 | bl.append(buf, size); |
| 12122 | int r = _write(fh, offset, size, std::move(bl)); |
| 12123 | ldout(cct, 3) << "write(" << fd << ", \"...\", " << size << ", " << offset << ") = " << r << dendl; |
| 12124 | return r; |
| 12125 | } |
| 12126 | |
| 12127 | int Client::pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset) |
| 12128 | { |
no test coverage detected