The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/hfs/MacOSStubs.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 #include <sys/param.h>
   26 #include <sys/systm.h>
   27 #include <sys/kernel.h>
   28 #include <sys/malloc.h>
   29 #include <sys/types.h>
   30 
   31 #include "hfs.h"
   32 #include "hfs_dbg.h"
   33 #include "hfscommon/headers/FileMgrInternal.h"
   34 
   35 
   36 /* 
   37  * gTimeZone should only be used for HFS volumes!
   38  * It is initialized when an HFS volume is mounted.
   39  */
   40 struct timezone gTimeZone = {8*60,1};
   41 
   42 /*
   43  * GetTimeUTC - get the GMT Mac OS time (in seconds since 1/1/1904)
   44  *
   45  * called by the Catalog Manager when creating/updating HFS Plus records
   46  */
   47 UInt32 GetTimeUTC(void)
   48 {
   49     return (time.tv_sec + MAC_GMT_FACTOR);
   50 }
   51 
   52 
   53 /*
   54  * LocalToUTC - convert from Mac OS local time to Mac OS GMT time.
   55  * This should only be called for HFS volumes (not for HFS Plus).
   56  */
   57 UInt32 LocalToUTC(UInt32 localTime)
   58 {
   59         UInt32 gtime = localTime;
   60         
   61         if (gtime != 0) {
   62                 gtime += (gTimeZone.tz_minuteswest * 60);
   63         /*
   64          * We no longer do DST adjustments here since we don't
   65          * know if time supplied needs adjustment!
   66          *
   67          * if (gTimeZone.tz_dsttime)
   68          *     gtime -= 3600;
   69          */
   70         }
   71     return (gtime);
   72 }
   73 
   74 /*
   75  * UTCToLocal - convert from Mac OS GMT time to Mac OS local time.
   76  * This should only be called for HFS volumes (not for HFS Plus).
   77  */
   78 UInt32 UTCToLocal(UInt32 utcTime)
   79 {
   80         UInt32 ltime = utcTime;
   81         
   82         if (ltime != 0) {
   83                 ltime -= (gTimeZone.tz_minuteswest * 60);
   84         /*
   85          * We no longer do DST adjustments here since we don't
   86          * know if time supplied needs adjustment!
   87          *
   88          * if (gTimeZone.tz_dsttime)
   89          *     ltime += 3600;
   90          */
   91         }
   92     return (ltime);
   93 }
   94 
   95 /*
   96  * to_bsd_time - convert from Mac OS time (seconds since 1/1/1904)
   97  *               to BSD time (seconds since 1/1/1970)
   98  */
   99 u_int32_t to_bsd_time(u_int32_t hfs_time)
  100 {
  101         u_int32_t gmt = hfs_time;
  102 
  103         if (gmt > MAC_GMT_FACTOR)
  104                 gmt -= MAC_GMT_FACTOR;
  105         else
  106                 gmt = 0;        /* don't let date go negative! */
  107 
  108         return gmt;
  109 }
  110 
  111 /*
  112  * to_hfs_time - convert from BSD time (seconds since 1/1/1970)
  113  *               to Mac OS time (seconds since 1/1/1904)
  114  */
  115 u_int32_t to_hfs_time(u_int32_t bsd_time)
  116 {
  117         u_int32_t hfs_time = bsd_time;
  118 
  119         /* don't adjust zero - treat as uninitialzed */
  120         if (hfs_time != 0)
  121                 hfs_time += MAC_GMT_FACTOR;
  122 
  123         return (hfs_time);
  124 }
  125 
  126 
  127 Ptr  NewPtrSysClear (Size byteCount)
  128 {
  129     Ptr         tmptr;
  130     MALLOC (tmptr, Ptr, byteCount, M_TEMP, M_WAITOK);
  131     if (tmptr)
  132         bzero(tmptr, byteCount);
  133     return tmptr;
  134 }
  135 
  136 
  137 
  138 Ptr  NewPtr (Size byteCount)
  139 {
  140     Ptr         tmptr;
  141     MALLOC (tmptr, Ptr, byteCount, M_TEMP, M_WAITOK);
  142     return tmptr;
  143 }
  144 
  145 
  146 void DisposePtr (Ptr p)
  147 {
  148     FREE (p, M_TEMP);
  149 }
  150 
  151 
  152 void DebugStr (ConstStr255Param  debuggerMsg)
  153 {
  154     kprintf ("*** Mac OS Debugging Message: %s\n", &debuggerMsg[1]);
  155         DEBUG_BREAK;
  156 }
  157 

Cache object: 75adc1c1e57a205265baed40f72f56c8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.