mode_t mode, int stripe_unit, int stripe_count,
int object_size, const char *data_pool)
{
- ldout(cct, 3) << "open enter(" << relpath << ", " << flags << "," << mode << ")" << dendl;
+ ldout(cct, 3) << "open enter(" << relpath << ", " << ceph_flags_sys2wire(flags) << "," << mode << ")" << dendl;
Mutex::Locker lock(client_lock);
tout(cct) << "open" << std::endl;
tout(cct) << relpath << std::endl;
- tout(cct) << flags << std::endl;
+ tout(cct) << ceph_flags_sys2wire(flags) << std::endl;
Fh *fh = NULL;
out:
tout(cct) << r << std::endl;
- ldout(cct, 3) << "open exit(" << path << ", " << flags << ") = " << r << dendl;
+ ldout(cct, 3) << "open exit(" << path << ", " << ceph_flags_sys2wire(flags) << ") = " << r << dendl;
return r;
}
return -EROFS;
}
- int cmode = ceph_flags_to_mode(flags);
+ // use normalized flags to generate cmode
+ int cmode = ceph_flags_to_mode(ceph_flags_sys2wire(flags));
if (cmode < 0)
return -EINVAL;
int want = ceph_caps_for_mode(cmode);
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_OPEN);
filepath path;
in->make_nosnap_relative_path(path);
- req->set_filepath(path);
- req->head.args.open.flags = flags & ~O_CREAT;
+ req->set_filepath(path);
+ req->head.args.open.flags = ceph_flags_sys2wire(flags & ~O_CREAT);
req->head.args.open.mode = mode;
req->head.args.open.pool = -1;
if (cct->_conf->client_debug_getattr_caps)
return -EDQUOT;
}
- int cmode = ceph_flags_to_mode(flags);
+ // use normalized flags to generate cmode
+ int cmode = ceph_flags_to_mode(ceph_flags_sys2wire(flags));
if (cmode < 0)
return -EINVAL;
path.push_dentry(name);
req->set_filepath(path);
req->set_inode(dir);
- req->head.args.open.flags = flags | O_CREAT;
+ req->head.args.open.flags = ceph_flags_sys2wire(flags | O_CREAT);
req->head.args.open.stripe_unit = stripe_unit;
req->head.args.open.stripe_count = stripe_count;
vinodeno_t vino = _get_vino(in);
- ldout(cct, 3) << "ll_open " << vino << " " << flags << dendl;
+ ldout(cct, 3) << "ll_open " << vino << " " << ceph_flags_sys2wire(flags) << dendl;
tout(cct) << "ll_open" << std::endl;
tout(cct) << vino.ino.val << std::endl;
- tout(cct) << flags << std::endl;
+ tout(cct) << ceph_flags_sys2wire(flags) << std::endl;
int r;
if (!cct->_conf->fuse_default_permissions) {
ll_unclosed_fh_set.insert(fhptr);
}
tout(cct) << (unsigned long)fhptr << std::endl;
- ldout(cct, 3) << "ll_open " << vino << " " << flags << " = " << r << " (" <<
- fhptr << ")" << dendl;
+ ldout(cct, 3) << "ll_open " << vino << " " << ceph_flags_sys2wire(flags) <<
+ " = " << r << " (" << fhptr << ")" << dendl;
return r;
}
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "_ll_create " << vparent << " " << name << " 0" << oct <<
- mode << dec << " " << flags << ", uid " << perms.uid()
+ mode << dec << " " << ceph_flags_sys2wire(flags) << ", uid " << perms.uid()
<< ", gid " << perms.gid() << dendl;
tout(cct) << "ll_create" << std::endl;
tout(cct) << vparent.ino.val << std::endl;
tout(cct) << name << std::endl;
tout(cct) << mode << std::endl;
- tout(cct) << flags << std::endl;
+ tout(cct) << ceph_flags_sys2wire(flags) << std::endl;
bool created = false;
int r = _lookup(parent, name, caps, in, perms);
tout(cct) << (unsigned long)*fhp << std::endl;
tout(cct) << ino << std::endl;
ldout(cct, 3) << "_ll_create " << parent << " " << name << " 0" << oct <<
- mode << dec << " " << flags << " = " << r << " (" << *fhp << " " <<
- hex << ino << dec << ")" << dendl;
+ mode << dec << " " << ceph_flags_sys2wire(flags) << " = " << r << " (" <<
+ *fhp << " " << hex << ino << dec << ")" << dendl;
return r;
}
Mutex::Locker lock(client_lock);
InodeRef in;
+
int r = _ll_create(parent, name, mode, oflags, &in, caps, fhp, perms);
if (r >= 0) {
assert(in);
int mode = -1;
#ifdef O_DIRECTORY /* fixme */
- if ((flags & O_DIRECTORY) == O_DIRECTORY)
+ if ((flags & CEPH_O_DIRECTORY) == CEPH_O_DIRECTORY)
return CEPH_FILE_MODE_PIN;
#endif
switch (flags & O_ACCMODE) {
- case O_WRONLY:
+ case CEPH_O_WRONLY:
mode = CEPH_FILE_MODE_WR;
break;
- case O_RDONLY:
+ case CEPH_O_RDONLY:
mode = CEPH_FILE_MODE_RD;
break;
- case O_RDWR:
+ case CEPH_O_RDWR:
case O_ACCMODE: /* this is what the VFS does */
mode = CEPH_FILE_MODE_RDWR;
break;
return caps;
}
+
+int ceph_flags_sys2wire(int flags)
+{
+ int wire_flags = 0;
+
+ switch (flags & O_ACCMODE) {
+ case O_RDONLY:
+ wire_flags |= CEPH_O_RDONLY;
+ break;
+ case O_WRONLY:
+ wire_flags |= CEPH_O_WRONLY;
+ break;
+ case O_RDWR:
+ wire_flags |= CEPH_O_RDWR;
+ break;
+ }
+ flags &= ~O_ACCMODE;
+
+#define ceph_sys2wire(a) if (flags & a) { wire_flags |= CEPH_##a; flags &= ~a; }
+
+ ceph_sys2wire(O_CREAT);
+ ceph_sys2wire(O_EXCL);
+ ceph_sys2wire(O_TRUNC);
+ ceph_sys2wire(O_DIRECTORY);
+ ceph_sys2wire(O_NOFOLLOW);
+
+#undef ceph_sys2wire
+
+ return wire_flags;
+}
#include "osd/OSDMap.h"
#include <errno.h>
-#include <fcntl.h>
#include <list>
#include <iostream>
return;
}
- bool need_auth = !file_mode_is_readonly(cmode) || (flags & O_TRUNC);
+ bool need_auth = !file_mode_is_readonly(cmode) || (flags & CEPH_O_TRUNC);
if ((cmode & CEPH_FILE_MODE_WR) && mdcache->is_readonly()) {
dout(7) << "read-only FS" << dendl;
// 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;
+ if (cur->inode.is_symlink() && !(flags & CEPH_O_NOFOLLOW))
+ flags &= ~CEPH_O_TRUNC;
}
dout(10) << "open flags = " << flags
respond_to_request(mdr, -ENXIO); // FIXME what error do we want?
return;
}*/
- if ((flags & O_DIRECTORY) && !cur->inode.is_dir() && !cur->inode.is_symlink()) {
+ if ((flags & CEPH_O_DIRECTORY) && !cur->inode.is_dir() && !cur->inode.is_symlink()) {
dout(7) << "specified O_DIRECTORY on non-directory " << *cur << dendl;
respond_to_request(mdr, -EINVAL);
return;
}
- if ((flags & O_TRUNC) && !cur->inode.is_file()) {
+ if ((flags & CEPH_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);
}
// O_TRUNC
- if ((flags & O_TRUNC) && !mdr->has_completed) {
+ if ((flags & CEPH_O_TRUNC) && !mdr->has_completed) {
assert(cur->is_auth());
xlocks.insert(&cur->filelock);
return;
}
- if (!(req->head.args.open.flags & O_EXCL)) {
+ if (!(req->head.args.open.flags & CEPH_O_EXCL)) {
int r = mdcache->path_traverse(mdr, NULL, NULL, req->get_filepath(),
&mdr->dn[0], NULL, MDS_TRAVERSE_FORWARD);
if (r > 0) return;
// r == -ENOENT
}
- bool excl = (req->head.args.open.flags & O_EXCL);
+ bool excl = (req->head.args.open.flags & CEPH_O_EXCL);
set<SimpleLock*> rdlocks, wrlocks, xlocks;
file_layout_t *dir_layout = NULL;
CDentry *dn = rdlock_path_xlock_dentry(mdr, 0, rdlocks, wrlocks, xlocks,
if (!dnl->is_null()) {
// it existed.
- assert(req->head.args.open.flags & O_EXCL);
+ assert(req->head.args.open.flags & CEPH_O_EXCL);
dout(10) << "O_EXCL, target exists, failing with -EEXIST" << dendl;
mdr->tracei = dnl->get_inode();
mdr->tracedn = dn;