From: Lucian Petrut Date: Thu, 30 Apr 2020 07:20:40 +0000 (+0000) Subject: common: define DEV_NULL X-Git-Tag: v16.1.0~652^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1532b8f332b92930f25fa0019533b98cc39b5033;p=ceph.git common: define DEV_NULL On Windows, the "nul" special path must be used instead of "/dev/null". Worth mentioning that reading from "nul" will report errors, unlike "/dev/null" on POSIX platforms. This doesn't affect writes. Signed-off-by: Lucian Petrut --- diff --git a/src/global/global_init.cc b/src/global/global_init.cc index abb3607a371..84acd4850dd 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -495,7 +495,7 @@ void global_init_daemonize(CephContext *cct) int reopen_as_null(CephContext *cct, int fd) { - int newfd = open("/dev/null", O_RDONLY|O_CLOEXEC); + int newfd = open(DEV_NULL, O_RDONLY | O_CLOEXEC); if (newfd < 0) { int err = errno; lderr(cct) << __func__ << " failed to open /dev/null: " << cpp_strerror(err) diff --git a/src/include/compat.h b/src/include/compat.h index d3f829c9be2..1b807231f14 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -316,6 +316,8 @@ extern _CRTIMP errno_t __cdecl _putenv_s(const char *_Name,const char *_Value); #define O_CLOEXEC 0 #define SOCKOPT_VAL_TYPE char* +#define DEV_NULL "nul" + #else /* WIN32 */ #define SOCKOPT_VAL_TYPE void* @@ -325,6 +327,8 @@ static inline int compat_closesocket(int fildes) { return close(fildes); } +#define DEV_NULL "/dev/null" + #endif /* WIN32 */ /* Supplies code to be run at startup time before invoking main().