]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: define DEV_NULL
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 30 Apr 2020 07:20:40 +0000 (07:20 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 22 Oct 2020 12:04:38 +0000 (12:04 +0000)
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 <lpetrut@cloudbasesolutions.com>
src/global/global_init.cc
src/include/compat.h

index abb3607a3712e11d25c02c4aa54d2aaafe57b2ac..84acd4850dd6fb1af32450dce347b2d1cdc3ef4e 100644 (file)
@@ -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)
index d3f829c9be2536298bf7807166a487ebff9ae65d..1b807231f1417d7f8171fb3edfd7fb7408f04070 100644 (file)
@@ -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().