|
@@ -7,6 +7,8 @@
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/xattr.h"
|
|
#include "qemu/xattr.h"
|
|
|
|
+#include "qapi/error.h"
|
|
|
|
+#include "qemu/error-report.h"
|
|
#include "9p-util.h"
|
|
#include "9p-util.h"
|
|
|
|
|
|
ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name,
|
|
ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name,
|
|
@@ -62,3 +64,34 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name,
|
|
close_preserve_errno(fd);
|
|
close_preserve_errno(fd);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * As long as mknodat is not available on macOS, this workaround
|
|
|
|
+ * using pthread_fchdir_np is needed.
|
|
|
|
+ *
|
|
|
|
+ * Radar filed with Apple for implementing mknodat:
|
|
|
|
+ * rdar://FB9862426 (https://openradar.appspot.com/FB9862426)
|
|
|
|
+ */
|
|
|
|
+#if defined CONFIG_PTHREAD_FCHDIR_NP
|
|
|
|
+
|
|
|
|
+int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev)
|
|
|
|
+{
|
|
|
|
+ int preserved_errno, err;
|
|
|
|
+ if (!pthread_fchdir_np) {
|
|
|
|
+ error_report_once("pthread_fchdir_np() not available on this version of macOS");
|
|
|
|
+ return -ENOTSUP;
|
|
|
|
+ }
|
|
|
|
+ if (pthread_fchdir_np(dirfd) < 0) {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ err = mknod(filename, mode, dev);
|
|
|
|
+ preserved_errno = errno;
|
|
|
|
+ /* Stop using the thread-local cwd */
|
|
|
|
+ pthread_fchdir_np(-1);
|
|
|
|
+ if (err < 0) {
|
|
|
|
+ errno = preserved_errno;
|
|
|
|
+ }
|
|
|
|
+ return err;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif
|