]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libceph -> libcephfs
authorSage Weil <sage@newdream.net>
Thu, 22 Sep 2011 22:07:19 +0000 (15:07 -0700)
committerSage Weil <sage@newdream.net>
Thu, 22 Sep 2011 22:08:25 +0000 (15:08 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
24 files changed:
ceph.spec.in
debian/.gitignore
debian/control
debian/libceph-dev.install
debian/libceph1.install
debian/rules
doc/architecture.rst
doc/dev/libs.rst
doc/ops/install/mkcephfs.rst
src/Makefile.am
src/client/hadoop/CephFSInterface.cc
src/client/hadoop/HADOOP-ceph.patch
src/client/hadoop/ceph/CephFileSystem.java
src/client/hadoop/ceph/CephTalker.java
src/client/hadoop/ceph/package.html
src/client/hypertable/CephBroker.cc
src/client/testceph.cc
src/common/config.h
src/include/ceph/libceph.h [deleted file]
src/include/cephfs/libcephfs.h [new file with mode: 0644]
src/libceph.cc [deleted file]
src/libcephfs.cc [new file with mode: 0644]
src/test/daemon_config.cc
src/test/libceph_config.cc

index 40d8f201ed946cc50d739ce65415f5d23f4fb3ff..4cce04ef7c0716422f64551bd3f616770a34d460 100644 (file)
@@ -178,7 +178,7 @@ fi
 %{_bindir}/ceph-coverage
 %{_bindir}/obsync
 %{_initrddir}/ceph
-%{_libdir}/libceph.so.*
+%{_libdir}/libcephfs.so.*
 %{_libdir}/librados.so.*
 %{_libdir}/librbd.so.*
 %{_libdir}/rados-classes/libcls_rbd.so.*
@@ -234,7 +234,7 @@ fi
 %files devel
 %defattr(-,root,root,-)
 %doc COPYING
-%{_includedir}/ceph/libceph.h
+%{_includedir}/cephfs/libcephfs.h
 %{_includedir}/crush/crush.h
 %{_includedir}/crush/hash.h
 %{_includedir}/crush/mapper.h
index 2860422a96fb879dec8e0969c83dddc280c1a378..1409714d50291526fb6bd2beef6f72003f57977f 100644 (file)
@@ -10,9 +10,9 @@
 /*.debhelper
 /ceph
 /files
-/libceph1-dbg
-/libceph-dev
-/libceph1
+/libcephfs1-dbg
+/libcephfs-dev
+/libcephfs1
 /librados2-dbg
 /librados-dev
 /librados2
index eb583e77a5d7bd631e1036eb4169538020ba367b..184f93c8f8e7cd8bb6e5345f60e862b9faf89275 100644 (file)
@@ -12,7 +12,7 @@ Standards-Version: 3.9.1
 Package: ceph
 Architecture: linux-any
 Depends: ${shlibs:Depends}, ${misc:Depends}, hdparm, binutils
-Recommends: ceph-client-tools, ceph-fuse, libceph1, librados2, librbd1, btrfs-tools, gceph
+Recommends: ceph-client-tools, ceph-fuse, libcephfs1, librados2, librbd1, btrfs-tools, gceph
 Description: distributed storage and file system
  Ceph is a distributed storage and network file system designed to provide
  excellent performance, reliability, and scalability.
@@ -186,9 +186,9 @@ Description: RADOS block device client library (development files)
  This package contains development files needed for building applications that
  link against librbd1.
 
-Package: libceph1
-Conflicts: libceph
-Replaces: libceph
+Package: libcephfs1
+Conflicts: libcephfs
+Replaces: libcephfs
 Architecture: linux-any
 Section: libs
 Depends: ${shlibs:Depends}, ${misc:Depends}
@@ -198,25 +198,25 @@ Description: Ceph distributed file system client library
  shared library allowing applications to access a Ceph distributed
  file system via a POSIX-like interface.
 
-Package: libceph1-dbg
+Package: libcephfs1-dbg
 Architecture: linux-any
 Section: debug
 Priority: extra
-Depends: libceph1 (= ${binary:Version}), ${misc:Depends}
-Description: debugging symbols for libceph1
+Depends: libcephfs1 (= ${binary:Version}), ${misc:Depends}
+Description: debugging symbols for libcephfs1
  Ceph is a distributed network file system designed to provide
  excellent performance, reliability, and scalability.  This is a
  shared library allowing applications to access a Ceph distributed
  file system via a POSIX-like interface.
  .
- This package contains debugging symbols for libceph1.
+ This package contains debugging symbols for libcephfs1.
 
-Package: libceph-dev
+Package: libcephfs-dev
 Architecture: linux-any
 Section: libdevel
-Depends: ${misc:Depends}, libceph1 (= ${binary:Version})
-Conflicts: libceph1-dev
-Replaces: libceph1-dev
+Depends: ${misc:Depends}, libcephfs1 (= ${binary:Version})
+Conflicts: libcephfs1-dev
+Replaces: libcephfs1-dev
 Description: Ceph distributed file system client library (development files)
  Ceph is a distributed network file system designed to provide
  excellent performance, reliability, and scalability.  This is a
@@ -224,7 +224,7 @@ Description: Ceph distributed file system client library (development files)
  file system via a POSIX-like interface.
  .
  This package contains development files needed for building applications that
- link against libceph.
+ link against libcephfs.
 
 Package: librgw1
 Conflicts: librgw, librgw1
index 9951a2b343ce95b5d2b8c6c28e7fc15f1a560bb7..902fb950cc151cbb98e28275a76c38a851fb3bfd 100644 (file)
@@ -1,4 +1,4 @@
-usr/lib/libceph.so
-usr/lib/libceph.a
-usr/lib/libceph.la
-usr/include/ceph/libceph.h
+usr/lib/libcephfs.so
+usr/lib/libcephfs.a
+usr/lib/libcephfs.la
+usr/include/cephfs/libcephfs.h
index 7008bb6422259d22441fea3ae3114b5b23fcbcb7..a5266dfbca3e34cb6ae2ce7d8fcd995f259faf3e 100644 (file)
@@ -1,2 +1,2 @@
-usr/lib/libceph.so.*
+usr/lib/libcephfs.so.*
 
index ad1782b3d1fa05337d09a7b12db1f9c7b6d45c6a..e604c2e0930b292afd53d90b7998868e934fee61 100755 (executable)
@@ -106,7 +106,7 @@ binary-arch: build install
        dh_strip -pceph-client-tools --dbg-package=ceph-client-tools-dbg
        dh_strip -plibrados2 --dbg-package=librados2-dbg
        dh_strip -plibrbd1 --dbg-package=librbd1-dbg
-       dh_strip -plibceph1 --dbg-package=libceph1-dbg
+       dh_strip -plibcephfs1 --dbg-package=libcephfs1-dbg
        dh_strip -pradosgw --dbg-package=radosgw-dbg
        dh_strip -pgceph --dbg-package=gceph-dbg
        dh_strip -plibrgw1 --dbg-package=librgw1-dbg
index e8f8b6d874d8d33a854fd766066415efe699c25e..2bd5c55cc71396811173f9a17749cd0999bfe90e 100644 (file)
@@ -173,7 +173,7 @@ better than a single server could.
 Client
 ======
 
-.. todo:: cephfs, ceph-fuse, librados, libceph, librbd
+.. todo:: cephfs, ceph-fuse, librados, libcephfs, librbd
 
 
 .. todo:: Summarize how much Ceph trusts the client, for what parts (security vs reliability).
index bdebdb3b000499d0eac6baa0855c8562f2fd99c9..203dd38b06dd2c54bf2c09fe3e7e896f89d85984 100644 (file)
@@ -8,7 +8,7 @@ make executables and other libraries.
 - libcommon: a collection of utilities which are available to nearly every ceph
   library and executable. In general, libcommon should not contain global
   variables, because it is intended to be linked into libraries such as
-  libceph.so.
+  libcephfs.so.
 
 - libglobal: a collection of utilities focused on the needs of Ceph daemon
   programs. In here you will find pidfile management functions, signal
index 3645383b2f9a21d4c54a57b8c0bf04e1a3cc2182..58a6da3c900656108b3157a190f7fc18d9d057bb 100644 (file)
@@ -55,9 +55,9 @@ Run these commands on all nodes::
 .. todo:: For older distributions, you may need to make sure your apt-get may read .bz2 compressed files. This works for Debian Lenny 5.0.3: ``apt-get install bzip2``
 
 .. todo:: Ponder packages; ceph.deb currently pulls in gceph (ceph.deb
-   Recommends: ceph-client-tools ceph-fuse libceph1 librados2 librbd1
+   Recommends: ceph-client-tools ceph-fuse libcephfs1 librados2 librbd1
    btrfs-tools gceph) (other interesting: ceph-client-tools ceph-fuse
-   libceph-dev librados-dev librbd-dev obsync python-ceph radosgw)
+   libcephfs-dev librados-dev librbd-dev obsync python-ceph radosgw)
 
 
 Red Hat / CentOS / Fedora
index ef5e17a66f8b7fc9b4fd14844375655e717d7277..2eaf84e3076c8086926438e8ad63a511d58f82b1 100644 (file)
@@ -199,16 +199,16 @@ test_librgw_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
 test_librgw_build_CXXFLAGS = $(AM_CXXFLAGS)
 bin_DEBUGPROGRAMS += test_librgw_build
 
-test_libceph_build_SOURCES = test/test_libcommon_build.cc $(libcommon_files) \
-                           $(libceph_la_SOURCES) $(libosdc_la_SOURCES)
-test_libceph_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
-test_libceph_build_CXXFLAGS = $(AM_CXXFLAGS)
-bin_DEBUGPROGRAMS += test_libceph_build
+test_libcephfs_build_SOURCES = test/test_libcommon_build.cc $(libcommon_files) \
+                           $(libcephfs_la_SOURCES) $(libosdc_la_SOURCES)
+test_libcephfs_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
+test_libcephfs_build_CXXFLAGS = $(AM_CXXFLAGS)
+bin_DEBUGPROGRAMS += test_libcephfs_build
 endif
 
 if WITH_HADOOPCLIENT
 test_libhadoopcephfs_build_SOURCES = test/test_libcommon_build.cc \
-         $(libhadoopcephfs_la_SOURCES) $(libceph_la_SOURCES) \
+         $(libhadoopcephfs_la_SOURCES) $(libcephfs_la_SOURCES) \
         $(libosdc_la_SOURCES) $(libcommon_files)
 test_libhadoopcephfs_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
 test_libhadoopcephfs_build_CXXFLAGS = $(AM_CXXFLAGS)
@@ -221,21 +221,21 @@ lib_LTLIBRARIES =
 noinst_LTLIBRARIES = 
 noinst_LIBRARIES =
 
-# libceph
-libceph_la_SOURCES = \
-       libceph.cc \
+# libcephfs
+libcephfs_la_SOURCES = \
+       libcephfs.cc \
        client/Client.cc \
        client/Inode.cc \
        client/MetaRequest.cc
-libceph_la_CFLAGS= ${CRYPTO_CFLAGS} ${AM_CFLAGS}
-libceph_la_CXXFLAGS= ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS}
-libceph_la_LIBADD = libosdc.la
-libceph_la_LDFLAGS =  -lpthread $(CRYPTO_LIBS) $(EXTRALIBS) \
+libcephfs_la_CFLAGS= ${CRYPTO_CFLAGS} ${AM_CFLAGS}
+libcephfs_la_CXXFLAGS= ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS}
+libcephfs_la_LIBADD = libosdc.la
+libcephfs_la_LDFLAGS =  -lpthread $(CRYPTO_LIBS) $(EXTRALIBS) \
             ${AM_LDFLAGS} -version-info 1:0:0 -export-symbols-regex '^ceph_.*'
-lib_LTLIBRARIES += libceph.la
+lib_LTLIBRARIES += libcephfs.la
 
 testceph_SOURCES = client/testceph.cc
-testceph_LDADD = libceph.la -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
+testceph_LDADD = libcephfs.la -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
 bin_DEBUGPROGRAMS += testceph
 
 testtimers_SOURCES = test/TestTimers.cc
@@ -371,7 +371,7 @@ radoslib_LTLIBRARIES = libcls_rbd.la
 if WITH_HADOOPCLIENT
 JAVA_BASE = /usr/lib/jvm/java-6-sun
 libhadoopcephfs_la_SOURCES = client/hadoop/CephFSInterface.cc
-libhadoopcephfs_la_LIBADD = libceph.la
+libhadoopcephfs_la_LIBADD = libcephfs.la
 libhadoopcephfs_la_CFLAGS = ${AM_CFLAGS}
 libhadoopcephfs_la_CXXFLAGS = ${AM_CXXFLAGS}
 libhadoopcephfs_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0 -export-symbols-regex 'hadoopcephfs_.*'
@@ -435,7 +435,7 @@ UNITTEST_STATIC_LDADD = \
        -lpthread
 
 unittest_encoding_SOURCES = test/encoding.cc
-unittest_encoding_LDADD = libceph.la -lpthread -lm \
+unittest_encoding_LDADD = libcephfs.la -lpthread -lm \
                          ${UNITTEST_LDADD}
 unittest_encoding_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} \
                     -fno-strict-aliasing
@@ -443,7 +443,7 @@ check_PROGRAMS += unittest_encoding
 
 unittest_base64_SOURCES = test/base64.cc
 unittest_base64_LDFLAGS = -pthread ${AM_LDFLAGS}
-unittest_base64_LDADD = libceph.la -lm ${UNITTEST_LDADD}
+unittest_base64_LDADD = libcephfs.la -lm ${UNITTEST_LDADD}
 unittest_base64_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_base64
 
@@ -459,7 +459,7 @@ unittest_gather_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_gather
 
 unittest_run_cmd_SOURCES = test/run_cmd.cc
-unittest_run_cmd_LDADD = libceph.la ${UNITTEST_LDADD}
+unittest_run_cmd_LDADD = libcephfs.la ${UNITTEST_LDADD}
 unittest_run_cmd_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_run_cmd
 
@@ -469,7 +469,7 @@ unittest_signals_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_signals
 
 unittest_simple_spin_SOURCES = test/simple_spin.cc
-unittest_simple_spin_LDADD = libceph.la ${UNITTEST_LDADD}
+unittest_simple_spin_LDADD = libcephfs.la ${UNITTEST_LDADD}
 unittest_simple_spin_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_simple_spin
 
@@ -550,11 +550,11 @@ unittest_formatter_LDADD = ${UNITTEST_LDADD} $(LIBGLOBAL_LDA)
 unittest_formatter_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_formatter
 
-unittest_libceph_config_SOURCES = test/libceph_config.cc
-unittest_libceph_config_LDFLAGS = -pthread ${AM_LDFLAGS}
-unittest_libceph_config_LDADD =  libceph.la ${UNITTEST_LDADD}
-unittest_libceph_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
-check_PROGRAMS += unittest_libceph_config
+unittest_libcephfs_config_SOURCES = test/libcephfs_config.cc
+unittest_libcephfs_config_LDFLAGS = -pthread ${AM_LDFLAGS}
+unittest_libcephfs_config_LDADD =  libcephfs.la ${UNITTEST_LDADD}
+unittest_libcephfs_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+check_PROGRAMS += unittest_libcephfs_config
 
 unittest_librados_config_SOURCES = test/librados_config.cc
 unittest_librados_config_LDFLAGS = -pthread ${AM_LDFLAGS}
@@ -725,8 +725,8 @@ bash_completion_DATA = $(srcdir)/bash_completion/ceph \
                $(srcdir)/bash_completion/rbd \
                $(srcdir)/bash_completion/radosgw_admin
 
-libceph_includedir = $(includedir)/ceph
-libceph_include_DATA = $(srcdir)/include/ceph/libceph.h
+libcephfs_includedir = $(includedir)/cephfs
+libcephfs_include_DATA = $(srcdir)/include/cephfs/libcephfs.h
 
 librbd_includedir = $(includedir)/rbd
 librbd_include_DATA = \
@@ -1086,7 +1086,7 @@ noinst_HEADERS = \
         include/blobhash.h\
         include/buffer.h\
         include/byteorder.h\
-       include/ceph/libceph.h\
+       include/cephfs/libcephfs.h\
        include/ceph_frag.h\
         include/ceph_fs.h\
         include/ceph_hash.h\
index af7f718d1bb858a9bedecf236684fc81804de5c2..1a8beafde65098278d54459553bd0457e0d0b253 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode:c++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 #include "CephFSInterface.h"
-#include "include/ceph/libceph.h"
+#include "include/cephfs/libcephfs.h"
 #include "common/ceph_argparse.h"
 #include "common/config.h"
 #include "msg/SimpleMessenger.h"
index 1f3c7a3a919c159109f629a6d781e505c20231f3..388916a7faa30e5c6b4f64bfe5cd799fcb17e27e 100644 (file)
@@ -87,7 +87,7 @@ Index: src/java/org/apache/hadoop/fs/ceph/CephTalker.java
 +      public CephTalker(Configuration conf, Log log) {
 +              super(conf, log);
 +              System.load(conf.get("fs.ceph.libDir")+"/libhadoopcephfs.so");
-+              System.load(conf.get("fs.ceph.libDir")+"/libceph.so");
++              System.load(conf.get("fs.ceph.libDir")+"/libcephfs.so");
 +      }
 +      protected native boolean ceph_initializeClient(String arguments, int block_size);
 +      protected native String ceph_getcwd();
@@ -173,9 +173,9 @@ Index: src/java/org/apache/hadoop/fs/ceph/CephFileSystem.java
 + * Configuration of the CephFileSystem is handled via a few Hadoop
 + * Configuration properties: <br>
 + * fs.ceph.monAddr -- the ip address/port of the monitor to connect to. <br>
-+ * fs.ceph.libDir -- the directory that libceph and libhadoopceph are
++ * fs.ceph.libDir -- the directory that libcephfs and libhadoopceph are
 + * located in. This assumes Hadoop is being run on a linux-style machine
-+ * with names like libceph.so.
++ * with names like libcephfs.so.
 + * fs.ceph.commandLine -- if you prefer you can fill in this property
 + * just as you would when starting Ceph up from the command line. Specific
 + * properties override any configuration specified here.
@@ -2236,7 +2236,7 @@ Index: src/java/org/apache/hadoop/fs/ceph/package.html
 +&lt;property&gt;
 +  &lt;name&gt;fs.ceph.libDir&lt;/name&gt;
 +  &lt;value&gt;/usr/local/lib&lt;/value&gt;
-+  &lt;description&gt;The folder holding libceph and libhadoopceph&lt;/description&gt;
++  &lt;description&gt;The folder holding libcephfs and libhadoopceph&lt;/description&gt;
 +  &lt;/property&gt;
 +</pre>
 +  <li>There are also a number of optional Ceph configuration options.
index d081558d1d167034740e86eecd04a90c64332a48..e57442e889acbc442dff1930f44de135e1e8a5b1 100644 (file)
@@ -52,9 +52,9 @@ import org.apache.hadoop.fs.CreateFlag;
  * Configuration of the CephFileSystem is handled via a few Hadoop
  * Configuration properties: <br>
  * fs.ceph.monAddr -- the ip address/port of the monitor to connect to. <br>
- * fs.ceph.libDir -- the directory that libceph and libhadoopceph are
+ * fs.ceph.libDir -- the directory that libcephfs and libhadoopceph are
  * located in. This assumes Hadoop is being run on a linux-style machine
- * with names like libceph.so.
+ * with names like libcephfs.so.
  * fs.ceph.commandLine -- if you prefer you can fill in this property
  * just as you would when starting Ceph up from the command line. Specific
  * properties override any configuration specified here.
index 4bda160d19f8ffb06c85e77723083ccc721887d8..8b52441b60eb6d1ce8bb8f7fdeaa7845797e5bcc 100644 (file)
@@ -34,7 +34,7 @@ class CephTalker extends CephFS {
   public CephTalker(Configuration conf, Log log) {
     super(conf, log);
     System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so");
-    System.load(conf.get("fs.ceph.libDir") + "/libceph.so");
+    System.load(conf.get("fs.ceph.libDir") + "/libcephfs.so");
     cluster = 0;
   }
 
index 058a3ec83f60453beba08cb9a99b4f1704c7d4a2..8167b1dde92089e57e8142deef44fc5b939d26b3 100644 (file)
@@ -50,7 +50,7 @@ documentation.
 &lt;property&gt;
   &lt;name&gt;fs.ceph.libDir&lt;/name&gt;
   &lt;value&gt;/usr/local/lib&lt;/value&gt;
-  &lt;description&gt;The folder holding libceph and libhadoopceph&lt;/description&gt;
+  &lt;description&gt;The folder holding libcephfs and libhadoopceph&lt;/description&gt;
   &lt;/property&gt;
 </pre>
   <li>There are also a number of optional Ceph configuration options.
@@ -98,4 +98,4 @@ By default, Ceph performs writes across the network rather than locally. To forc
       up an hdfs instance. Just start whatever systems you need and they will
       automatically make use of the Ceph filesystem once configured as above.</li>
 </body>
-</html>
\ No newline at end of file
+</html>
index 9d610dfb3e3941290ddf5c936870fb511b4b3338..96fd4830ec218121917688942a592aa4e3e70ff5 100644 (file)
@@ -29,7 +29,7 @@
 #include "Common/Filesystem.h"
 #include "Common/System.h"
 
-#include <ceph/libceph.h>
+#include <cephfs/libcephfs.h>
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
index 7601b7cef6fbbcc2277a5be1b87e478d912d5d41..5e95e902727bb742484089ded3d55c10c9bd267a 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 #include "common/errno.h"
-#include "include/ceph/libceph.h"
+#include "include/cephfs/libcephfs.h"
 #include <stdlib.h>
 
 #include <errno.h>
index 08a6c6b31f589194b22caf0313dbeeac03b56de5..f0f6c3feb99bbb48c5be3c38bd9e0a776ad1f004 100644 (file)
@@ -45,7 +45,7 @@ extern const char *CEPH_CONF_FILE_DEFAULT;
 /** This class represents the current Ceph configuration.
  *
  * For Ceph daemons, this is the daemon configuration.  Log levels, caching
- * settings, btrfs settings, and so forth can all be found here.  For libceph
+ * settings, btrfs settings, and so forth can all be found here.  For libcephfs
  * and librados users, this is the configuration associated with their context.
  *
  * For information about how this class is loaded from a configuration file,
diff --git a/src/include/ceph/libceph.h b/src/include/ceph/libceph.h
deleted file mode 100644 (file)
index f8dbe79..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2009-2011 New Dream Network
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation.  See file COPYING.
- *
- */
-
-#ifndef CEPH_LIB_H
-#define CEPH_LIB_H
-
-#include <utime.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __USE_FILE_OFFSET64
-# error libceph: must define __USE_FILE_OFFSET64 or readdir results will be corrupted
-#endif
-
-struct ceph_mount_info;
-struct ceph_dir_result;
-struct CephContext;
-
-const char *ceph_version(int *major, int *minor, int *patch);
-
-/* initialization */
-int ceph_create(struct ceph_mount_info **cmount, const char * const id);
-
-/* initialization with an existing configuration */
-int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext *conf);
-
-/* Activate the mount */
-int ceph_mount(struct ceph_mount_info *cmount, const char *root);
-
-/* Destroy the ceph mount instance */
-void ceph_shutdown(struct ceph_mount_info *cmount);
-
-/* Config
- *
- * Functions for manipulating the Ceph configuration at runtime.
- */
-int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path_list);
-
-int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, const char **argv);
-
-/* Sets a configuration value from a string.
- * Returns 0 on success, error code otherwise. */
-int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, const char *value);
-
-/* Returns a configuration value as a string.
- * If len is positive, that is the maximum number of bytes we'll write into the
- * buffer. If len == -1, we'll call malloc() and set *buf.
- * Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the
- * buffer is too short. */
-int ceph_conf_get(struct ceph_mount_info *cmount, const char *option, char *buf, size_t len);
-
-int ceph_statfs(struct ceph_mount_info *cmount, const char *path, struct statvfs *stbuf);
-
-/* Get the current working directory.
- *
- * The pointer you get back from this function will continue to be valid until
- * the *next* call you make to ceph_getcwd, at which point it will be invalidated.
- */
-const char* ceph_getcwd(struct ceph_mount_info *cmount);
-
-int ceph_chdir(struct ceph_mount_info *cmount, const char *s);
-
-int ceph_opendir(struct ceph_mount_info *cmount, const char *name, struct ceph_dir_result **dirpp);
-int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
-struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
-int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de);
-int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de,
-                      struct stat *st, int *stmask);
-int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen);
-int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen);
-void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
-loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
-void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset);
-
-int ceph_link(struct ceph_mount_info *cmount, const char *existing, const char *newname);
-int ceph_unlink(struct ceph_mount_info *cmount, const char *path);
-int ceph_rename(struct ceph_mount_info *cmount, const char *from, const char *to);
-
-/* dirs */
-int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode);
-int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode);
-int ceph_rmdir(struct ceph_mount_info *cmount, const char *path);
-
-/* symlinks */
-int ceph_readlink(struct ceph_mount_info *cmount, const char *path, char *buf, loff_t size);
-int ceph_symlink(struct ceph_mount_info *cmount, const char *existing, const char *newname);
-
-/* inode stuff */
-int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf);
-
-int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct stat *attr, int mask);
-int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode);
-int ceph_chown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid);
-int ceph_utime(struct ceph_mount_info *cmount, const char *path, struct utimbuf *buf);
-int ceph_truncate(struct ceph_mount_info *cmount, const char *path, loff_t size);
-
-/* file ops */
-int ceph_mknod(struct ceph_mount_info *cmount, const char *path, mode_t mode, dev_t rdev);
-int ceph_open(struct ceph_mount_info *cmount, const char *path, int flags, mode_t mode);
-int ceph_close(struct ceph_mount_info *cmount, int fd);
-loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, loff_t offset, int whence);
-int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, loff_t size, loff_t offset);
-int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, loff_t size,
-              loff_t offset);
-int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size);
-int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly);
-int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf);
-
-int ceph_sync_fs(struct ceph_mount_info *cmount);
-
-/* xattr support */
-int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
-       void *value, size_t size);
-int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
-       void *value, size_t size);
-int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size);
-int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size);
-int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name);
-int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name);
-int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
-       const void *value, size_t size, int flags);
-int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
-       const void *value, size_t size, int flags);
-
-
-
-/* expose file layout */
-int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh);
-int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh);
-int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh);
-int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd,
-                                loff_t offset, char *buf, int buflen);
-
-/* set default layout for new files */
-int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount, int stripe);
-int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount, int count);
-int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size);
-int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd);
-int ceph_set_default_file_replication(struct ceph_mount_info *cmount, int replication);
-
-/* read from local replicas when possible */
-int ceph_localize_reads(struct ceph_mount_info *cmount, int val);
-
-/* return osd on local node, if any */
-int ceph_get_local_osd(struct ceph_mount_info *cmount);
-
-/* Get the CephContext of this mount */
-struct CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h
new file mode 100644 (file)
index 0000000..f8dbe79
--- /dev/null
@@ -0,0 +1,169 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2009-2011 New Dream Network
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#ifndef CEPH_LIB_H
+#define CEPH_LIB_H
+
+#include <utime.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __USE_FILE_OFFSET64
+# error libceph: must define __USE_FILE_OFFSET64 or readdir results will be corrupted
+#endif
+
+struct ceph_mount_info;
+struct ceph_dir_result;
+struct CephContext;
+
+const char *ceph_version(int *major, int *minor, int *patch);
+
+/* initialization */
+int ceph_create(struct ceph_mount_info **cmount, const char * const id);
+
+/* initialization with an existing configuration */
+int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext *conf);
+
+/* Activate the mount */
+int ceph_mount(struct ceph_mount_info *cmount, const char *root);
+
+/* Destroy the ceph mount instance */
+void ceph_shutdown(struct ceph_mount_info *cmount);
+
+/* Config
+ *
+ * Functions for manipulating the Ceph configuration at runtime.
+ */
+int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path_list);
+
+int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, const char **argv);
+
+/* Sets a configuration value from a string.
+ * Returns 0 on success, error code otherwise. */
+int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, const char *value);
+
+/* Returns a configuration value as a string.
+ * If len is positive, that is the maximum number of bytes we'll write into the
+ * buffer. If len == -1, we'll call malloc() and set *buf.
+ * Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the
+ * buffer is too short. */
+int ceph_conf_get(struct ceph_mount_info *cmount, const char *option, char *buf, size_t len);
+
+int ceph_statfs(struct ceph_mount_info *cmount, const char *path, struct statvfs *stbuf);
+
+/* Get the current working directory.
+ *
+ * The pointer you get back from this function will continue to be valid until
+ * the *next* call you make to ceph_getcwd, at which point it will be invalidated.
+ */
+const char* ceph_getcwd(struct ceph_mount_info *cmount);
+
+int ceph_chdir(struct ceph_mount_info *cmount, const char *s);
+
+int ceph_opendir(struct ceph_mount_info *cmount, const char *name, struct ceph_dir_result **dirpp);
+int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
+struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
+int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de);
+int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de,
+                      struct stat *st, int *stmask);
+int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen);
+int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen);
+void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
+loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp);
+void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset);
+
+int ceph_link(struct ceph_mount_info *cmount, const char *existing, const char *newname);
+int ceph_unlink(struct ceph_mount_info *cmount, const char *path);
+int ceph_rename(struct ceph_mount_info *cmount, const char *from, const char *to);
+
+/* dirs */
+int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode);
+int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode);
+int ceph_rmdir(struct ceph_mount_info *cmount, const char *path);
+
+/* symlinks */
+int ceph_readlink(struct ceph_mount_info *cmount, const char *path, char *buf, loff_t size);
+int ceph_symlink(struct ceph_mount_info *cmount, const char *existing, const char *newname);
+
+/* inode stuff */
+int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf);
+
+int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct stat *attr, int mask);
+int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode);
+int ceph_chown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid);
+int ceph_utime(struct ceph_mount_info *cmount, const char *path, struct utimbuf *buf);
+int ceph_truncate(struct ceph_mount_info *cmount, const char *path, loff_t size);
+
+/* file ops */
+int ceph_mknod(struct ceph_mount_info *cmount, const char *path, mode_t mode, dev_t rdev);
+int ceph_open(struct ceph_mount_info *cmount, const char *path, int flags, mode_t mode);
+int ceph_close(struct ceph_mount_info *cmount, int fd);
+loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, loff_t offset, int whence);
+int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, loff_t size, loff_t offset);
+int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, loff_t size,
+              loff_t offset);
+int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size);
+int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly);
+int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf);
+
+int ceph_sync_fs(struct ceph_mount_info *cmount);
+
+/* xattr support */
+int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       void *value, size_t size);
+int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       void *value, size_t size);
+int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size);
+int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size);
+int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name);
+int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name);
+int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       const void *value, size_t size, int flags);
+int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       const void *value, size_t size, int flags);
+
+
+
+/* expose file layout */
+int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh);
+int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh);
+int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh);
+int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd,
+                                loff_t offset, char *buf, int buflen);
+
+/* set default layout for new files */
+int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount, int stripe);
+int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount, int count);
+int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size);
+int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd);
+int ceph_set_default_file_replication(struct ceph_mount_info *cmount, int replication);
+
+/* read from local replicas when possible */
+int ceph_localize_reads(struct ceph_mount_info *cmount, int val);
+
+/* return osd on local node, if any */
+int ceph_get_local_osd(struct ceph_mount_info *cmount);
+
+/* Get the CephContext of this mount */
+struct CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/libceph.cc b/src/libceph.cc
deleted file mode 100644 (file)
index 54f07ed..0000000
+++ /dev/null
@@ -1,616 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2009-2011 New Dream Network
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation.  See file COPYING.
- *
- */
-
-#include "client/Client.h"
-#include "include/ceph/libceph.h"
-#include "common/Mutex.h"
-#include "common/ceph_argparse.h"
-#include "common/common_init.h"
-#include "common/config.h"
-#include "common/version.h"
-#include "mon/MonClient.h"
-#include "include/str_list.h"
-#include "messages/MMonMap.h"
-#include "msg/SimpleMessenger.h"
-
-#include <fcntl.h>
-#include <iostream>
-#include <string.h>
-#include <string>
-
-class ceph_mount_info
-{
-public:
-  ceph_mount_info(uint64_t msgr_nonce_, CephContext *cct_)
-    : msgr_nonce(msgr_nonce_),
-      mounted(false),
-      client(NULL),
-      monclient(NULL),
-      messenger(NULL),
-      cct(cct_)
-  {
-  }
-
-  ~ceph_mount_info()
-  {
-    try {
-      shutdown();
-      if (cct) {
-       common_destroy_context(cct);
-       cct = NULL;
-      }
-    }
-    catch (const std::exception& e) {
-      // we shouldn't get here, but if we do, we want to know about it.
-      lderr(cct) << "ceph_mount_info::~ceph_mount_info: caught exception: "
-                << e.what() << dendl;
-    }
-    catch (...) {
-      // ignore
-    }
-  }
-
-  int mount(const std::string &mount_root)
-  {
-    if (mounted)
-      return -EDOM;
-
-    common_init_finish(cct);
-
-    //monmap
-    monclient = new MonClient(cct);
-    if (monclient->build_initial_monmap() < 0) {
-      shutdown();
-      return -1000;
-    }
-
-    //network connection
-    messenger = new SimpleMessenger(cct);
-    if (!messenger->register_entity(entity_name_t::CLIENT())) {
-      messenger->destroy();
-      messenger = NULL;
-      shutdown();
-      return -1001;
-    }
-
-    //at last the client
-    client = new Client(messenger, monclient);
-    if (!client) {
-      shutdown();
-      return -1002;
-    }
-
-    if (messenger->start_with_nonce(msgr_nonce) != 0) {
-      shutdown();
-      return -1003;
-    }
-
-    client->init();
-
-    int ret = client->mount(mount_root);
-    if (ret) {
-      shutdown();
-      return ret;
-    }
-
-    mounted = true;
-    return 0;
-  }
-
-  void shutdown()
-  {
-    if (mounted) {
-      client->unmount();
-      mounted = false;
-    }
-    if (client) {
-      client->shutdown();
-      delete client;
-      client = NULL;
-    }
-    if (messenger) {
-      messenger->wait();
-      messenger->destroy();
-      messenger = NULL;
-    }
-    if (monclient) {
-      delete monclient;
-      monclient = NULL;
-    }
-  }
-
-  int conf_read_file(const char *path_list)
-  {
-    std::deque<std::string> parse_errors;
-    int ret = cct->_conf->parse_config_files(path_list, &parse_errors, 0);
-    if (ret)
-      return ret;
-    cct->_conf->apply_changes(NULL);
-    complain_about_parse_errors(cct, &parse_errors);
-    return 0;
-  }
-
-  int conf_parse_argv(int argc, const char **argv)
-  {
-    int ret;
-    vector<const char*> args;
-    argv_to_vec(argc, argv, args);
-    ret = cct->_conf->parse_argv(args);
-    if (ret)
-       return ret;
-    cct->_conf->apply_changes(NULL);
-    return 0;
-  }
-
-  int conf_set(const char *option, const char *value)
-  {
-    int ret = cct->_conf->set_val(option, value);
-    if (ret)
-      return ret;
-    cct->_conf->apply_changes(NULL);
-    return 0;
-  }
-
-  int conf_get(const char *option, char *buf, size_t len)
-  {
-    char *tmp = buf;
-    return cct->_conf->get_val(option, &tmp, len);
-  }
-
-  Client *get_client()
-  {
-    return client;
-  }
-
-  const char *get_cwd()
-  {
-    client->getcwd(cwd);
-    return cwd.c_str();
-  }
-
-  CephContext *get_ceph_context() const {
-    return cct;
-  }
-
-private:
-  uint64_t msgr_nonce;
-  bool mounted;
-  Client *client;
-  MonClient *monclient;
-  SimpleMessenger *messenger;
-  CephContext *cct;
-  std::string cwd;
-};
-
-extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
-{
-  int major, minor, patch;
-  const char *v = ceph_version_to_str();
-
-  int n = sscanf(v, "%d.%d.%d", &major, &minor, &patch);
-  if (pmajor)
-    *pmajor = (n >= 1) ? major : 0;
-  if (pminor)
-    *pminor = (n >= 2) ? minor : 0;
-  if (ppatch)
-    *ppatch = (n >= 3) ? patch : 0;
-  return VERSION;
-}
-
-extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephContext *cct)
-{
-  // Function-static variables are thread-safe in gcc and in the forthcoming C++ standard
-  static int nonce_seed = 0;
-
-  uint64_t nonce = (uint64_t)++nonce_seed * 1000000ull + (uint64_t)getpid();
-  *cmount = new struct ceph_mount_info(nonce, cct);
-  return 0;
-}
-
-extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const id)
-{
-  CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);
-  if (id) {
-    iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
-  }
-
-  CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
-  cct->_conf->parse_env(); // environment variables coverride
-  cct->_conf->apply_changes(NULL);
-  return ceph_create_with_context(cmount, cct);
-}
-
-extern "C" void ceph_shutdown(struct ceph_mount_info *cmount)
-{
-  cmount->shutdown();
-}
-
-extern "C" int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path)
-{
-  return cmount->conf_read_file(path);
-}
-
-extern "C" int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc,
-                                    const char **argv)
-{
-  return cmount->conf_parse_argv(argc, argv);
-}
-
-extern "C" int ceph_conf_set(struct ceph_mount_info *cmount, const char *option,
-                            const char *value)
-{
-  return cmount->conf_set(option, value);
-}
-
-extern "C" int ceph_conf_get(struct ceph_mount_info *cmount, const char *option,
-                            char *buf, size_t len)
-{
-  return cmount->conf_get(option, buf, len);
-}
-
-extern "C" int ceph_mount(struct ceph_mount_info *cmount, const char *root)
-{
-  std::string mount_root;
-  if (root)
-    mount_root = root;
-  return cmount->mount(mount_root);
-}
-
-extern "C" int ceph_statfs(struct ceph_mount_info *cmount, const char *path,
-                          struct statvfs *stbuf)
-{
-  return cmount->get_client()->statfs(path, stbuf);
-}
-
-extern "C" int ceph_get_local_osd(struct ceph_mount_info *cmount)
-{
-  return cmount->get_client()->get_local_osd();
-}
-
-extern "C" const char* ceph_getcwd(struct ceph_mount_info *cmount)
-{
-  return cmount->get_cwd();
-}
-
-extern "C" int ceph_chdir (struct ceph_mount_info *cmount, const char *s)
-{
-  return cmount->get_client()->chdir(s);
-}
-
-extern "C" int ceph_opendir(struct ceph_mount_info *cmount,
-                           const char *name, struct ceph_dir_result **dirpp)
-{
-  return cmount->get_client()->opendir(name, (dir_result_t **)dirpp);
-}
-
-extern "C" int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
-{
-  return cmount->get_client()->closedir((dir_result_t*)dirp);
-}
-
-extern "C" struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
-{
-  return cmount->get_client()->readdir((dir_result_t*)dirp);
-}
-
-extern "C" int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de)
-{
-  return cmount->get_client()->readdir_r((dir_result_t*)dirp, de);
-}
-
-extern "C" int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp,
-                                 struct dirent *de, struct stat *st, int *stmask)
-{
-  return cmount->get_client()->readdirplus_r((dir_result_t*)dirp, de, st, stmask);
-}
-
-extern "C" int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp,
-                            char *buf, int buflen)
-{
-  return cmount->get_client()->getdents((dir_result_t*)dirp, buf, buflen);
-}
-
-extern "C" int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp,
-                             char *buf, int buflen)
-{
-  return cmount->get_client()->getdnames((dir_result_t*)dirp, buf, buflen);
-}
-
-extern "C" void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
-{
-  cmount->get_client()->rewinddir((dir_result_t*)dirp);
-}
-
-extern "C" loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
-{
-  return cmount->get_client()->telldir((dir_result_t*)dirp);
-}
-
-extern "C" void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset)
-{
-  cmount->get_client()->seekdir((dir_result_t*)dirp, offset);
-}
-
-extern "C" int ceph_link (struct ceph_mount_info *cmount, const char *existing,
-                         const char *newname)
-{
-  return cmount->get_client()->link(existing, newname);
-}
-
-extern "C" int ceph_unlink(struct ceph_mount_info *cmount, const char *path)
-{
-  return cmount->get_client()->unlink(path);
-}
-
-extern "C" int ceph_rename(struct ceph_mount_info *cmount, const char *from,
-                          const char *to)
-{
-  return cmount->get_client()->rename(from, to);
-}
-
-// dirs
-extern "C" int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode)
-{
-  return cmount->get_client()->mkdir(path, mode);
-}
-
-extern "C" int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode)
-{
-  return cmount->get_client()->mkdirs(path, mode);
-}
-
-extern "C" int ceph_rmdir(struct ceph_mount_info *cmount, const char *path)
-{
-  return cmount->get_client()->rmdir(path);
-}
-
-// symlinks
-extern "C" int ceph_readlink(struct ceph_mount_info *cmount, const char *path,
-                            char *buf, loff_t size)
-{
-  return cmount->get_client()->readlink(path, buf, size);
-}
-
-extern "C" int ceph_symlink(struct ceph_mount_info *cmount, const char *existing,
-                           const char *newname)
-{
-  return cmount->get_client()->symlink(existing, newname);
-}
-
-// inode stuff
-extern "C" int ceph_lstat(struct ceph_mount_info *cmount, const char *path,
-                         struct stat *stbuf)
-{
-  return cmount->get_client()->lstat(path, stbuf);
-}
-
-extern "C" int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath,
-                           struct stat *attr, int mask)
-{
-  return cmount->get_client()->setattr(relpath, attr, mask);
-}
-
-// *xattr() calls supporting samba/vfs
-extern "C" int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size)
-{
-  return cmount->get_client()->getxattr(path, name, value, size);
-}
-
-extern "C" int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size)
-{
-  return cmount->get_client()->lgetxattr(path, name, value, size);
-}
-
-extern "C" int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size)
-{
-  return cmount->get_client()->listxattr(path, list, size);
-}
-
-extern "C" int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size)
-{
-  return cmount->get_client()->llistxattr(path, list, size);
-}
-
-extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name)
-{
-  return cmount->get_client()->removexattr(path, name);
-}
-
-extern "C" int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name)
-{
-  return cmount->get_client()->lremovexattr(path, name);
-}
-
-extern "C" int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags)
-{
-  return cmount->get_client()->setxattr(path, name, value, size, flags);
-}
-
-extern "C" int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags)
-{
-  return cmount->get_client()->lsetxattr(path, name, value, size, flags);
-}
-/* end xattr support */
-
-extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode)
-{
-  return cmount->get_client()->chmod(path, mode);
-}
-extern "C" int ceph_chown(struct ceph_mount_info *cmount, const char *path,
-                         uid_t uid, gid_t gid)
-{
-  return cmount->get_client()->chown(path, uid, gid);
-}
-
-extern "C" int ceph_utime(struct ceph_mount_info *cmount, const char *path,
-                         struct utimbuf *buf)
-{
-  return cmount->get_client()->utime(path, buf);
-}
-
-extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path,
-                            loff_t size)
-{
-  return cmount->get_client()->truncate(path, size);
-}
-
-// file ops
-extern "C" int ceph_mknod(struct ceph_mount_info *cmount, const char *path,
-                         mode_t mode, dev_t rdev)
-{
-  return cmount->get_client()->mknod(path, mode, rdev);
-}
-
-extern "C" int ceph_open(struct ceph_mount_info *cmount, const char *path,
-                        int flags, mode_t mode)
-{
-  return cmount->get_client()->open(path, flags, mode);
-}
-
-extern "C" int ceph_close(struct ceph_mount_info *cmount, int fd)
-{
-  return cmount->get_client()->close(fd);
-}
-
-extern "C" loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd,
-                            loff_t offset, int whence)
-{
-  return cmount->get_client()->lseek(fd, offset, whence);
-}
-
-extern "C" int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf,
-                        loff_t size, loff_t offset)
-{
-  return cmount->get_client()->read(fd, buf, size, offset);
-}
-
-extern "C" int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf,
-                         loff_t size, loff_t offset)
-{
-  return cmount->get_client()->write(fd, buf, size, offset);
-}
-
-extern "C" int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size)
-{
-  return cmount->get_client()->ftruncate(fd, size);
-}
-
-extern "C" int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly)
-{
-  return cmount->get_client()->fsync(fd, syncdataonly);
-}
-
-extern "C" int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf)
-{
-  return cmount->get_client()->fstat(fd, stbuf);
-}
-
-extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount)
-{
-  return cmount->get_client()->sync_fs();
-}
-
-
-extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh)
-{
-  struct ceph_file_layout l;
-  int r = cmount->get_client()->describe_layout(fh, &l);
-  if (r < 0)
-    return r;
-  return l.fl_stripe_unit;
-}
-
-extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh)
-{
-  struct ceph_file_layout l;
-  int r = cmount->get_client()->describe_layout(fh, &l);
-  if (r < 0)
-    return r;
-  return l.fl_pg_pool;
-}
-
-extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh)
-{
-  struct ceph_file_layout l;
-  int r = cmount->get_client()->describe_layout(fh, &l);
-  if (r < 0)
-    return r;
-  int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool);
-  return rep;
-}
-
-extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount,
-                                                int stripe)
-{
-  cmount->get_client()->set_default_file_stripe_unit(stripe);
-  return 0;
-}
-
-extern "C" int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount,
-                                                 int count)
-{
-  cmount->get_client()->set_default_file_stripe_unit(count);
-  return 0;
-}
-
-extern "C" int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size)
-{
-  cmount->get_client()->set_default_object_size(size);
-  return 0;
-}
-
-extern "C" int ceph_set_default_file_replication(struct ceph_mount_info *cmount,
-                                                int replication)
-{
-  cmount->get_client()->set_default_file_replication(replication);
-  return 0;
-}
-
-extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd)
-{
-  cmount->get_client()->set_default_preferred_pg(osd);
-  return 0;
-}
-
-extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fh,
-                                           loff_t offset, char *buf, int buflen)
-{
-  string address;
-  int r = cmount->get_client()->get_file_stripe_address(fh, offset, address);
-  if (r < 0)
-    return r; 
-  int len = address.size()+1;
-  if (len > buflen) {
-    if (buflen == 0)
-      return len;
-    return -ERANGE;
-  }
-  len = address.copy(buf, len, 0);
-  buf[len] = '\0'; // write a null char to terminate c-style string
-  return 0;
-}
-
-extern "C" int ceph_localize_reads(struct ceph_mount_info *cmount, int val)
-{
-  if (!val)
-    cmount->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
-  else
-    cmount->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
-  return 0;
-}
-
-extern "C" CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount)
-{
-  return cmount->get_ceph_context();
-}
diff --git a/src/libcephfs.cc b/src/libcephfs.cc
new file mode 100644 (file)
index 0000000..153348c
--- /dev/null
@@ -0,0 +1,616 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2009-2011 New Dream Network
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include "client/Client.h"
+#include "include/cephfs/libcephfs.h"
+#include "common/Mutex.h"
+#include "common/ceph_argparse.h"
+#include "common/common_init.h"
+#include "common/config.h"
+#include "common/version.h"
+#include "mon/MonClient.h"
+#include "include/str_list.h"
+#include "messages/MMonMap.h"
+#include "msg/SimpleMessenger.h"
+
+#include <fcntl.h>
+#include <iostream>
+#include <string.h>
+#include <string>
+
+class ceph_mount_info
+{
+public:
+  ceph_mount_info(uint64_t msgr_nonce_, CephContext *cct_)
+    : msgr_nonce(msgr_nonce_),
+      mounted(false),
+      client(NULL),
+      monclient(NULL),
+      messenger(NULL),
+      cct(cct_)
+  {
+  }
+
+  ~ceph_mount_info()
+  {
+    try {
+      shutdown();
+      if (cct) {
+       common_destroy_context(cct);
+       cct = NULL;
+      }
+    }
+    catch (const std::exception& e) {
+      // we shouldn't get here, but if we do, we want to know about it.
+      lderr(cct) << "ceph_mount_info::~ceph_mount_info: caught exception: "
+                << e.what() << dendl;
+    }
+    catch (...) {
+      // ignore
+    }
+  }
+
+  int mount(const std::string &mount_root)
+  {
+    if (mounted)
+      return -EDOM;
+
+    common_init_finish(cct);
+
+    //monmap
+    monclient = new MonClient(cct);
+    if (monclient->build_initial_monmap() < 0) {
+      shutdown();
+      return -1000;
+    }
+
+    //network connection
+    messenger = new SimpleMessenger(cct);
+    if (!messenger->register_entity(entity_name_t::CLIENT())) {
+      messenger->destroy();
+      messenger = NULL;
+      shutdown();
+      return -1001;
+    }
+
+    //at last the client
+    client = new Client(messenger, monclient);
+    if (!client) {
+      shutdown();
+      return -1002;
+    }
+
+    if (messenger->start_with_nonce(msgr_nonce) != 0) {
+      shutdown();
+      return -1003;
+    }
+
+    client->init();
+
+    int ret = client->mount(mount_root);
+    if (ret) {
+      shutdown();
+      return ret;
+    }
+
+    mounted = true;
+    return 0;
+  }
+
+  void shutdown()
+  {
+    if (mounted) {
+      client->unmount();
+      mounted = false;
+    }
+    if (client) {
+      client->shutdown();
+      delete client;
+      client = NULL;
+    }
+    if (messenger) {
+      messenger->wait();
+      messenger->destroy();
+      messenger = NULL;
+    }
+    if (monclient) {
+      delete monclient;
+      monclient = NULL;
+    }
+  }
+
+  int conf_read_file(const char *path_list)
+  {
+    std::deque<std::string> parse_errors;
+    int ret = cct->_conf->parse_config_files(path_list, &parse_errors, 0);
+    if (ret)
+      return ret;
+    cct->_conf->apply_changes(NULL);
+    complain_about_parse_errors(cct, &parse_errors);
+    return 0;
+  }
+
+  int conf_parse_argv(int argc, const char **argv)
+  {
+    int ret;
+    vector<const char*> args;
+    argv_to_vec(argc, argv, args);
+    ret = cct->_conf->parse_argv(args);
+    if (ret)
+       return ret;
+    cct->_conf->apply_changes(NULL);
+    return 0;
+  }
+
+  int conf_set(const char *option, const char *value)
+  {
+    int ret = cct->_conf->set_val(option, value);
+    if (ret)
+      return ret;
+    cct->_conf->apply_changes(NULL);
+    return 0;
+  }
+
+  int conf_get(const char *option, char *buf, size_t len)
+  {
+    char *tmp = buf;
+    return cct->_conf->get_val(option, &tmp, len);
+  }
+
+  Client *get_client()
+  {
+    return client;
+  }
+
+  const char *get_cwd()
+  {
+    client->getcwd(cwd);
+    return cwd.c_str();
+  }
+
+  CephContext *get_ceph_context() const {
+    return cct;
+  }
+
+private:
+  uint64_t msgr_nonce;
+  bool mounted;
+  Client *client;
+  MonClient *monclient;
+  SimpleMessenger *messenger;
+  CephContext *cct;
+  std::string cwd;
+};
+
+extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
+{
+  int major, minor, patch;
+  const char *v = ceph_version_to_str();
+
+  int n = sscanf(v, "%d.%d.%d", &major, &minor, &patch);
+  if (pmajor)
+    *pmajor = (n >= 1) ? major : 0;
+  if (pminor)
+    *pminor = (n >= 2) ? minor : 0;
+  if (ppatch)
+    *ppatch = (n >= 3) ? patch : 0;
+  return VERSION;
+}
+
+extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephContext *cct)
+{
+  // Function-static variables are thread-safe in gcc and in the forthcoming C++ standard
+  static int nonce_seed = 0;
+
+  uint64_t nonce = (uint64_t)++nonce_seed * 1000000ull + (uint64_t)getpid();
+  *cmount = new struct ceph_mount_info(nonce, cct);
+  return 0;
+}
+
+extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const id)
+{
+  CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);
+  if (id) {
+    iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
+  }
+
+  CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
+  cct->_conf->parse_env(); // environment variables coverride
+  cct->_conf->apply_changes(NULL);
+  return ceph_create_with_context(cmount, cct);
+}
+
+extern "C" void ceph_shutdown(struct ceph_mount_info *cmount)
+{
+  cmount->shutdown();
+}
+
+extern "C" int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path)
+{
+  return cmount->conf_read_file(path);
+}
+
+extern "C" int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc,
+                                    const char **argv)
+{
+  return cmount->conf_parse_argv(argc, argv);
+}
+
+extern "C" int ceph_conf_set(struct ceph_mount_info *cmount, const char *option,
+                            const char *value)
+{
+  return cmount->conf_set(option, value);
+}
+
+extern "C" int ceph_conf_get(struct ceph_mount_info *cmount, const char *option,
+                            char *buf, size_t len)
+{
+  return cmount->conf_get(option, buf, len);
+}
+
+extern "C" int ceph_mount(struct ceph_mount_info *cmount, const char *root)
+{
+  std::string mount_root;
+  if (root)
+    mount_root = root;
+  return cmount->mount(mount_root);
+}
+
+extern "C" int ceph_statfs(struct ceph_mount_info *cmount, const char *path,
+                          struct statvfs *stbuf)
+{
+  return cmount->get_client()->statfs(path, stbuf);
+}
+
+extern "C" int ceph_get_local_osd(struct ceph_mount_info *cmount)
+{
+  return cmount->get_client()->get_local_osd();
+}
+
+extern "C" const char* ceph_getcwd(struct ceph_mount_info *cmount)
+{
+  return cmount->get_cwd();
+}
+
+extern "C" int ceph_chdir (struct ceph_mount_info *cmount, const char *s)
+{
+  return cmount->get_client()->chdir(s);
+}
+
+extern "C" int ceph_opendir(struct ceph_mount_info *cmount,
+                           const char *name, struct ceph_dir_result **dirpp)
+{
+  return cmount->get_client()->opendir(name, (dir_result_t **)dirpp);
+}
+
+extern "C" int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
+{
+  return cmount->get_client()->closedir((dir_result_t*)dirp);
+}
+
+extern "C" struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
+{
+  return cmount->get_client()->readdir((dir_result_t*)dirp);
+}
+
+extern "C" int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de)
+{
+  return cmount->get_client()->readdir_r((dir_result_t*)dirp, de);
+}
+
+extern "C" int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp,
+                                 struct dirent *de, struct stat *st, int *stmask)
+{
+  return cmount->get_client()->readdirplus_r((dir_result_t*)dirp, de, st, stmask);
+}
+
+extern "C" int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp,
+                            char *buf, int buflen)
+{
+  return cmount->get_client()->getdents((dir_result_t*)dirp, buf, buflen);
+}
+
+extern "C" int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp,
+                             char *buf, int buflen)
+{
+  return cmount->get_client()->getdnames((dir_result_t*)dirp, buf, buflen);
+}
+
+extern "C" void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
+{
+  cmount->get_client()->rewinddir((dir_result_t*)dirp);
+}
+
+extern "C" loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp)
+{
+  return cmount->get_client()->telldir((dir_result_t*)dirp);
+}
+
+extern "C" void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset)
+{
+  cmount->get_client()->seekdir((dir_result_t*)dirp, offset);
+}
+
+extern "C" int ceph_link (struct ceph_mount_info *cmount, const char *existing,
+                         const char *newname)
+{
+  return cmount->get_client()->link(existing, newname);
+}
+
+extern "C" int ceph_unlink(struct ceph_mount_info *cmount, const char *path)
+{
+  return cmount->get_client()->unlink(path);
+}
+
+extern "C" int ceph_rename(struct ceph_mount_info *cmount, const char *from,
+                          const char *to)
+{
+  return cmount->get_client()->rename(from, to);
+}
+
+// dirs
+extern "C" int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode)
+{
+  return cmount->get_client()->mkdir(path, mode);
+}
+
+extern "C" int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode)
+{
+  return cmount->get_client()->mkdirs(path, mode);
+}
+
+extern "C" int ceph_rmdir(struct ceph_mount_info *cmount, const char *path)
+{
+  return cmount->get_client()->rmdir(path);
+}
+
+// symlinks
+extern "C" int ceph_readlink(struct ceph_mount_info *cmount, const char *path,
+                            char *buf, loff_t size)
+{
+  return cmount->get_client()->readlink(path, buf, size);
+}
+
+extern "C" int ceph_symlink(struct ceph_mount_info *cmount, const char *existing,
+                           const char *newname)
+{
+  return cmount->get_client()->symlink(existing, newname);
+}
+
+// inode stuff
+extern "C" int ceph_lstat(struct ceph_mount_info *cmount, const char *path,
+                         struct stat *stbuf)
+{
+  return cmount->get_client()->lstat(path, stbuf);
+}
+
+extern "C" int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath,
+                           struct stat *attr, int mask)
+{
+  return cmount->get_client()->setattr(relpath, attr, mask);
+}
+
+// *xattr() calls supporting samba/vfs
+extern "C" int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size)
+{
+  return cmount->get_client()->getxattr(path, name, value, size);
+}
+
+extern "C" int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size)
+{
+  return cmount->get_client()->lgetxattr(path, name, value, size);
+}
+
+extern "C" int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size)
+{
+  return cmount->get_client()->listxattr(path, list, size);
+}
+
+extern "C" int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size)
+{
+  return cmount->get_client()->llistxattr(path, list, size);
+}
+
+extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name)
+{
+  return cmount->get_client()->removexattr(path, name);
+}
+
+extern "C" int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name)
+{
+  return cmount->get_client()->lremovexattr(path, name);
+}
+
+extern "C" int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags)
+{
+  return cmount->get_client()->setxattr(path, name, value, size, flags);
+}
+
+extern "C" int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags)
+{
+  return cmount->get_client()->lsetxattr(path, name, value, size, flags);
+}
+/* end xattr support */
+
+extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode)
+{
+  return cmount->get_client()->chmod(path, mode);
+}
+extern "C" int ceph_chown(struct ceph_mount_info *cmount, const char *path,
+                         uid_t uid, gid_t gid)
+{
+  return cmount->get_client()->chown(path, uid, gid);
+}
+
+extern "C" int ceph_utime(struct ceph_mount_info *cmount, const char *path,
+                         struct utimbuf *buf)
+{
+  return cmount->get_client()->utime(path, buf);
+}
+
+extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path,
+                            loff_t size)
+{
+  return cmount->get_client()->truncate(path, size);
+}
+
+// file ops
+extern "C" int ceph_mknod(struct ceph_mount_info *cmount, const char *path,
+                         mode_t mode, dev_t rdev)
+{
+  return cmount->get_client()->mknod(path, mode, rdev);
+}
+
+extern "C" int ceph_open(struct ceph_mount_info *cmount, const char *path,
+                        int flags, mode_t mode)
+{
+  return cmount->get_client()->open(path, flags, mode);
+}
+
+extern "C" int ceph_close(struct ceph_mount_info *cmount, int fd)
+{
+  return cmount->get_client()->close(fd);
+}
+
+extern "C" loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd,
+                            loff_t offset, int whence)
+{
+  return cmount->get_client()->lseek(fd, offset, whence);
+}
+
+extern "C" int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf,
+                        loff_t size, loff_t offset)
+{
+  return cmount->get_client()->read(fd, buf, size, offset);
+}
+
+extern "C" int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf,
+                         loff_t size, loff_t offset)
+{
+  return cmount->get_client()->write(fd, buf, size, offset);
+}
+
+extern "C" int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size)
+{
+  return cmount->get_client()->ftruncate(fd, size);
+}
+
+extern "C" int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly)
+{
+  return cmount->get_client()->fsync(fd, syncdataonly);
+}
+
+extern "C" int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf)
+{
+  return cmount->get_client()->fstat(fd, stbuf);
+}
+
+extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount)
+{
+  return cmount->get_client()->sync_fs();
+}
+
+
+extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh)
+{
+  struct ceph_file_layout l;
+  int r = cmount->get_client()->describe_layout(fh, &l);
+  if (r < 0)
+    return r;
+  return l.fl_stripe_unit;
+}
+
+extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh)
+{
+  struct ceph_file_layout l;
+  int r = cmount->get_client()->describe_layout(fh, &l);
+  if (r < 0)
+    return r;
+  return l.fl_pg_pool;
+}
+
+extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh)
+{
+  struct ceph_file_layout l;
+  int r = cmount->get_client()->describe_layout(fh, &l);
+  if (r < 0)
+    return r;
+  int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool);
+  return rep;
+}
+
+extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount,
+                                                int stripe)
+{
+  cmount->get_client()->set_default_file_stripe_unit(stripe);
+  return 0;
+}
+
+extern "C" int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount,
+                                                 int count)
+{
+  cmount->get_client()->set_default_file_stripe_unit(count);
+  return 0;
+}
+
+extern "C" int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size)
+{
+  cmount->get_client()->set_default_object_size(size);
+  return 0;
+}
+
+extern "C" int ceph_set_default_file_replication(struct ceph_mount_info *cmount,
+                                                int replication)
+{
+  cmount->get_client()->set_default_file_replication(replication);
+  return 0;
+}
+
+extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd)
+{
+  cmount->get_client()->set_default_preferred_pg(osd);
+  return 0;
+}
+
+extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fh,
+                                           loff_t offset, char *buf, int buflen)
+{
+  string address;
+  int r = cmount->get_client()->get_file_stripe_address(fh, offset, address);
+  if (r < 0)
+    return r; 
+  int len = address.size()+1;
+  if (len > buflen) {
+    if (buflen == 0)
+      return len;
+    return -ERANGE;
+  }
+  len = address.copy(buf, len, 0);
+  buf[len] = '\0'; // write a null char to terminate c-style string
+  return 0;
+}
+
+extern "C" int ceph_localize_reads(struct ceph_mount_info *cmount, int val)
+{
+  if (!val)
+    cmount->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
+  else
+    cmount->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS);
+  return 0;
+}
+
+extern "C" CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount)
+{
+  return cmount->get_ceph_context();
+}
index 0eae90af3e0aa268ec18d44da985a7b2d8ba622d..6a09e0943910bce72425cebf0adfec673af2ecd1 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "common/ceph_argparse.h"
 #include "common/config.h"
-#include "include/ceph/libceph.h"
+#include "include/cephfs/libcephfs.h"
 #include "include/rados/librados.h"
 #include "test/unit.h"
 
index aac7dabeff632baf27629403f2ef07176729bc0f..c5e184f59c4f0cf4f48764913266042ee771bb3b 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 #include "gtest/gtest.h"
-#include "include/ceph/libceph.h"
+#include "include/cephfs/libcephfs.h"
 
 #include <sstream>
 #include <string>