mirror of
https://github.com/ceph/ceph
synced 2025-02-22 10:37:15 +00:00
build under darwin
This commit is contained in:
parent
138d8bda1f
commit
a74202b88b
@ -2334,7 +2334,9 @@ void Client::_readdir_fill_dirent(struct dirent *de, DirEntry *entry, off_t off)
|
||||
strncpy(de->d_name, entry->d_name.c_str(), 256);
|
||||
#ifndef __CYGWIN__
|
||||
de->d_ino = entry->st.st_ino;
|
||||
#ifndef DARWIN
|
||||
de->d_off = off + 1;
|
||||
#endif
|
||||
de->d_reclen = 1;
|
||||
de->d_type = MODE_TO_DT(entry->st.st_mode);
|
||||
dout(10) << "_readdir_fill_dirent '" << de->d_name << "' -> " << de->d_ino
|
||||
|
@ -398,8 +398,13 @@ void FileJournal::do_write(bufferlist& bl)
|
||||
::pwrite(fd, hbp.c_str(), hbp.length(), 0);
|
||||
|
||||
// entry
|
||||
#ifdef DARWIN
|
||||
off_t pos = write_pos;
|
||||
::lseek(fd, write_pos, SEEK_SET);
|
||||
#else
|
||||
off64_t pos = write_pos;
|
||||
::lseek64(fd, write_pos, SEEK_SET);
|
||||
#endif
|
||||
for (list<bufferptr>::const_iterator it = bl.buffers().begin();
|
||||
it != bl.buffers().end();
|
||||
it++) {
|
||||
@ -411,9 +416,15 @@ void FileJournal::do_write(bufferlist& bl)
|
||||
<< dendl;
|
||||
pos += (*it).length();
|
||||
}
|
||||
#ifdef DARWIN
|
||||
if (!directio)
|
||||
::fsync(fd);
|
||||
#else
|
||||
if (!directio)
|
||||
::fdatasync(fd);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
write_lock.Lock();
|
||||
|
||||
writing = false;
|
||||
@ -583,7 +594,11 @@ bool FileJournal::read_entry(bufferlist& bl, epoch_t& epoch)
|
||||
|
||||
// header
|
||||
entry_header_t h;
|
||||
#ifdef DARWIN
|
||||
::lseek(fd, read_pos, SEEK_SET);
|
||||
#else
|
||||
::lseek64(fd, read_pos, SEEK_SET);
|
||||
#endif
|
||||
::read(fd, &h, sizeof(h));
|
||||
if (!h.check_magic(read_pos, header.fsid)) {
|
||||
dout(2) << "read_entry " << read_pos << " : bad header magic, end of journal" << dendl;
|
||||
|
@ -15,6 +15,12 @@
|
||||
# include "byteorder.h"
|
||||
#endif
|
||||
|
||||
#ifdef DARWIN
|
||||
typedef long long loff_t;
|
||||
typedef long long off64_t;
|
||||
#define O_DIRECT 00040000
|
||||
#endif
|
||||
|
||||
#define CEPH_MON_PORT 12345
|
||||
|
||||
/*
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define MAX_ERRNO 4095
|
||||
#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
|
||||
|
||||
#include <asm/errno.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* this generates a warning in c++; caller can do the cast manually
|
||||
static inline void *ERR_PTR(long error)
|
||||
|
@ -63,7 +63,7 @@ template<> struct rjhash<uint64_t> {
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(__CYGWIN__) || defined(DARWIN)
|
||||
template<> struct rjhash<size_t> {
|
||||
inline size_t operator()(const size_t x) const {
|
||||
#ifdef __LP64__
|
||||
|
@ -485,7 +485,7 @@ void CDir::steal_dentry(CDentry *dn)
|
||||
void CDir::purge_stolen(list<Context*>& waiters)
|
||||
{
|
||||
// take waiters _before_ unfreeze...
|
||||
take_waiting(WAIT_ANY, waiters);
|
||||
take_waiting(WAIT_ANY_MASK, waiters);
|
||||
|
||||
if (is_auth()) {
|
||||
assert(is_frozen_dir());
|
||||
|
@ -135,7 +135,7 @@ class CDir : public MDSCacheObject {
|
||||
|
||||
static const int WAIT_DNLOCK_OFFSET = 4;
|
||||
|
||||
static const int WAIT_ANY = (0xffffffff);
|
||||
static const int WAIT_ANY_MASK = (0xffffffff);
|
||||
static const int WAIT_ATFREEZEROOT = (WAIT_UNFREEZE);
|
||||
static const int WAIT_ATSUBTREEROOT = (WAIT_SINGLEAUTH);
|
||||
|
||||
|
@ -116,7 +116,7 @@ class CInode : public MDSCacheObject {
|
||||
static const int WAIT_DIRLOCK_OFFSET = 5 + 4*SimpleLock::WAIT_BITS;
|
||||
static const int WAIT_VERSIONLOCK_OFFSET = 5 + 5*SimpleLock::WAIT_BITS;
|
||||
|
||||
static const int WAIT_ANY = 0xffffffff;
|
||||
static const int WAIT_ANY_MASK = (0xffffffff);
|
||||
|
||||
// misc
|
||||
static const int EXPORT_NONCE = 1; // nonce given to replicas created by export
|
||||
|
@ -1198,7 +1198,7 @@ void MDCache::handle_mds_recovery(int who)
|
||||
while (!q.empty()) {
|
||||
CDir *d = q.front();
|
||||
q.pop_front();
|
||||
d->take_waiting(CDir::WAIT_ANY, waiters);
|
||||
d->take_waiting(CDir::WAIT_ANY_MASK, waiters);
|
||||
|
||||
// inode waiters too
|
||||
for (CDir::map_t::iterator p = d->items.begin();
|
||||
@ -1206,7 +1206,7 @@ void MDCache::handle_mds_recovery(int who)
|
||||
++p) {
|
||||
CDentry *dn = p->second;
|
||||
if (dn->is_primary()) {
|
||||
dn->get_inode()->take_waiting(CInode::WAIT_ANY, waiters);
|
||||
dn->get_inode()->take_waiting(CInode::WAIT_ANY_MASK, waiters);
|
||||
|
||||
// recurse?
|
||||
list<CDir*> ls;
|
||||
|
@ -940,7 +940,7 @@ void Migrator::finish_export_inode(CInode *in, utime_t now, list<Context*>& fini
|
||||
in->replica_nonce = CInode::EXPORT_NONCE;
|
||||
|
||||
// waiters
|
||||
in->take_waiting(CInode::WAIT_ANY, finished);
|
||||
in->take_waiting(CInode::WAIT_ANY_MASK, finished);
|
||||
|
||||
// *** other state too?
|
||||
|
||||
@ -1051,7 +1051,7 @@ void Migrator::finish_export_dir(CDir *dir, list<Context*>& finished, utime_t no
|
||||
dir->state &= CDir::MASK_STATE_EXPORT_KEPT; // i only retain a few things.
|
||||
|
||||
// suck up all waiters
|
||||
dir->take_waiting(CDir::WAIT_ANY, finished); // all dir waiters
|
||||
dir->take_waiting(CDir::WAIT_ANY_MASK, finished); // all dir waiters
|
||||
|
||||
// pop
|
||||
dir->finish_export(now);
|
||||
@ -2105,7 +2105,7 @@ int Migrator::decode_import_dir(bufferlist::iterator& blp,
|
||||
// a replica's presense in my cache implies/forces it's presense in authority's.
|
||||
list<Context*> waiters;
|
||||
|
||||
dir->take_waiting(CDir::WAIT_ANY, waiters);
|
||||
dir->take_waiting(CDir::WAIT_ANY_MASK, waiters);
|
||||
for (list<Context*>::iterator it = waiters.begin();
|
||||
it != waiters.end();
|
||||
it++)
|
||||
|
@ -15,7 +15,8 @@
|
||||
#ifndef __MONMAP_H
|
||||
#define __MONMAP_H
|
||||
|
||||
#include <asm/errno.h>
|
||||
#include "include/err.h"
|
||||
|
||||
#include "msg/Message.h"
|
||||
#include "include/types.h"
|
||||
//#include "config.h"
|
||||
|
@ -45,9 +45,11 @@
|
||||
|
||||
Rank rank;
|
||||
|
||||
|
||||
#ifdef DARWIN
|
||||
sig_t old_sigint_handler = 0;
|
||||
#else
|
||||
sighandler_t old_sigint_handler = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/********************************************
|
||||
* Accepter
|
||||
|
@ -217,7 +217,11 @@ int FakeStore::mount()
|
||||
#ifndef __CYGWIN__
|
||||
} else {
|
||||
char names[1000];
|
||||
#ifdef DARWIN
|
||||
r = ::listxattr(basedir.c_str(), names, 1000, 0);
|
||||
#else
|
||||
r = ::listxattr(basedir.c_str(), names, 1000);
|
||||
#endif
|
||||
if (r < 0) {
|
||||
derr(0) << "xattrs don't appear to work (" << strerror(errno) << "), specify --fakestore_fake_attrs to fake them (in memory)." << dendl;
|
||||
assert(0);
|
||||
@ -445,7 +449,11 @@ int FakeStore::setattr(pobject_t oid, const char *name,
|
||||
#ifndef __CYGWIN__
|
||||
char fn[100];
|
||||
get_oname(oid, fn);
|
||||
#ifdef DARWIN
|
||||
r = ::setxattr(fn, name, value, size, 0, 0);
|
||||
#else
|
||||
r = ::setxattr(fn, name, value, size, 0);
|
||||
#endif
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
@ -461,7 +469,11 @@ int FakeStore::setattrs(pobject_t oid, map<string,bufferptr>& aset)
|
||||
for (map<string,bufferptr>::iterator p = aset.begin();
|
||||
p != aset.end();
|
||||
++p) {
|
||||
#ifdef DARWIN
|
||||
r = ::setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length(), 0, 0);
|
||||
#else
|
||||
r = ::setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length(), 0);
|
||||
#endif
|
||||
if (r < 0) {
|
||||
cerr << "error setxattr " << strerror(errno) << std::endl;
|
||||
break;
|
||||
@ -479,7 +491,11 @@ int FakeStore::getattr(pobject_t oid, const char *name,
|
||||
#ifndef __CYGWIN__
|
||||
char fn[100];
|
||||
get_oname(oid, fn);
|
||||
#ifdef DARWIN
|
||||
r = ::getxattr(fn, name, value, size, 0, 0);
|
||||
#else
|
||||
r = ::getxattr(fn, name, value, size);
|
||||
#endif
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
@ -494,12 +510,19 @@ int FakeStore::getattrs(pobject_t oid, map<string,bufferptr>& aset)
|
||||
|
||||
char val[1000];
|
||||
char names[1000];
|
||||
#ifdef DARWIN
|
||||
int num = ::listxattr(fn, names, 1000, 0);
|
||||
#else
|
||||
int num = ::listxattr(fn, names, 1000);
|
||||
|
||||
#endif
|
||||
char *name = names;
|
||||
for (int i=0; i<num; i++) {
|
||||
dout(0) << "getattrs " << oid << " getting " << (i+1) << "/" << num << " '" << names << "'" << dendl;
|
||||
#ifdef DARWIN
|
||||
int l = ::getxattr(fn, name, val, 1000, 0, 0);
|
||||
#else
|
||||
int l = ::getxattr(fn, name, val, 1000);
|
||||
#endif
|
||||
dout(0) << "getattrs " << oid << " getting " << (i+1) << "/" << num << " '" << names << "' = " << l << " bytes" << dendl;
|
||||
aset[names].append(val, l);
|
||||
name += strlen(name) + 1;
|
||||
@ -515,7 +538,11 @@ int FakeStore::rmattr(pobject_t oid, const char *name, Context *onsafe)
|
||||
#ifndef __CYGWIN__
|
||||
char fn[100];
|
||||
get_oname(oid, fn);
|
||||
#ifdef DARWIN
|
||||
r = ::removexattr(fn, name, 0);
|
||||
#else
|
||||
r = ::removexattr(fn, name);
|
||||
#endif
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
@ -526,7 +553,11 @@ int FakeStore::listattr(pobject_t oid, char *attrls, size_t size)
|
||||
if (fake_attrs) return attrs.listattr(oid, attrls, size);
|
||||
char fn[100];
|
||||
get_oname(oid, fn);
|
||||
#ifdef DARWIN
|
||||
return ::listxattr(fn, attrls, size, 0);
|
||||
#else
|
||||
return ::listxattr(fn, attrls, size);
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
@ -566,7 +597,11 @@ int FakeStore::collection_setattrs(coll_t cid, map<string,bufferptr>& aset)
|
||||
for (map<string,bufferptr>::iterator p = aset.begin();
|
||||
p != aset.end();
|
||||
++p) {
|
||||
#ifdef DARWIN
|
||||
r = ::setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length(), 0, 0);
|
||||
#else
|
||||
r = ::setxattr(fn, p->first.c_str(), p->second.c_str(), p->second.length(), 0);
|
||||
#endif
|
||||
if (r < 0) break;
|
||||
}
|
||||
#endif
|
||||
@ -583,12 +618,20 @@ int FakeStore::collection_getattrs(coll_t cid, map<string,bufferptr>& aset)
|
||||
|
||||
char val[1000];
|
||||
char names[1000];
|
||||
#ifdef DARWIN
|
||||
int num = ::listxattr(fn, names, 1000, 0);
|
||||
#else
|
||||
int num = ::listxattr(fn, names, 1000);
|
||||
|
||||
#endif
|
||||
|
||||
char *name = names;
|
||||
for (int i=0; i<num; i++) {
|
||||
dout(0) << "getattrs " << cid << " getting " << (i+1) << "/" << num << " '" << names << "'" << dendl;
|
||||
#ifdef DARWIN
|
||||
int l = ::getxattr(fn, name, val, 1000, 0, 0);
|
||||
#else
|
||||
int l = ::getxattr(fn, name, val, 1000);
|
||||
#endif
|
||||
dout(0) << "getattrs " << cid << " getting " << (i+1) << "/" << num << " '" << names << "' = " << l << " bytes" << dendl;
|
||||
aset[names].append(val, l);
|
||||
name += strlen(name) + 1;
|
||||
|
@ -70,6 +70,11 @@
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef DARWIN
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#endif // DARWIN
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user