ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/extfs.cpp
(Generate patch)

Comparing BasiliskII/src/extfs.cpp (file contents):
Revision 1.26 by cebix, 2001-07-06T17:36:06Z vs.
Revision 1.31 by gbeauche, 2006-04-30T15:46:55Z

# Line 1 | Line 1
1   /*
2   *  extfs.cpp - MacOS file system for native file system access
3   *
4 < *  Basilisk II (C) 1997-2001 Christian Bauer
4 > *  Basilisk II (C) 1997-2005 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 48 | Line 48
48   #include <dirent.h>
49   #endif
50  
51 + #if defined __APPLE__ && defined __MACH__
52 + #include <sys/attr.h>
53 + #endif
54 +
55   #include "cpu_emulation.h"
56   #include "emul_op.h"
57   #include "main.h"
# Line 165 | Line 169 | static uint32 next_cnid = fsUsrCNID;   //
169  
170  
171   /*
172 + *  Get object creation time
173 + */
174 +
175 + #if defined __APPLE__ && defined __MACH__
176 + struct crtimebuf {
177 +        unsigned long length;
178 +        struct timespec crtime;
179 + };
180 +
181 + static uint32 do_get_creation_time(const char *path)
182 + {
183 +        struct attrlist attr;
184 +        memset(&attr, 0, sizeof(attr));
185 +        attr.bitmapcount = ATTR_BIT_MAP_COUNT;
186 +        attr.commonattr = ATTR_CMN_CRTIME;
187 +
188 +        crtimebuf buf;
189 +        if (getattrlist(path, &attr, &buf, sizeof(buf), FSOPT_NOFOLLOW) < 0)
190 +                return 0;
191 +        return TimeToMacTime(buf.crtime.tv_sec);
192 + }
193 +
194 + static uint32 get_creation_time(const char *path)
195 + {
196 +        if (path == NULL)
197 +                return 0;
198 +        if (path == RootPath) {
199 +                static uint32 root_crtime = UINT_MAX;
200 +                if (root_crtime == UINT_MAX)
201 +                        root_crtime = do_get_creation_time(path);
202 +                return root_crtime;
203 +        }
204 +        return do_get_creation_time(path);
205 + }
206 + #endif
207 +
208 +
209 + /*
210   *  Find FSItem for given CNID
211   */
212  
# Line 730 | Line 772 | static int16 get_current_dir(uint32 pb,
772          if (no_vol_name)
773                  WriteMacInt32(pb + ioNamePtr, name_ptr);
774          int16 status = ReadMacInt16(fs_data + fsReturn);
733        int16 more_matches = ReadMacInt16(fs_data + fsReturn + 2);
734        int16 vRefNum = ReadMacInt16(fs_data + fsReturn + 4);
735        uint32 vcb = ReadMacInt32(fs_data + fsReturn + 6);
775          D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
776          result = (int16)(r.d[0] & 0xffff);
777  
# Line 967 | Line 1006 | static int16 fs_volume_mount(uint32 pb)
1006          r.a[0] = fs_data + fsReturn;
1007          r.a[1] = fs_data + fsReturn + 2;
1008          Execute68k(fs_data + fsAllocateVCB, &r);
1009 + #if DEBUG
1010          uint16 sysVCBLength = ReadMacInt16(fs_data + fsReturn);
1011 + #endif
1012          uint32 vcb = ReadMacInt32(fs_data + fsReturn + 2);
1013          D(bug("  UTAllocateVCB() returned %d, vcb %08lx, size %d\n", r.d[0], vcb, sysVCBLength));
1014          if (r.d[0] & 0xffff)
# Line 977 | Line 1018 | static int16 fs_volume_mount(uint32 pb)
1018          WriteMacInt16(vcb + vcbSigWord, 0x4244);
1019   #if defined(__BEOS__) || defined(WIN32)
1020          WriteMacInt32(vcb + vcbCrDate, TimeToMacTime(root_stat.st_crtime));
1021 + #elif defined __APPLE__ && defined __MACH__
1022 +        WriteMacInt32(vcb + vcbCrDate, get_creation_time(RootPath));
1023   #else
1024          WriteMacInt32(vcb + vcbCrDate, 0);
1025   #endif
# Line 1040 | Line 1083 | static int16 fs_get_vol_info(uint32 pb,
1083                  pstrcpy((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), VOLUME_NAME);
1084   #if defined(__BEOS__) || defined(WIN32)
1085          WriteMacInt32(pb + ioVCrDate, TimeToMacTime(root_stat.st_crtime));
1086 + #elif defined __APPLE__ && defined __MACH__
1087 +        WriteMacInt32(pb + ioVCrDate, get_creation_time(RootPath));
1088   #else
1089          WriteMacInt32(pb + ioVCrDate, 0);
1090   #endif
# Line 1232 | Line 1277 | read_next_de:
1277  
1278   #if defined(__BEOS__) || defined(WIN32)
1279          WriteMacInt32(pb + ioFlCrDat, TimeToMacTime(st.st_crtime));
1280 + #elif defined __APPLE__ && defined __MACH__
1281 +        WriteMacInt32(pb + ioFlCrDat, get_creation_time(full_path));
1282   #else
1283          WriteMacInt32(pb + ioFlCrDat, 0);
1284   #endif
# Line 1354 | Line 1401 | read_next_de:
1401          WriteMacInt32(pb + ioFlParID, fs_item->parent_id);
1402   #if defined(__BEOS__) || defined(WIN32)
1403          WriteMacInt32(pb + ioFlCrDat, TimeToMacTime(st.st_crtime));
1404 + #elif defined __APPLE__ && defined __MACH__
1405 +        WriteMacInt32(pb + ioFlCrDat, get_creation_time(full_path));
1406   #else
1407          WriteMacInt32(pb + ioFlCrDat, 0);
1408   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines