You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2015/12/17 23:05:46 UTC
[2/3] mesos git commit: Windows: Stout: Added compatibility code for
`grp.h` and `pwd.h`.
Windows: Stout: Added compatibility code for `grp.h` and `pwd.h`.
This code will be particularly useful when we expand Windows support for
`files/files.hpp`.
Review: https://reviews.apache.org/r/39888/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/33d332ef
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/33d332ef
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/33d332ef
Branch: refs/heads/master
Commit: 33d332ef4bbb339df96f442a90e8775d48a0f817
Parents: ce09c58
Author: Alex Clemmer <cl...@gmail.com>
Authored: Wed Dec 16 17:17:49 2015 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Dec 17 13:35:51 2015 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/Makefile.am | 2 +
.../include/stout/internal/windows/grp.hpp | 51 +++++++++++++++++++
.../include/stout/internal/windows/pwd.hpp | 52 ++++++++++++++++++++
.../3rdparty/stout/include/stout/windows.hpp | 11 +++++
4 files changed, 116 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/33d332ef/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index d1ef6f0..b2dea9b 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -36,6 +36,8 @@ nobase_include_HEADERS = \
stout/gzip.hpp \
stout/hashmap.hpp \
stout/hashset.hpp \
+ stout/internal/windows/grp.hpp \
+ stout/internal/windows/pwd.hpp \
stout/interval.hpp \
stout/ip.hpp \
stout/json.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/33d332ef/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/grp.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/grp.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/grp.hpp
new file mode 100644
index 0000000..1b74be6
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/grp.hpp
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_INTERNAL_WINDOWS_GRP_HPP__
+#define __STOUT_INTERNAL_WINDOWS_GRP_HPP__
+
+#include <sys/types.h>
+
+#include <stout/windows.hpp>
+
+
+// Dummy struct for POSIX compliance.
+struct group
+{
+ char* gr_name; // The name of the group.
+ gid_t gr_gid; // Numerical group ID.
+ char** gr_mem; // Pointer to a null-terminated array of character pointers to
+ // member names.
+};
+
+
+extern "C" {
+// Dummy implementation of `getgrgid` for POSIX compliance. Per the POSIX
+// specification[1], we are to return `NULL` if an entry matching the GID is
+// not found. On Windows, we will never find such an entry, so we always return
+// `NULL`. Just to be safe, we also set `errno` to `ENOSYS` which indicates the
+// function is not implemented.
+//
+// [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/getgrgid.html
+struct group* getgrgid(gid_t)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+} // extern "C" {
+
+
+#endif // __STOUT_INTERNAL_WINDOWS_GRP_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/33d332ef/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/pwd.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/pwd.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/pwd.hpp
new file mode 100644
index 0000000..60990bb
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/internal/windows/pwd.hpp
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_INTERNAL_WINDOWS_PWD_HPP__
+#define __STOUT_INTERNAL_WINDOWS_PWD_HPP__
+
+#include <sys/types.h>
+
+#include <stout/windows.hpp>
+
+
+// Dummy struct for POSIX compliance.
+struct passwd
+{
+ char* pw_name; // User's login name.
+ uid_t pw_uid; // Numerical user ID.
+ gid_t pw_gid; // Numerical group ID.
+ char* pw_dir; // Initial working directory.
+ char* pw_shell; // Program to use as shell.
+};
+
+
+extern "C" {
+// Dummy implementation of `getpwuid` for POSIX compliance. Per the POSIX
+// specification[1], we are to return `NULL` if an entry matching the UID is
+// not found. On Windows, we will never find such an entry, so we always return
+// `NULL`. Just to be safe, we also set `errno` to `ENOSYS` which indicates the
+// function is not implemented.
+//
+// [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/getgrgid.html
+struct passwd* getpwuid(uid_t)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+} // extern "C" {
+
+
+#endif // __STOUT_INTERNAL_WINDOWS_PWD_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/33d332ef/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
index 6711a16..d46e262 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
@@ -120,6 +120,9 @@ typedef int mode_t;
// including functions like `OpenProcess`.
typedef DWORD pid_t;
+typedef int uid_t;
+typedef int gid_t;
+
typedef SSIZE_T ssize_t;
// Socket flags. Define behavior of a socket when it (e.g.) shuts down. We map
@@ -127,6 +130,14 @@ typedef SSIZE_T ssize_t;
// have to change any socket code.
constexpr int SHUT_RD = SD_RECEIVE;
+// Macros that test whether a `stat` struct represents a directory or a file.
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) // Directory.
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) // File.
+#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) // Character device.
+#define S_ISFIFO(mode) (((mode) & S_IFMT) == _S_IFIFO) // Pipe.
+#define S_ISBLK(mode) 0 // Block special device.
+#define S_ISSOCK(mode) 0 // Socket.
+#define S_ISLNK(mode) 0 // Symbolic link.
// Permissions API. (cf. MESOS-3176 to track ongoing permissions work.)
//