From 58dde17c9128ff64c48c092a5f78b8e7c1b91db1 Mon Sep 17 00:00:00 2001 From: Emmanuel Maillard Date: Wed, 7 Jul 2004 00:47:10 +0000 Subject: [PATCH] Added Darwin support in get_default_drive_device. --- dlls/ntdll/directory.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index eb72c221ce6..8f474936d56 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -41,6 +41,12 @@ #ifdef HAVE_LINUX_IOCTL_H #include #endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif #include #ifdef HAVE_UNISTD_H # include @@ -268,6 +274,44 @@ static char *get_default_drive_device( const char *root ) if (ret) strcpy( ret, device ); } RtlLeaveCriticalSection( &dir_section ); +#elif defined(__APPLE__) + struct statfs *mntStat; + struct stat st; + int i; + int mntSize; + dev_t dev; + ino_t ino; + static const char path_bsd_device[] = "/dev/disk"; + int res; + + res = stat( root, &st ); + if (res == -1) return NULL; + + dev = st.st_dev; + ino = st.st_ino; + + RtlEnterCriticalSection( &dir_section ); + + mntSize = getmntinfo(&mntStat, MNT_NOWAIT); + + for (i = 0; i < mntSize && !ret; i++) + { + if (stat(mntStat[i].f_mntonname, &st ) == -1) continue; + if (st.st_dev != dev || st.st_ino != ino) continue; + + /* FIXME add support for mounted network drive */ + if ( strncmp(mntStat[i].f_mntfromname, path_bsd_device, strlen(path_bsd_device)) == 0) + { + /* set return value to the corresponding raw BSD node */ + ret = RtlAllocateHeap( GetProcessHeap(), 0, strlen(mntStat[i].f_mntfromname) + 2 /* 2 : r and \0 */ ); + if (ret) + { + strcpy(ret, "/dev/r"); + strcat(ret, mntStat[i].f_mntfromname+sizeof("/dev/")-1); + } + } + } + RtlLeaveCriticalSection( &dir_section ); #else static int warned; if (!warned++) FIXME( "auto detection of DOS devices not supported on this platform\n" ); -- 2.11.4.GIT