Further sanity check fixes.
[dcpomatic.git] / src / tools / dcpomatic_disk_writer.cc
index c38e35e3ee8cf95406ba0a2a3478763e3db6456f..b8255468f78ab827a86d965e7ab358dfd4f63f40 100644 (file)
@@ -42,6 +42,7 @@ extern "C" {
 #endif
 
 #ifdef DCPOMATIC_OSX
+#include "lib/stdout_log.h"
 #undef nil
 extern "C" {
 #include <lwext4/file_dev.h>
@@ -438,7 +439,7 @@ try
                /* Do some basic sanity checks; this is a bit belt-and-braces but it can't hurt... */
 
 #ifdef DCPOMATIC_OSX
-               if (!starts_with(*device, "/dev/disk")) {
+               if (!starts_with(*device, "/dev/rdisk")) {
                        LOG_DISK ("Will not write to %1", *device);
                        nanomsg->send(DISK_WRITER_ERROR "\nRefusing to write to this drive\n1\n", LONG_TIMEOUT);
                        return true;
@@ -462,7 +463,7 @@ try
                bool on_drive_list = false;
                bool mounted = false;
                for (auto const& i: Drive::get()) {
-                       if (i.device() == *device) {
+                       if (i.device_for_write() == *device) {
                                on_drive_list = true;
                                mounted = i.mounted();
                        }
@@ -504,11 +505,20 @@ try
 int
 main ()
 {
+#ifdef DCPOMATIC_OSX
+       /* On macOS this is running as root, so config_path() will be somewhere in root's
+        * home.  Instead, just write to stdout as the macOS process control stuff will
+        * redirect this to a file in /var/log
+        */
+       dcpomatic_log.reset(new StdoutLog(LogEntry::TYPE_DISK));
+       LOG_DISK_NC("dcpomatic_disk_writer started");
+#else
        /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's
         * a better place to put them.
         */
        dcpomatic_log.reset(new FileLog(config_path() / "disk_writer.log", LogEntry::TYPE_DISK));
        LOG_DISK_NC("dcpomatic_disk_writer started");
+#endif
 
        try {
                nanomsg = new Nanomsg (false);