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 * BLBlessDir.c 25 * bless 26 * 27 * Created by Shantonu Sen <ssen@apple.com> on Tue Apr 17 2001. 28 * Copyright (c) 2001-2007 Apple Inc. All Rights Reserved. 29 * 30 * $Id: BLBlessDir.c,v 1.15 2006/02/20 22:49:55 ssen Exp $ 31 * 32 */ 33 34#include <sys/types.h> 35 36#include "bless.h" 37#include "bless_private.h" 38 39 40int BLBlessDir(BLContextPtr context, const char * mountpoint, 41 uint32_t dirX, uint32_t dir9, int useX) { 42 43 int err; 44 uint32_t finderinfo[8]; 45 46 err = BLGetVolumeFinderInfo(context, mountpoint, finderinfo); 47 if(err) { 48 contextprintf(context, kBLLogLevelError, "Can't get Finder info fields for volume mounted at %s\n", mountpoint ); 49 return 1; 50 } 51 52 /* If either directory was not specified, the dirID 53 * variables will be 0, so we can use that to initialize 54 * the FI fields */ 55 56 /* Set Finder info words 3 & 5 */ 57 finderinfo[3] = dir9; 58 finderinfo[5] = dirX; 59 60 if(!dirX || !useX) { 61 /* The 9 folder is what we really want */ 62 finderinfo[0] = dir9; 63 } else { 64 /* X */ 65 finderinfo[0] = dirX; 66 } 67 68 contextprintf(context, kBLLogLevelVerbose, "finderinfo[0] = %d\n", finderinfo[0] ); 69 contextprintf(context, kBLLogLevelVerbose, "finderinfo[3] = %d\n", finderinfo[3] ); 70 contextprintf(context, kBLLogLevelVerbose, "finderinfo[5] = %d\n", finderinfo[5] ); 71 72 err = BLSetVolumeFinderInfo(context, mountpoint, finderinfo); 73 if(err) { 74 contextprintf(context, kBLLogLevelError, "Can't set Finder info fields for volume mounted at %s\n", mountpoint ); 75 return 2; 76 } 77 78 return 0; 79} 80 81