return r;
}
+int Client::ll_createx(Inode *parent, const char *name, mode_t mode,
+ int oflags, Inode **outp, Fh **fhp,
+ struct ceph_statx *stx, unsigned want, unsigned lflags,
+ const UserPerm& perms)
+{
+ unsigned caps = statx_to_mask(lflags, want);
+ InodeRef in;
+ Mutex::Locker lock(client_lock);
+
+ int r = _ll_create(parent, name, mode, oflags, &in, caps, fhp, perms);
+ if (r >= 0) {
+ assert(in);
+
+ // passing an Inode in outp requires an additional ref
+ if (outp) {
+ _ll_get(in.get());
+ *outp = in.get();
+ }
+ fill_statx(in, caps, stx);
+ } else {
+ stx->stx_ino = 0;
+ stx->stx_mask = 0;
+ }
+
+ return r;
+}
+
loff_t Client::ll_lseek(Fh *fh, loff_t offset, int whence)
{
Mutex::Locker lock(client_lock);
int ll_create(Inode *parent, const char *name, mode_t mode, int flags,
struct stat *attr, Inode **out, Fh **fhp,
const UserPerm& perms);
+ int ll_createx(Inode *parent, const char *name, mode_t mode,
+ int oflags, Inode **outp, Fh **fhp,
+ struct ceph_statx *stx, unsigned want, unsigned lflags,
+ const UserPerm& perms);
int ll_read_block(Inode *in, uint64_t blockid, char *buf, uint64_t offset,
uint64_t length, file_layout_t* layout);
const UserPerm *perms);
int ceph_ll_removexattr(struct ceph_mount_info *cmount, struct Inode *in,
const char *name, const UserPerm *perms);
-int ceph_ll_create(struct ceph_mount_info *cmount, struct Inode *parent,
- const char *name, mode_t mode, int flags,
- struct stat *attr, struct Inode **out, Fh **fhp,
- int uid, int gid);
+int ceph_ll_create(struct ceph_mount_info *cmount, Inode *parent,
+ const char *name, mode_t mode, int oflags, Inode **outp,
+ Fh **fhp, struct ceph_statx *stx, unsigned want,
+ unsigned lflags, const UserPerm *perms);
int ceph_ll_mknod(struct ceph_mount_info *cmount, struct Inode *parent,
const char *name, mode_t mode, dev_t rdev,
struct stat *attr, struct Inode **out,
}
extern "C" int ceph_ll_create(class ceph_mount_info *cmount,
- struct Inode *parent, const char *name,
- mode_t mode, int flags, struct stat *attr,
- struct Inode **out, Fh **fhp, int uid, int gid)
+ Inode *parent, const char *name, mode_t mode,
+ int oflags, Inode **outp, Fh **fhp,
+ struct ceph_statx *stx, unsigned want,
+ unsigned lflags, const UserPerm *perms)
{
- UserPerm perms(uid, gid);
- return (cmount->get_client())->ll_create(parent, name, mode, flags,
- attr, out, fhp, perms);
+ return (cmount->get_client())->ll_createx(parent, name, mode, oflags, outp,
+ fhp, stx, want, lflags, *perms);
}
extern "C" int ceph_ll_mknod(class ceph_mount_info *cmount,
sprintf(c_file, "recordlock_test_%d", getpid());
Fh *fh = NULL;
Inode *root = NULL, *inode = NULL;
- struct stat attr;
+ struct ceph_statx stx;
int rc;
struct flock lock1, lock2;
ASSERT_EQ(rc, 0);
// Get the inode and Fh corresponding to c_file
- rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, &attr,
- &inode, &fh, 0, 0);
+ rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT,
+ &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount));
ASSERT_EQ(rc, 0);
// write lock twice
struct ceph_mount_info *const cmount = s.cmount;
Fh *fh = NULL;
Inode *root = NULL, *inode = NULL;
- struct stat attr;
+ struct ceph_statx stx;
struct flock lock1;
int rc;
struct timespec ts;
ASSERT_EQ(rc, 0);
// Get the inode and Fh corresponding to c_file
- rc = ceph_ll_create(cmount, root, s.file, fileMode, O_RDWR | O_CREAT, &attr,
- &inode, &fh, 0, 0);
+ rc = ceph_ll_create(cmount, root, s.file, fileMode, O_RDWR | O_CREAT,
+ &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount));
ASSERT_EQ(rc, 0);
lock1.l_type = F_WRLCK;
sprintf(c_file, "recordlock_test_%d", mypid);
Fh *fh = NULL;
Inode *root = NULL, *inode = NULL;
- struct stat attr;
+ struct ceph_statx stx;
struct flock lock1;
int rc;
ASSERT_EQ(rc, 0);
// Get the inode and Fh corresponding to c_file
- rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, &attr,
- &inode, &fh, 0, 0);
+ rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT,
+ &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount));
ASSERT_EQ(rc, 0);
// Lock
sprintf(c_file, "recordlock_test_%d", mypid);
Fh *fh = NULL;
Inode *root = NULL, *inode = NULL;
- struct stat attr;
+ struct ceph_statx stx;
struct flock lock1;
int rc;
ASSERT_EQ(rc, 0);
// Get the inode and Fh corresponding to c_file
- rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, &attr,
- &inode, &fh, 0, 0);
+ rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT,
+ &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount));
ASSERT_EQ(rc, 0);
// Lock
struct timespec ts;
Fh *fh = NULL;
Inode *root = NULL, *inode = NULL;
- struct stat attr;
+ struct ceph_statx stx;
int rc;
struct flock lock1;
ASSERT_EQ(rc, 0);
// Get the inode and Fh corresponding to c_file
- rc = ceph_ll_create(cmount, root, s.file, fileMode, O_RDWR | O_CREAT, &attr,
- &inode, &fh, 0, 0);
+ rc = ceph_ll_create(cmount, root, s.file, fileMode, O_RDWR | O_CREAT,
+ &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount));
ASSERT_EQ(rc, 0);
WAIT_MAIN(1); // (R1)
sprintf(c_file, "recordlock_test_%d", mypid);
Fh *fh = NULL;
Inode *root = NULL, *inode = NULL;
- struct stat attr;
+ struct ceph_statx stx;
struct flock lock1;
int rc;
ASSERT_EQ(rc, 0);
// Get the inode and Fh corresponding to c_file
- rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, &attr,
- &inode, &fh, 0, 0);
+ rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT,
+ &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount));
ASSERT_EQ(rc, 0);
// Lock
sprintf(c_file, "recordlock_test_%d", mypid);
Fh *fh = NULL;
Inode *root = NULL, *inode = NULL;
- struct stat attr;
+ struct ceph_statx stx;
struct flock lock1;
int rc;
ASSERT_EQ(rc, 0);
// Get the inode and Fh corresponding to c_file
- rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, &attr,
- &inode, &fh, 0, 0);
+ rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT,
+ &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount));
ASSERT_EQ(rc, 0);
// Lock
ASSERT_EQ(ceph_ll_mkdir(cmount, root, dirname, 0755, &st, &dir, getuid(), getgid()), 0);
ASSERT_EQ(ceph_ll_create(cmount, dir, filename, 0666, O_RDWR|O_CREAT|O_EXCL,
- &st, &file, &fh, getuid(), getgid()), 0);
- ASSERT_EQ(st.st_nlink, (nlink_t)1);
+ &file, &fh, &stx, CEPH_STATX_NLINK, 0, perms), 0);
+ ASSERT_EQ(stx.stx_nlink, (nlink_t)1);
ASSERT_EQ(ceph_ll_link(cmount, file, dir, linkname, &st, getuid(), getgid()), 0);
ASSERT_EQ(st.st_nlink, (nlink_t)2);
ASSERT_EQ(ceph_ll_unlink(cmount, dir, linkname, getuid(), getgid()), 0);
ASSERT_EQ(ceph_ll_lookup(cmount, dir, filename, &file, &stx,
CEPH_STATX_NLINK, 0, perms), 0);
- ASSERT_EQ(st.st_nlink, (nlink_t)1);
+ ASSERT_EQ(stx.stx_nlink, (nlink_t)1);
ceph_shutdown(cmount);
}
sprintf(filename, "lazystatx%x", getpid());
Inode *root1, *file1, *root2, *file2;
- struct stat st;
struct ceph_statx stx;
Fh *fh;
UserPerm *perms1 = ceph_mount_perms(cmount1);
ASSERT_EQ(ceph_ll_lookup_root(cmount1, &root1), 0);
ceph_ll_unlink(cmount1, root1, filename, getuid(), getgid());
ASSERT_EQ(ceph_ll_create(cmount1, root1, filename, 0666, O_RDWR|O_CREAT|O_EXCL,
- &st, &file1, &fh, getuid(), getgid()), 0);
-
+ &file1, &fh, &stx, 0, 0, perms1), 0);
ASSERT_EQ(ceph_ll_lookup_root(cmount2, &root2), 0);