return;
}
- // can only open non-regular inode with mode FILE_MODE_PIN, at least for now.
- if (!cur->inode.is_file())
+ if (!cur->inode.is_file()) {
+ // can only open non-regular inode with mode FILE_MODE_PIN, at least for now.
cmode = CEPH_FILE_MODE_PIN;
+ // the inode is symlink and client wants to follow it, ignore the O_TRUNC flag.
+ if (cur->inode.is_symlink() && !(flags & O_NOFOLLOW))
+ flags &= ~O_TRUNC;
+ }
dout(10) << "open flags = " << flags
<< ", filemode = " << cmode
return;
}
+ if ((flags & O_TRUNC) && !cur->inode.is_file()) {
+ dout(7) << "specified O_TRUNC on !(file|symlink) " << *cur << dendl;
+ // we should return -EISDIR for directory, return -EINVAL for other non-regular
+ respond_to_request(mdr, cur->inode.is_dir() ? EISDIR : -EINVAL);
+ return;
+ }
+
if (cur->inode.inline_version != CEPH_INLINE_NONE &&
!mdr->session->connection->has_feature(CEPH_FEATURE_MDS_INLINE_DATA)) {
dout(7) << "old client cannot open inline data file " << *cur << dendl;