]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-fuse: add ioctl support 306/head
authorAndras Elso <elso.andras@gmail.com>
Tue, 21 May 2013 19:51:55 +0000 (21:51 +0200)
committerAndras Elso <elso.andras@gmail.com>
Tue, 21 May 2013 19:53:38 +0000 (21:53 +0200)
Signed-off-by: Andras Elso <elso.andras@gmail.com>
src/client/Client.cc
src/client/Client.h
src/client/fuse_ll.cc

index a2275c5342d2f7001ba6543ecd0261703f108dd7..0b4d87b2066966be2cf36069acb8f8206977c6bc 100644 (file)
@@ -7462,6 +7462,18 @@ int Client::ll_link(vinodeno_t vino, vinodeno_t newparent, const char *newname,
   return r;
 }
 
+int Client::ll_describe_layout(Fh *fh, ceph_file_layout* lp)
+{
+  Mutex::Locker lock(client_lock);
+  ldout(cct, 3) << "ll_describe_layout " << fh << " " << fh->inode->ino << dendl;
+  tout(cct) << "ll_describe_layout" << std::endl;
+
+  Inode *in = fh->inode;
+  *lp = in->layout;
+
+  return 0;
+}
+
 int Client::ll_opendir(vinodeno_t vino, void **dirpp, int uid, int gid)
 {
   Mutex::Locker lock(client_lock);
index b0bc6e0e1e4ce79f54b9a34be406cfad03568014..22c6852baa6fa531b30b3ab6db610f1f888f6419 100644 (file)
@@ -713,6 +713,7 @@ public:
   int ll_rmdir(vinodeno_t vino, const char *name, int uid = -1, int gid = -1);
   int ll_rename(vinodeno_t parent, const char *name, vinodeno_t newparent, const char *newname, int uid = -1, int gid = -1);
   int ll_link(vinodeno_t vino, vinodeno_t newparent, const char *newname, struct stat *attr, int uid = -1, int gid = -1);
+  int ll_describe_layout(Fh *fh, ceph_file_layout* layout);
   int ll_open(vinodeno_t vino, int flags, Fh **fh, int uid = -1, int gid = -1);
   int ll_create(vinodeno_t parent, const char *name, mode_t mode, int flags, struct stat *attr, Fh **fh, int uid = -1, int gid = -1);
   int ll_read(Fh *fh, loff_t off, loff_t len, bufferlist *bl);
index 57d79dfbe0327807253b7f229be4ae887ee8aa89..46480e61974d901c4d0529f434d87a4b7f276fef 100644 (file)
@@ -28,6 +28,7 @@
 #include "common/safe_io.h"
 #include "include/types.h"
 #include "Client.h"
+#include "ioctl.h"
 #include "common/config.h"
 #include "include/assert.h"
 
@@ -368,6 +369,34 @@ static void fuse_ll_flush(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info
   fuse_reply_err(req, 0);
 }
 
+static void fuse_ll_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, struct fuse_file_info *fi,
+                          unsigned flags, const void *in_buf, size_t in_bufsz, size_t out_bufsz)
+{
+  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+
+  if (flags & FUSE_IOCTL_COMPAT) {
+    fuse_reply_err(req, ENOSYS);
+    return;
+  }
+
+  switch(cmd) {
+    case CEPH_IOC_GET_LAYOUT: {
+      struct ceph_file_layout layout;
+      struct ceph_ioctl_layout l;
+      Fh *fh = (Fh*)fi->fh;
+      cfuse->client->ll_describe_layout(fh, &layout);
+      l.stripe_unit = layout.fl_stripe_unit;
+      l.stripe_count = layout.fl_stripe_count;
+      l.object_size = layout.fl_object_size;
+      l.data_pool = layout.fl_pg_pool;
+      fuse_reply_ioctl(req, 0, &l, sizeof(struct ceph_ioctl_layout));
+    }
+    break;
+    default:
+      fuse_reply_err(req, EINVAL);
+  }
+}
+
 static void fuse_ll_release(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
 {
   CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
@@ -567,7 +596,8 @@ const static struct fuse_lowlevel_ops fuse_ll_oper = {
  create: fuse_ll_create,
  getlk: 0,
  setlk: 0,
- bmap: 0
+ bmap: 0,
+ ioctl: fuse_ll_ioctl
 };