Re: libceph API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ceph_mount_t is forward declared as a struct in libceph.h.
When referencing that within libceph.h, gcc barfs:
client/libceph.h:32: error: expected ‘)’ before ‘*’ token

Is libceph.h intended to be used in C-programs, and if so, am I using
it incorrectly?
ceph_mount_t is defined as a class in libceph.cc, and I'm unclear on
how that would be translated into a struct for C-programs linking to
libceph.

I suppose I could use a void * and pass it around opaquely?

Here's the C-program I was trying to compile with it (a rough
conversion of testceph.cc)"

//#include "common/errno.h"
#include "libceph.h"

#include <errno.h>
#include <string.h>
#include <iostream>

//using std::cout;
//using std::cerr;

int main(int argc, const char **argv)
{
  ceph_mount_t *cmount;
  int ret = ceph_create(&cmount, NULL);
  if (ret) {
    printf(STDERR, "ceph_create failed with error: %i\n", ret);
    return 1;
  }

  ceph_conf_read_file(cmount, NULL);
  ceph_conf_parse_argv(cmount, argc, argv);

  char buf[128];
  ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf));
  if (ret) {
    printf(STDERR, "ceph_conf_get(\"log file\") failed with error %i\n", ret);
  }
  else {
    printf(STDOUT, "log_file = \"%s\"\n", ret);
  }

  ret = ceph_mount(cmount, NULL);
  if (ret) {
    printf(STDERR, "ceph_mount error: $i\n", ret);
    return 1;
  }
  printf(STDOUT, "Successfully mounted Ceph!\n");

  ceph_dir_result_t *foo_dir;
  ret = ceph_opendir(cmount, "foo", &foo_dir);
  if (ret != -ENOENT) {
    printf(STDERR, "ceph_opendir error: unexpected result from trying
to open foo: %s\n", strerror(ret));
    return 1;
  }

  ret = ceph_mkdir(cmount, "foo",  0777);
  if (ret) {
    printf(STDERR, "ceph_mkdir error: %s\n", strerror(ret));
    return 1;
  }

  struct stat stbuf;
  ret = ceph_lstat(cmount, "foo", &stbuf);
  if (ret) {
    printf(STDERR, "ceph_lstat error: %s\n", strerror(ret));
    return 1;
  }

  if (!S_ISDIR(stbuf.st_mode)) {
    printf(STDERR, "ceph_lstat(foo): foo is not a directory? st_mode =
%x\n", stbuf.st_mode
    return 1;
  }

  ret = ceph_rmdir(cmount, "foo");
  if (ret) {
    printf(STDERR, "ceph_rmdir error: %s\n", strerror(ret));
    return 1;
  }

  ret = ceph_mkdirs(cmount, "foo/bar/baz",  0777);
  if (ret) {
    printf(STDERR, "ceph_mkdirs error: %s\n", strerror(ret));
    return 1;
  }
  ret = ceph_rmdir(cmount, "foo/bar/baz");
  if (ret) {
    printf(STDERR, "ceph_rmdir error: %s\n", strerror(ret));
    return 1;
  }
  ret = ceph_rmdir(cmount, "foo/bar");
  if (ret) {
    printf(STDERR, "ceph_rmdir error: %s\n", strerror(ret));
    return 1;
  }
  ret = ceph_rmdir(cmount, "foo");
  if (ret) {
    printf(STDERR, "ceph_rmdir error: %s\n", strerror(ret));
    return 1;
  }

  ceph_shutdown(cmount);

  return 0;
}


On Thu, Apr 21, 2011 at 12:32 PM, Colin McCabe <cmccabe@xxxxxxxxxxxxxx> wrote:
> Hi all,
>
> I pushed the DIR* change and the connect->mount change.
> Check it out.
>
> I'm going to try to get the hadoop bindings up and running in libceph_api.
>
> sincerely,
> C.
>
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux