X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fcommon%2Fcode_environment.cc;fp=src%2Fceph%2Fsrc%2Fcommon%2Fcode_environment.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=7b106d585fb4c14872d0f7fdbaf42d8bb12517bf;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/common/code_environment.cc b/src/ceph/src/common/code_environment.cc deleted file mode 100644 index 7b106d5..0000000 --- a/src/ceph/src/common/code_environment.cc +++ /dev/null @@ -1,93 +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) 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 "common/code_environment.h" - -#include - -#ifdef HAVE_SYS_PRCTL_H -#include -#endif - -code_environment_t g_code_env = CODE_ENVIRONMENT_UTILITY; - -extern "C" const char *code_environment_to_str(enum code_environment_t e) -{ - switch (e) { - case CODE_ENVIRONMENT_UTILITY: - return "CODE_ENVIRONMENT_UTILITY"; - case CODE_ENVIRONMENT_DAEMON: - return "CODE_ENVIRONMENT_DAEMON"; - case CODE_ENVIRONMENT_LIBRARY: - return "CODE_ENVIRONMENT_LIBRARY"; - default: - return NULL; - } -} - -std::ostream &operator<<(std::ostream &oss, const enum code_environment_t e) -{ - oss << code_environment_to_str(e); - return oss; -} - -#if defined(HAVE_SYS_PRCTL_H) && defined(PR_GET_NAME) /* Since 2.6.11 */ - -int get_process_name(char *buf, int len) -{ - if (len <= 16) { - /* The man page discourages using this prctl with a buffer shorter - * than 16 bytes. With a 16-byte buffer, it might not be - * null-terminated. */ - return -ENAMETOOLONG; - } - memset(buf, 0, len); - return prctl(PR_GET_NAME, buf); -} - -#elif defined(HAVE_GETPROGNAME) - -int get_process_name(char *buf, int len) -{ - if (len <= 0) { - return -EINVAL; - } - - const char *progname = getprogname(); - if (progname == nullptr || *progname == '\0') { - return -ENOSYS; - } - - strncpy(buf, progname, len - 1); - buf[len - 1] = '\0'; - return 0; -} - -#else - -int get_process_name(char *buf, int len) -{ - return -ENOSYS; -} - -#endif - -std::string get_process_name_cpp() -{ - char buf[32]; - if (get_process_name(buf, sizeof(buf))) { - return "(unknown)"; - } - return std::string(buf); -}