diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test.c | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/test/test.c b/test/test.c index 1e5ad2e47..0cfa90432 100644 --- a/test/test.c +++ b/test/test.c @@ -43,6 +43,7 @@ #include <IOKit/IOKitLib.h> #include <IOKit/storage/IOMedia.h> #include <IOKit/storage/IODVDMedia.h> +#include <sys/mount.h> #endif #define LAPSHARP_DEFAULT_PRESET "medium" @@ -4888,46 +4889,23 @@ static void print_string_list(FILE *out, const char* const *list, const char *pr ****************************************************************************/ static char* bsd_name_for_path(char *path) { - OSStatus err; - FSRef ref; - err = FSPathMakeRef( (const UInt8 *) input, &ref, NULL ); - if( err != noErr ) - { - return NULL; - } + const char *prefix = "/dev/"; + struct statfs s; - // Get the volume reference number. - FSCatalogInfo catalogInfo; - err = FSGetCatalogInfo( &ref, kFSCatInfoVolume, &catalogInfo, NULL, NULL, - NULL); - if( err != noErr ) + if (statfs(path, &s) == -1) { return NULL; } - FSVolumeRefNum volRefNum = catalogInfo.volume; - // Now let's get the device name - GetVolParmsInfoBuffer volumeParms; - err = FSGetVolumeParms( volRefNum, &volumeParms, sizeof( volumeParms ) ); - if( err != noErr ) - { - return NULL; - } + size_t lenpre = strlen(prefix), + lenstr = strlen(s.f_mntfromname); - // A version 4 GetVolParmsInfoBuffer contains the BSD node name in the vMDeviceID field. - // It is actually a char * value. This is mentioned in the header CoreServices/CarbonCore/Files.h. - if( volumeParms.vMVersion < 4 ) + if (lenstr > lenpre && strncmp(prefix, s.f_mntfromname, lenpre) == 0) { - return NULL; - } - - // vMDeviceID might be zero as is reported with experimental ZFS (zfs-119) support in Leopard. - if( !volumeParms.vMDeviceID ) - { - return NULL; + return strdup(s.f_mntfromname + lenpre); } - return strdup( volumeParms.vMDeviceID ); + return strdup(s.f_mntfromname); } /**************************************************************************** |