1/* 2 * Copyright (c) 2001-2007 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23/* 24 * BLGetVolumeFinderInfo.c 25 * bless 26 * 27 * Created by Shantonu Sen <ssen@apple.com> on Thu Apr 19 2001. 28 * Copyright (c) 2001-2007 Apple Inc. All Rights Reserved. 29 * 30 * $Id: BLGetVolumeFinderInfo.c,v 1.16 2006/02/20 22:49:54 ssen Exp $ 31 * 32 */ 33 34#include <CoreFoundation/CoreFoundation.h> 35#include <unistd.h> 36#include <sys/types.h> 37#include <sys/attr.h> 38 39#include "bless.h" 40#include "bless_private.h" 41 42struct volinfobuf { 43 uint32_t info_length; 44 uint32_t finderinfo[8]; 45}; 46 47 48int BLGetVolumeFinderInfo(BLContextPtr context, const char * mountpoint, uint32_t * words) { 49 int err, i; 50 struct volinfobuf vinfo; 51 struct attrlist alist; 52 53 54 alist.bitmapcount = 5; 55 alist.reserved = 0; 56 alist.commonattr = ATTR_CMN_FNDRINFO; 57 alist.volattr = ATTR_VOL_INFO; 58 alist.dirattr = 0; 59 alist.fileattr = 0; 60 alist.forkattr = 0; 61 62 err = getattrlist(mountpoint, &alist, &vinfo, sizeof(vinfo), 0); 63 if(err) { 64 contextprintf(context, kBLLogLevelError, "Can't get volume information for %s\n", mountpoint ); 65 return 1; 66 } 67 68 /* Finder info words are just opaque and in big-endian format on disk 69 for HFS+ */ 70 71 for(i=0; i<6; i++) { 72 words[i] = CFSwapInt32BigToHost(vinfo.finderinfo[i]); 73 } 74 75 *(uint64_t *)&words[6] = CFSwapInt64BigToHost( 76 (*(uint64_t *)&vinfo.finderinfo[6])); 77 78 return 0; 79} 80 81