From: VMware, Inc <> Date: Mon, 22 Aug 2011 20:21:37 +0000 (-0700) Subject: Fix disk device detection on Mac OS. X-Git-Tag: 2011.08.21-471295~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14734fa09089176dc0a2128ac06af26deefa56b1;p=thirdparty%2Fopen-vm-tools.git Fix disk device detection on Mac OS. A recent reorg of this code seems to have uncovered an issue where our FreeBSD-targeted WiperIsDiskDevice doesn't really work on MacOS, in spite of what the comments say. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/wiper/wiperPosix.c b/open-vm-tools/lib/wiper/wiperPosix.c index 8beb74cf7..88fc1a307 100644 --- a/open-vm-tools/lib/wiper/wiperPosix.c +++ b/open-vm-tools/lib/wiper/wiperPosix.c @@ -46,6 +46,7 @@ #include "wiper.h" #include "util.h" #include "str.h" +#include "strutil.h" #include "fileIO.h" #include "vmstdio.h" #include "mntinfo.h" @@ -325,7 +326,7 @@ WiperIsDiskDevice(MNTINFO *mnt, // IN: file system being considered return FALSE; } -#elif defined(__FreeBSD__) || defined(__APPLE__) /* } FreeBSD { */ +#elif defined(__FreeBSD__) /* } FreeBSD { */ static Bool WiperIsDiskDevice(MNTINFO *mnt, // IN: file system being considered @@ -359,7 +360,7 @@ WiperIsDiskDevice(MNTINFO *mnt, // IN: file system being considered (S_ISCHR(s->st_mode) && ((maj == 3) || (maj == 13)))) { retval = TRUE; } -#else /* Also the Apple case */ +#else /* * Begin by testing whether file system source is really a character * device node. (FreeBSD killed off block devices long ago.) Next, @@ -375,10 +376,27 @@ WiperIsDiskDevice(MNTINFO *mnt, // IN: file system being considered retval = TRUE; } } +#undef MASK_ATA_DISK +#undef MASK_SCSI_DISK #endif /* __FreeBSD_version */ return retval; } + +#elif defined(__APPLE__) /* } { */ + +static Bool +WiperIsDiskDevice(MNTINFO *mnt, // IN + struct stat *s) // IN +{ + /* + * Differently from FreeBSD, Mac OS still lists disks as block devices, + * it seems. Disks devices also seem to start with "/dev/disk". + */ + return S_ISBLK(s->st_mode) && + StrUtil_StartsWith(MNTINFO_NAME(mnt), "/dev/disk"); +} + #endif /* } */ /*