Annotation of kernel/bsd/hfs/hfscommon/Misc/FileMgrInit.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /*
                     26:        File:           FileMgrInit.c
                     27: 
                     28:        Contains:       Initialization code for HFS Plus
                     29: 
                     30:        Version:        HFS Plus 1.0
                     31: 
                     32:        Copyright:      � 1997-1998 by Apple Computer, Inc., all rights reserved.
                     33: 
                     34:        File Ownership:
                     35: 
                     36:                DRI:                            Don Brady
                     37: 
                     38:                Other Contact:          xxx put other contact here xxx
                     39: 
                     40:                Technology:                     xxx put technology here xxx
                     41: 
                     42:        Writers:
                     43: 
                     44:                (DSH)   Deric Horn
                     45:                (msd)   Mark Day
                     46:                (djb)   Don Brady
                     47: 
                     48:        Change History (most recent first):
                     49:           <Rhap>         4/3/98        djb             Clean up usage of FSVar based globals.
                     50: 
                     51:           <CS9>        10/13/97        djb             Set initial default text encoding to kTextEncodingUndefined.
                     52:           <CS8>         10/1/97        djb             Call InitCatalogCache to allocate catalog iterator cache.
                     53:           <CS7>         9/16/97        msd             Fix bug #1679792 by tail patching WriteXParam to do a
                     54:                                                                        ReadLocation.
                     55:           <CS6>         7/28/97        msd             Allocate a 32K attributes buffer in PostInitFS.
                     56:           <CS5>         7/16/97        DSH             FilesInternal.i renamed FileMgrInternal.i to avoid name
                     57:                                                                        collision
                     58:           <CS4>          7/8/97        DSH             Loading PrecompiledHeaders from define passed in on C line
                     59:           <CS3>         6/17/97        msd             In PostInitFS, set up the offset to GMT.
                     60:           <CS2>          5/7/97        djb             Turn on the gestaltDTMgrSupportsFSM bit.
                     61:           <CS1>         4/25/97        djb             first checked in
                     62: 
                     63:          <HFS2>         4/10/97        msd             Remove enums gestaltFSNoMFSVols and
                     64:                                                                        gestaltFSSupportsHFSPlusVols, since they are now in Gestalt.i.
                     65:          <HFS1>         3/31/97        djb             first checked in
                     66: */
                     67: 
                     68: #if ( PRAGMA_LOAD_SUPPORTED )
                     69:         #pragma        load    PrecompiledHeaders
                     70: #else
                     71:         #if TARGET_OS_MAC
                     72:        #include        <Types.h>
                     73:        #include        <Gestalt.h>
                     74:        #include        <OSUtils.h>
                     75:        #include        <LowMemPriv.h>
                     76:        #include <Patches.h>
                     77:        #else
                     78:        #include "../../hfs.h"
                     79:         #include "../headers/system/MacOSStubs.h"
                     80:        #endif  /* TARGET_OS_MAC */
                     81: #endif /* PRAGMA_LOAD_SUPPORTED */
                     82: 
                     83: #include "../headers/FileMgrInternal.h"
                     84: 
                     85: OSErr PostInitFS(void);
                     86: 
                     87: pascal OSErr FSAttrGestaltFunction( OSType selector, long *response );
                     88: extern long WriteXPRamPatch(void);
                     89: void UpdateGMTDelta(void);
                     90: 
                     91: 
                     92: 
                     93: OSErr PostInitFS(void)
                     94: {
                     95: #if TARGET_OS_MAC
                     96:        SelectorFunctionUPP     oldGestaltFunction;
                     97: #endif
                     98:        OSErr                           result;
                     99:        FSVarsRec                       *fsVars;
                    100:        
                    101:        fsVars = (FSVarsRec *) LMGetFSMVars();
                    102: 
                    103: 
                    104:        fsVars->gDefaultBaseEncoding = kTextEncodingUndefined;
                    105:        
                    106:        //
                    107:        // Allocate Catalog Iterator cache...
                    108:        //
                    109:        result = InitCatalogCache();
                    110:        ReturnIfError(result);
                    111: 
                    112:        //
                    113:        //      Allocate a 32K buffer used by CatSearch, attributes, ExchangeFiles.
                    114:        //�� constant should really be in FileMgrInternal.i
                    115:        //
                    116: #if TARGET_OS_MAC
                    117:        fsVars->gAttributesBuffer               = NewPtrSys(32768);
                    118:        if (fsVars->gAttributesBuffer == NULL)
                    119:        {
                    120:          #if DEBUG_BUILD
                    121:                DebugStr("\pFATAL: No memory for File Manager");
                    122:          #endif
                    123: 
                    124:                return MemError();
                    125:        }
                    126:        fsVars->gAttributesBufferSize   = 32768;
                    127: #endif
                    128: 
                    129:        //
                    130:        //      Update the GMT offset
                    131:        //
                    132:        UpdateGMTDelta();
                    133:        
                    134: #if TARGET_OS_MAC
                    135:        //
                    136:        //      Patch the WriteXPRam trap so we can update the GMT offset when it changes.
                    137:        //
                    138:        fsVars->oldWriteXPRam = GetOSTrapAddress(_WriteXPRam);
                    139:        SetOSTrapAddress(WriteXPRamPatch, _WriteXPRam);
                    140:        
                    141:        //
                    142:        //      Fix up the gestalt value we return (for new flags)
                    143:        //
                    144:        result = ReplaceGestalt(gestaltFSAttr, FSAttrGestaltFunction, &oldGestaltFunction);
                    145: #else
                    146: #pragma unused(oldGestaltFunction)
                    147: #endif         /* TARGET_OS_MAC */
                    148:        
                    149:        return result;
                    150: }
                    151: 
                    152: 
                    153:        
                    154: #if TARGET_OS_MAC
                    155: 
                    156: pascal OSErr FSAttrGestaltFunction( OSType selector, long *response )
                    157: {
                    158:        #pragma unused (selector)
                    159: 
                    160:        *response = (1 << gestaltFullExtFSDispatching)
                    161:                          | (1 << gestaltHasFSSpecCalls)
                    162:                          | (1 << gestaltHasFileSystemManager)
                    163:                          | (1 << gestaltFSMDoesDynamicLoad)
                    164:                          | (1 << gestaltFSSupports4GBVols)
                    165:                          | (1 << gestaltFSSupports2TBVols)
                    166:                          | (1 << gestaltHasExtendedDiskInit)
                    167:                          | (1 << gestaltDTMgrSupportsFSM)
                    168: 
                    169:                          | (1 << gestaltFSNoMFSVols)
                    170:                          | (1 << gestaltFSSupportsHFSPlusVols);
                    171: 
                    172:        return noErr;
                    173: }
                    174: #endif         /* TARGET_OS_MAC */
                    175: 
                    176: 
                    177: 
                    178: void UpdateGMTDelta(void)
                    179: {
                    180: /* ### */
                    181: #if TARGET_OS_MAC
                    182:        long                            gmtDelta;
                    183:        FSVarsRec                       *fsVars = (FSVarsRec *) LMGetFSMVars();
                    184:        MachineLocation         location;
                    185: 
                    186:        //
                    187:        //      Determine the offset from GMT to local time (local - GMT)
                    188:        //
                    189:        ReadLocation(&location);
                    190:        gmtDelta = location.u.gmtDelta & 0x00FFFFFF;            // value is low 24 bits
                    191:        if (gmtDelta & 0x00800000)                                                      // negative?
                    192:                gmtDelta |= 0xFF000000;                                                 // if so, sign extend
                    193:        
                    194:        fsVars->offsetToUTC = gmtDelta;
                    195: #endif         /* TARGET_OS_MAC */
                    196: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.