Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS X Support #7

Open
mkuron opened this issue Jul 25, 2012 · 4 comments
Open

Mac OS X Support #7

mkuron opened this issue Jul 25, 2012 · 4 comments

Comments

@mkuron
Copy link

mkuron commented Jul 25, 2012

I tried to compile vmfs-tools on Mac OS X 10.6.8. In its current state, it fails, but fixing it is rather simple:

Missing u_char typedef: #include <sys/types.h>
Missing strnlen(): #define strnlen(s, maxlen) (strlen (s) < maxlen ? strlen (s) : maxlen)
Missing timersub() and gettimeofday(): #include <sys/time.h>
Missing libuuid: Download e2fsprogs, ./configure it, cd lib/uuid, make, copy the uuid folder to vmfs-tools. (e2fsprogs from MacPorts does not help as it gets built without libuuid)
FUSE: Install osxfuse

Below is a diff file for these changes. The changes to C code have ifdef around them and could thus easily go into the official code. The changes required to configure.mk to find fuse and uuid are more invasive; I don't know much about automake, but I'm sure you could wrap some kind of if-clause around it.

diff --git a/configure.mk b/configure.mk
index 710816c..2dbfa6f 100644
--- a/configure.mk
+++ b/configure.mk
@@ -9,8 +9,8 @@ datarootdir := $$(prefix)/share
 mandir := $$(datarootdir)/man

 # configure rules really start here
-$(call PKG_CONFIG_CHK,uuid,-I/usr/include/uuid,-luuid)
-$(call PKG_CONFIG_CHK,fuse)
+$(call PKG_CONFIG_CHK,uuid,-I./uuid,-L./uuid,-luuid)
+$(call PKG_CONFIG_CHK,fuse,-I/usr/local/include/osxfuse/fuse,-L/usr/local/lib -lfuse)
 $(call PATH_LOOKUP,asciidoc)
 $(call PATH_LOOKUP,xsltproc)

diff --git a/imager/imager.c b/imager/imager.c
index e2963ba..f7c60c5 100644
--- a/imager/imager.c
+++ b/imager/imager.c
@@ -48,6 +48,9 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <inttypes.h>
+#ifdef __APPLE__
+#include <sys/types.h>
+#endif
 #include <string.h>

 static void die(char *fmt, ...)
diff --git a/libvmfs/utils.h b/libvmfs/utils.h
index 8daca31..61f8460 100644
--- a/libvmfs/utils.h
+++ b/libvmfs/utils.h
@@ -22,6 +22,10 @@
 #include <string.h>
 #include <uuid.h>
 #include <inttypes.h>
+#ifdef __APPLE__
+#include <sys/types.h>
+#define strnlen(s, maxlen) (strlen (s) < maxlen ? strlen (s) : maxlen)
+#endif

 /* Max and min macro */
 #define m_max(a,b) (((a) > (b)) ? (a) : (b))
diff --git a/libvmfs/vmfs_host.h b/libvmfs/vmfs_host.h
index bffc6f5..8834135 100644
--- a/libvmfs/vmfs_host.h
+++ b/libvmfs/vmfs_host.h
@@ -18,6 +18,10 @@
 #ifndef VMFS_HOST_H
 #define VMFS_HOST_H

+#ifdef __APPLE__
+#include <sys/time.h>
+#endif
+
 /* Initialize host info (UUID,uptime,...) */
 int vmfs_host_init(void);

Now everything compiles without warnings or errors. debugvmfs works fine on test.img, but I have not tested yet whether vmfs-fuse works on an actual volume (as far as I can tell, it does not mount bitmap files like test.img, so I can't test it right now). If someone sends me a dd image of a VMFS, I can test that and the other tools.

@hk6an6
Copy link

hk6an6 commented Sep 26, 2012

I had to change one thing on the configure.mk file:

the line for "$(call PKG_CONFIG_CHK,fuse,-I/usr/local/include/osxfuse/fuse,-L/usr/local/lib -lfuse)" is actually "$(call PKG_CONFIG_CHK,fuse,-I/usr/local/include/osxfuse/fuse,-L/usr/local/lib -
losxfuse)", since we're using "osxfuse" instead of "fuse"

On OS X 10.8.2, after following your instructions, "sudo make install" fails with the message:

make: *** No rule to make target debugvmfs/debugvmfs.8', needed by/usr/local/share/man/man8/debugvmfs.8'. Stop.

I'm clueless as to how to fix this. Can you help me out?

@xtrasimplicity
Copy link

xtrasimplicity commented Jan 4, 2017

I had this issue on macOS Sierra (10.12), and was able to fix it with @mkuron did, with one minor modification: instead of adding #ifdef conditions, I had to just add each include. It appears that (at least with my version of gcc) _APPLE_ is not defined, so the sys/xxxx headers aren't included if you use the ifdef condition.

@skandragon
Copy link

__APPLE__ (two underscores in front, two behind) is defined. A single _ is not. Which did you try, @xtrasimplicity ?

@xtrasimplicity
Copy link

@skandragon, this was so long ago that I don't actually have that particular install of OS X anymore, so I can't check, unfortunately! I'd like to think that I just mistyped __APPLE__, but I can't say for certain! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants