-std::string SharedMemoryCommon::SharedMemoryFilePath(const char *segmentName, uid_t uid) {
- std::string path;
- uid = SharedMemoryCommon::fixUID(uid);
- path = SharedMemoryCommon::kMDSMessagesDirectory; // i.e. /private/var/db/mds/messages/
- if (uid != 0) {
- path += std::to_string(uid) + "/"; // e.g. /private/var/db/mds/messages/501/
+static bool makedir(const char *path, mode_t mode) {
+ // Returns true on success. Primarily to centralize logging
+ if (::mkdir(path, mode)==0 || errno==EEXIST) {
+ return true;
+ } else {
+ secdebug("MDSPRIVACY","Failed to make directory: %s (%d)", path, errno);
+ return false;