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 * BLGetFileID.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: BLGetFileID.c,v 1.15 2006/02/20 22:49:55 ssen Exp $ 31 * 32 */ 33 34#include <unistd.h> 35#include <sys/attr.h> 36 37#include "bless.h" 38#include "bless_private.h" 39 40int BLGetFileID(BLContextPtr context, const char * path, uint32_t *folderID) { 41 42 int err; 43 44 struct attrlist blist; 45 struct objectinfobuf { 46 uint32_t info_length; 47 fsobj_id_t dirid; 48 } attrbuf; 49 50 51 // Get System Folder dirID 52 blist.bitmapcount = 5; 53 blist.reserved = 0; 54 blist.commonattr = ATTR_CMN_OBJID; 55 blist.volattr = 0; 56 blist.dirattr = 0; 57 blist.fileattr = 0; 58 blist.forkattr = 0; 59 60 err = getattrlist(path, &blist, &attrbuf, sizeof(attrbuf), 0); 61 if (err) { 62 return 1; 63 }; 64 65 /* 66 * the OBJID is an attribute stored in the in-core vnode in host 67 * endianness. The kernel has already swapped it when loading the 68 * Catalog entry from disk, so we don't need to do any swapping 69 */ 70 71 *folderID = attrbuf.dirid.fid_objno; 72 return 0; 73} 74 75