%{_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.*
%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
/*.debhelper
/ceph
/files
-/libceph1-dbg
-/libceph-dev
-/libceph1
+/libcephfs1-dbg
+/libcephfs-dev
+/libcephfs1
/librados2-dbg
/librados-dev
/librados2
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.
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}
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
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
-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
-usr/lib/libceph.so.*
+usr/lib/libcephfs.so.*
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
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).
- 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
.. 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
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)
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
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_.*'
-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
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
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
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
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}
$(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 = \
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\
// -*- 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"
+ 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();
+ * 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.
+<property>
+ <name>fs.ceph.libDir</name>
+ <value>/usr/local/lib</value>
-+ <description>The folder holding libceph and libhadoopceph</description>
++ <description>The folder holding libcephfs and libhadoopceph</description>
+ </property>
+</pre>
+ <li>There are also a number of optional Ceph configuration options.
* 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.
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;
}
<property>
<name>fs.ceph.libDir</name>
<value>/usr/local/lib</value>
- <description>The folder holding libceph and libhadoopceph</description>
+ <description>The folder holding libcephfs and libhadoopceph</description>
</property>
</pre>
<li>There are also a number of optional Ceph configuration options.
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>
#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>
*/
#include "common/errno.h"
-#include "include/ceph/libceph.h"
+#include "include/cephfs/libcephfs.h"
#include <stdlib.h>
#include <errno.h>
/** 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,
+++ /dev/null
-// -*- 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
--- /dev/null
+// -*- 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
+++ /dev/null
-// -*- 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();
-}
--- /dev/null
+// -*- 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();
+}
#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"
*/
#include "gtest/gtest.h"
-#include "include/ceph/libceph.h"
+#include "include/cephfs/libcephfs.h"
#include <sstream>
#include <string>