X-Git-Url: https://git.saurik.com/apple/hfs.git/blobdiff_plain/51e135ce018217de5c809f4ac236ef6b6d87ef97..ccb1535577c019312b69b95a60bb75c8a3ee22a3:/mount_hfs/mount_hfs.c?ds=sidebyside diff --git a/mount_hfs/mount_hfs.c b/mount_hfs/mount_hfs.c index 8f086e8..9e8fcff 100644 --- a/mount_hfs/mount_hfs.c +++ b/mount_hfs/mount_hfs.c @@ -54,13 +54,44 @@ /* Sensible wrappers over the byte-swapping routines */ #include "hfs_endian.h" -#if !TARGET_OS_EMBEDDED -#include "optical.h" -#endif +#if TARGET_OS_OSX +#include "optical.h" //only include optical headers on Macs +#endif //osx #include +/* + * Replay the journal. We don't care if there are problems. + */ +static void +replay_journal(const char *device) +{ + struct vfsconf vfc; + int mib[4]; + int fd = -1; + + fd = open(device, O_RDWR); + if (fd == -1) { + warn("Could not open block device %s for writing", device); + goto done; + } + if (getvfsbyname("hfs", &vfc) != 0) { + warn("Could not get hfs vfs information"); + goto done; + } + mib[0] = CTL_VFS; + mib[1] = vfc.vfc_typenum; + mib[2] = HFS_REPLAY_JOURNAL; + mib[3] = fd; + (void)sysctl(mib, 4, NULL, NULL, NULL, 0); + +done: + if (fd != -1) + close(fd); + return; +} + struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_IGNORE_OWNERSHIP, @@ -101,7 +132,7 @@ typedef struct CreateDateAttrBuf { #define KEXT_LOAD_COMMAND "/sbin/kextload" -#define ENCODING_MODULE_PATH "/System/Library/Filesystems/hfs.fs/Encodings/" +#define ENCODING_MODULE_PATH "/System/Library/Filesystems/hfs.fs/Contents/Resources/Encodings/" #define MXENCDNAMELEN 16 /* Maximun length of encoding name string */ @@ -423,11 +454,15 @@ main(argc, argv) u_int32_t localCreateTime; struct hfs_mnt_encoding *encp; -#if TARGET_OS_EMBEDDED + int do_rekey = 0; + int tmp_mntflags = 0; + +#if TARGET_OS_IPHONE mntflags = MNT_NOATIME; -#else +#else // !TARGET_OS_IPHONE mntflags = 0; -#endif +#endif // TARGET_OS_IPHONE + encp = NULL; (void)memset(&args, '\0', sizeof(struct hfs_mount_args)); @@ -601,6 +636,7 @@ main(argc, argv) if (args.hfs_mask == (mode_t)VNOVAL) args.hfs_mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } + #if DEBUG printf("mount_hfs: calling mount: \n" ); printf("\tdevice = %s\n", dev); @@ -614,46 +650,45 @@ main(argc, argv) #endif -#if !TARGET_OS_EMBEDDED - /* - * We shouldn't really be calling up to other layers, but - * an exception was made in this case to fix the situation - * where HFS was writable on optical media. - */ - - if ((_optical_is_writable(dev) & _OPTICAL_WRITABLE_PACKET)) { - mntflags |= MNT_RDONLY; - } +#if TARGET_OS_OSX + /* + * We shouldn't really be calling up to other layers, but + * an exception was made in this case to fix the situation + * where HFS was writable on optical media. + */ + + if ((_optical_is_writable(dev) & _OPTICAL_WRITABLE_PACKET)) { + mntflags |= MNT_RDONLY; + } #endif - if (is_hfs_std) - mntflags |= MNT_RDONLY; - - if ((mntflags & MNT_RDONLY) == 0) { - /* - * get the volume's create date so we can synchronize - * it with the root directory create date - */ - localCreateTime = getVolumeCreateDate(dev); - } - else { - localCreateTime = 0; - } - + if (is_hfs_std) + mntflags |= MNT_RDONLY; + + if ((mntflags & MNT_RDONLY) == 0) { + /* + * get the volume's create date so we can synchronize + * it with the root directory create date + */ + localCreateTime = getVolumeCreateDate(dev); + } + else { + localCreateTime = 0; + } + if ((mountStatus = mount(HFS_MOUNT_TYPE, dir, mntflags, &args)) < 0) { -#if DEBUG - printf("mount_hfs: error on mount(): error = %d.\n", mountStatus); -#endif - err(1, NULL); - }; - - /* - * synchronize the root directory's create date - * with the volume's create date - */ - if (localCreateTime) - syncCreateDate(dir, localCreateTime); - + printf("mount_hfs: error on mount(): error = %d.\n", mountStatus); + err(1, NULL); + }; + + /* + * synchronize the root directory's create date + * with the volume's create date + */ + if (localCreateTime) + syncCreateDate(dir, localCreateTime); + + exit(0); } @@ -859,7 +894,6 @@ usage() { (void)fprintf(stderr, "usage: mount_hfs [-xw] [-u user] [-g group] [-m mask] [-e encoding] [-t tbuffer-size] [-j] [-c] [-o options] special-device filesystem-node\n"); - (void)fprintf(stderr, " -j disables journaling; -c disables group-commit for journaling\n"); exit(1); }