common/linux_version.c
endif
+if SOLARIS
+libcommon_internal_la_SOURCES += \
+ common/solaris_errno.cc
+endif
+
if WITH_RBD
if LINUX
libcommon_internal_la_SOURCES += \
--- /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) 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 <errno.h>
+#include "include/types.h"
+
+
+// converts from linux errno values to host values
+__s32 ceph_to_host_errno(__s32 r)
+{
+ if (r < -34) {
+ switch (r) {
+ case -35:
+ return -EDEADLK;
+ case -36:
+ return -ENAMETOOLONG;
+ case -37:
+ return -ENOLCK;
+ case -38:
+ return -ENOSYS;
+ case -39:
+ return -ENOTEMPTY;
+ case -40:
+ return -ELOOP;
+ case -42:
+ return -ENOMSG;
+ case -43:
+ return -EIDRM;
+ case -44:
+ return -ECHRNG;
+ case -45:
+ return -EL2NSYNC;
+ case -46:
+ return -EL3HLT;
+ case -47:
+ return -EL3RST;
+ case -48:
+ return -ELNRNG;
+ case -49:
+ return -EUNATCH;
+ case -50:
+ return -ENOCSI;
+ case -51:
+ return -EL2HLT;
+ case -52:
+ return -EBADE;
+ case -53:
+ return -EBADR;
+ case -54:
+ return -EXFULL;
+ case -55:
+ return -ENOANO;
+ case -56:
+ return -EBADRQC;
+ case -57:
+ return -EBADSLT;
+ case -59:
+ return -EBFONT;
+ case -60:
+ return -ENOSTR;
+ case -61:
+ return -ENODATA;
+ case -62:
+ return -ETIME;
+ case -63:
+ return -ENOSR;
+ //case -64:
+ // return -EPERM; //TODO ENONET
+ //case -65:
+ // return -EPERM; //TODO ENOPKG
+ //case -66:
+ // return -EREMOTE;
+ //case -67:
+ // return -ENOLINK;
+ //case -68:
+ // return -EPERM; //TODO EADV
+ //case -69:
+ // return -EPERM; //TODO ESRMNT
+ //case -70:
+ // return -EPERM; //TODO ECOMM
+ case -71:
+ return -EPROTO;
+ case -72:
+ return -EMULTIHOP;
+ case -73:
+ return -EPERM; //TODO EDOTDOT
+ case -74:
+ return -EBADMSG;
+ case -75:
+ return -EOVERFLOW;
+ case -76:
+ return -ENOTUNIQ;
+ case -77:
+ return -EBADFD;
+ case -78:
+ return -EREMCHG;
+ case -79:
+ return -ELIBACC;
+ case -80:
+ return -ELIBBAD;
+ case -81:
+ return -ELIBSCN;
+ case -82:
+ return -ELIBMAX;
+ case -83:
+ return -ELIBEXEC;
+ case -84:
+ return -EILSEQ;
+ case -85:
+ return -ERESTART;
+ case -86:
+ return -ESTRPIPE;
+ case -87:
+ return -EUSERS;
+ case -88:
+ return -ENOTSOCK;
+ case -89:
+ return -EDESTADDRREQ;
+ case -90:
+ return -EMSGSIZE;
+ case -91:
+ return -EPROTOTYPE;
+ case -92:
+ return -ENOPROTOOPT;
+ case -93:
+ return -EPROTONOSUPPORT;
+ case -94:
+ return -ESOCKTNOSUPPORT;
+ case -95:
+ return -EOPNOTSUPP;
+ case -96:
+ return -EPFNOSUPPORT;
+ case -97:
+ return -EAFNOSUPPORT;
+ case -98:
+ return -EADDRINUSE;
+ case -99:
+ return -EADDRNOTAVAIL;
+ case -100:
+ return -ENETDOWN;
+ case -101:
+ return -ENETUNREACH;
+ case -102:
+ return -ENETRESET;
+ case -103:
+ return -ECONNABORTED;
+ case -104:
+ return -ECONNRESET;
+ case -105:
+ return -ENOBUFS;
+ case -106:
+ return -EISCONN;
+ case -107:
+ return -ENOTCONN;
+ case -108:
+ return -ESHUTDOWN;
+ case -109:
+ return -ETOOMANYREFS;
+ case -110:
+ return -ETIMEDOUT;
+ case -111:
+ return -ECONNREFUSED;
+ case -112:
+ return -EHOSTDOWN;
+ case -113:
+ return -EHOSTUNREACH;
+ case -114:
+ return -EALREADY;
+ case -115:
+ return -EINPROGRESS;
+ case -116:
+ return -ESTALE;
+ case -117:
+ return -EPERM; //TODO EUCLEAN
+ case -118:
+ return -EPERM; //TODO ENOTNAM
+ case -119:
+ return -EPERM; //TODO ENAVAIL
+ case -120:
+ return -EPERM; //TODO EISNAM
+ case -121:
+ return -EPERM; //TODO EREMOTEIO
+ case -122:
+ return -EDQUOT;
+ case -123:
+ return -EPERM; //TODO ENOMEDIUM
+ case -124:
+ return -EPERM; //TODO EMEDIUMTYPE - not used
+ case -125:
+ return -ECANCELED;
+ case -126:
+ return -EPERM; //TODO ENOKEY
+ case -127:
+ return -EPERM; //TODO EKEYEXPIRED
+ case -128:
+ return -EPERM; //TODO EKEYREVOKED
+ case -129:
+ return -EPERM; //TODO EKEYREJECTED
+ case -130:
+ return -EOWNERDEAD;
+ case -131:
+ return -ENOTRECOVERABLE;
+ case -132:
+ return -EPERM; //TODO ERFKILL
+ case -133:
+ return -EPERM; //TODO EHWPOISON
+
+ default: {
+ break;
+ }
+ }
+ }
+ return r; // otherwise return original value
+}
+
+
WRITE_CMP_OPERATORS_1(shard_id_t, id)
ostream &operator<<(ostream &lhs, const shard_id_t &rhs);
+#if defined(__sun)
+__s32 ceph_to_host_errno(__s32 e);
+#else
+#define ceph_to_host_errno(e) (e)
+#endif
+
+struct errorcode32_t {
+ int32_t code;
+
+ errorcode32_t() {}
+ errorcode32_t(int32_t i) : code(i) {}
+
+ operator int() const { return code; }
+ int operator==(int i) {
+ return code==i;
+ }
+
+ void encode(bufferlist &bl) const {
+ ::encode(code, bl);
+ }
+ void decode(bufferlist::iterator &bl) {
+ ::decode(code, bl);
+ code = ceph_to_host_errno(code);
+ }
+};
+WRITE_CLASS_ENCODER(errorcode32_t)
+WRITE_EQ_OPERATORS_1(errorcode32_t, code)
+WRITE_CMP_OPERATORS_1(errorcode32_t, code)
+
+
#endif
struct MAuthReply : public Message {
__u32 protocol;
- __s32 result;
+ errorcode32_t result;
uint64_t global_id; // if zero, meaningless
string result_msg;
bufferlist result_bl;
class MCommandReply : public Message {
public:
- __s32 r;
+ errorcode32_t r;
string rs;
MCommandReply()
class MMonCommandAck : public PaxosServiceMessage {
public:
vector<string> cmd;
- __s32 r;
+ errorcode32_t r;
string rs;
MMonCommandAck() : PaxosServiceMessage(MSG_MON_COMMAND_ACK, 0) {}
pg_t pgid;
vector<OSDOp> ops;
int64_t flags;
- int32_t result;
+ errorcode32_t result;
eversion_t bad_replay_version;
eversion_t replay_version;
version_t user_version;
}
::decode_nohead(head.object_len, oid.name, p);
pgid = pg_t(head.layout.ol_pgid);
- result = head.result;
+ result = (int32_t)head.result;
flags = head.flags;
replay_version = head.reassert_version;
user_version = replay_version.version;
uint64_t notify_id; ///< osd unique id for a notify notification
uint8_t opcode; ///< CEPH_WATCH_EVENT_*
bufferlist bl; ///< notify payload (osd->client)
- int32_t return_code; ///< notify result (osd->client)
+ errorcode32_t return_code; ///< notify result (osd->client)
uint64_t notifier_gid; ///< who sent the notify
MWatchNotify()
#include "include/str_list.h"
#include "common/errno.h"
-
#define dout_subsys ceph_subsys_objecter
#undef dout_prefix
#define dout_prefix *_dout << messenger->get_myname() << ".objecter "
// set rval before running handlers so that handlers
// can change it if e.g. decoding fails
if (*pr)
- **pr = p->rval;
+ **pr = ceph_to_host_errno(p->rval);
if (*ph) {
ldout(cct, 10) << " op " << i << " handler " << *ph << dendl;
- (*ph)->complete(p->rval);
+ (*ph)->complete(ceph_to_host_errno(p->rval));
*ph = NULL;
}
}