<key>FSProbeOrder</key>
<integer>1000</integer>
</dict>
+ <key>7C3457EF-0000-11AA-AA11-00306543ECAC</key>
+ <dict>
+ <key>FSMediaProperties</key>
+ <dict>
+ <key>Content Hint</key>
+ <string>7C3457EF-0000-11AA-AA11-00306543ECAC</string>
+ <key>Leaf</key>
+ <true/>
+ </dict>
+ <key>autodiskmount</key>
+ <false/>
+ </dict>
<key>Apple_HFS</key>
<dict>
<key>FSMediaProperties</key>
if (fileRec->recordType == kHFSFileRecord) {
HFSPlusExtentRecord dataForkExtents;
HFSPlusExtentRecord rsrcForkExtents;
-
+
+ ClearMemory(&dataForkExtents, sizeof(dataForkExtents));
+ ClearMemory(&rsrcForkExtents, sizeof(rsrcForkExtents));
+
for (i = 0; i < kHFSExtentDensity; ++i) {
dataForkExtents[i].startBlock =
(UInt32) (fileRec->hfsFile.dataExtents[i].startBlock);
rsrcForkExtents[i].blockCount =
(UInt32) (fileRec->hfsFile.rsrcExtents[i].blockCount);
}
- ClearMemory(&dataForkExtents[i].startBlock,
- sizeof(HFSPlusExtentRecord) - sizeof(HFSExtentRecord));
-
- ClearMemory(&rsrcForkExtents[i].startBlock,
- sizeof(HFSPlusExtentRecord) - sizeof(HFSExtentRecord));
errDF = DeallocateFork(vcb, fileRec->hfsFile.fileID, kDataForkType,
dataForkExtents, &recordDeleted );
if (fs_fd < 0) {
plog("ERROR: could not open %s to freeze the volume.\n", mntonname);
free(mntonname);
- return 0;
+ return EEXIT;
}
if (fcntl(fs_fd, F_FREEZE_FS, NULL) != 0) {
free(mntonname);
plog("ERROR: could not freeze volume (%s)\n", strerror(errno));
- return 0;
+ return EEXIT;
}
} else if (stfs_buf.f_flags & MNT_RDONLY) {
hotmount = 1;
+ } else {
+ /* MNT_RDONLY is not set and this is not a live verification */
+ plog("ERROR: volume %s is mounted with write access. Re-run with (-l) to freeze volume.\n", mntonname);
+ return EEXIT;
}
}
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>com.apple.private.security.disk-device-access</key>
- <true/>
-</dict>
-</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.private.security.disk-device-access</key>
+ <true/>
+</dict>
+</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.rootless.install</key>
+ <true/>
+</dict>
+</plist>
E_FreeBlocks = 553, /* Invalid volume free block count */
E_MDBDamaged = 554, /* Master Directory Block needs minor repair */
E_VolumeHeaderDamaged = 555, /* Volume Header needs minor repair */
- E_VBMDamaged = 556, /* Volume Bit Map needs minor repair */
+ E_VBMDamaged = 556, /* Volume Bit Map needs repair */
E_InvalidNodeSize = -557, /* Invalid B-tree node size */
E_LeafCnt = 558, /* Invalid leaf record count */
E_BadValue = 559, /* (It should be %s instead of %s) */
{ E_FreeBlocks, "Invalid volume free block count", fsckMsgError, fsckLevel1, 0, },
{ E_MDBDamaged, "Master Directory Block needs minor repair", fsckMsgError, fsckLevel1, 0, },
{ E_VolumeHeaderDamaged, "Volume header needs minor repair", fsckMsgError, fsckLevel1, 0, },
- { E_VBMDamaged, "Volume bitmap needs minor repair for under-allocation", fsckMsgError, fsckLevel1, 0, },
+ { E_VBMDamaged, "Volume bitmap needs repair for under-allocation", fsckMsgError, fsckLevel0, 0, },
{ E_InvalidNodeSize, "Invalid B-tree node size", fsckMsgError, fsckLevel1, 0, },
{ E_LeafCnt, "Invalid leaf record count", fsckMsgError, fsckLevel1, 0, },
{ E_BadValue, "(It should be %s instead of %s)", fsckMsgDamageInfo,fsckLevel1, 2, (const int[]){ fsckTypeString, fsckTypeString } },
4D0E89A71534FF48004CD678 /* mount_hfs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mount_hfs.c; sourceTree = "<group>"; };
4D0E89A81534FF48004CD678 /* optical.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = optical.c; sourceTree = "<group>"; };
4D0E89A91534FF48004CD678 /* optical.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = optical.h; sourceTree = "<group>"; };
- 4D6E7827191D3E7E004E3F93 /* fsck_hfs.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = fsck_hfs.entitlements; sourceTree = "<group>"; };
+ 4D6E7827191D3E7E004E3F93 /* fsck_hfs.ios.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = fsck_hfs.ios.entitlements; sourceTree = "<group>"; };
4D6E7828191D3F26004E3F93 /* newfs_hfs.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = newfs_hfs.entitlements; path = newfs_hfs/newfs_hfs.entitlements; sourceTree = SOURCE_ROOT; };
- 4D6E7829191D3F41004E3F93 /* mount_hfs.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = mount_hfs.entitlements; sourceTree = "<group>"; };
- 4D7C8964192141CA002013C9 /* hfs_util.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = hfs_util.entitlements; sourceTree = "<group>"; };
+ 4D6E7829191D3F41004E3F93 /* mount_hfs.ios.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = mount_hfs.ios.entitlements; sourceTree = "<group>"; };
+ 4D7C8964192141CA002013C9 /* hfs_util.ios.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = hfs_util.ios.entitlements; sourceTree = "<group>"; };
4D7C8965192141DB002013C9 /* CopyHFSMeta.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = CopyHFSMeta.entitlements; sourceTree = "<group>"; };
4D7C8966192141ED002013C9 /* fstyp_hfs.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = fstyp_hfs.entitlements; sourceTree = "<group>"; };
4DE6C7461535012200C11066 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
863D03961820761900A4F0C4 /* util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = util.c; sourceTree = "<group>"; };
86CBF37F183186C300A64A93 /* libhfs_metadata.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libhfs_metadata.a; sourceTree = BUILT_PRODUCTS_DIR; };
86CBF3851831880F00A64A93 /* iterate_hfs_metadata.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = iterate_hfs_metadata.c; path = libhfs_metadata/iterate_hfs_metadata.c; sourceTree = SOURCE_ROOT; };
+ 9D7AAC861B44874E0001F573 /* mount_hfs.osx.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = mount_hfs.osx.entitlements; sourceTree = "<group>"; };
+ 9D7AAC871B44880B0001F573 /* hfs_util.osx.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = hfs_util.osx.entitlements; sourceTree = "<group>"; };
+ 9D9067881B44633C003D2117 /* fsck_hfs.osx.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = fsck_hfs.osx.entitlements; sourceTree = "<group>"; };
C1B6FA0610CC0A0A00778D48 /* hfsutil_jnl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hfsutil_jnl.c; sourceTree = "<group>"; };
C1B6FA0710CC0A0A00778D48 /* hfsutil_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hfsutil_main.c; sourceTree = "<group>"; };
C1B6FA2210CC0AF400778D48 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
4D0E89A71534FF48004CD678 /* mount_hfs.c */,
4D0E89A81534FF48004CD678 /* optical.c */,
4D0E89A61534FF48004CD678 /* mount_hfs.8 */,
- 4D6E7829191D3F41004E3F93 /* mount_hfs.entitlements */,
+ 4D6E7829191D3F41004E3F93 /* mount_hfs.ios.entitlements */,
+ 9D7AAC861B44874E0001F573 /* mount_hfs.osx.entitlements */,
);
path = mount_hfs;
sourceTree = "<group>";
4DFD9418153600060039B6BA /* dfalib */,
4DFD9440153600060039B6BA /* docs */,
4DFD9446153600060039B6BA /* fsck_hfs.8 */,
- 4D6E7827191D3E7E004E3F93 /* fsck_hfs.entitlements */,
+ 4D6E7827191D3E7E004E3F93 /* fsck_hfs.ios.entitlements */,
+ 9D9067881B44633C003D2117 /* fsck_hfs.osx.entitlements */,
);
path = fsck_hfs;
sourceTree = "<group>";
C1B6FA2F10CC0B8A00778D48 /* hfs.util.8 */,
C1B6FA0610CC0A0A00778D48 /* hfsutil_jnl.c */,
C1B6FA0710CC0A0A00778D48 /* hfsutil_main.c */,
- 4D7C8964192141CA002013C9 /* hfs_util.entitlements */,
+ 4D7C8964192141CA002013C9 /* hfs_util.ios.entitlements */,
+ 9D7AAC871B44880B0001F573 /* hfs_util.osx.entitlements */,
);
path = hfs_util;
sourceTree = "<group>";
8DD76FAB0486AB0100D96B5E /* Sources */,
8DD76FAD0486AB0100D96B5E /* Frameworks */,
8DD76FAF0486AB0100D96B5E /* Copy man8 */,
- 4DFD9541153785060039B6BA /* Create symlink */,
);
buildRules = (
);
shellScript = "ln -sfhv ${FS_BUNDLE_BIN_PATH}/fsck_hfs ${DSTROOT}/sbin/fsck_hfs\nchgrp -h wheel ${DSTROOT}/sbin/fsck_hfs\n";
showEnvVarsInLog = 0;
};
- 4DFD9541153785060039B6BA /* Create symlink */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 8;
- files = (
- );
- inputPaths = (
- "$(DSTROOT)$(FS_BUNDLE_BIN_PATH)/hfs.util",
- );
- name = "Create symlink";
- outputPaths = (
- "$(DSTROOT)$(FS_BUNDLE_PATH)/hfs.util",
- );
- runOnlyForDeploymentPostprocessing = 1;
- shellPath = /bin/sh;
- shellScript = "ln -sfhv ${FS_BUNDLE_BIN_DIR}/hfs.util ${DSTROOT}${FS_BUNDLE_PATH}/hfs.util";
- showEnvVarsInLog = 0;
- };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
1DEB928708733DD80010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = hfs_util/hfs_util.entitlements;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-";
+ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = hfs_util/hfs_util.ios.entitlements;
+ "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = hfs_util/hfs_util.osx.entitlements;
+ CODE_SIGN_IDENTITY = "-";
INSTALL_PATH = $FS_BUNDLE_BIN_PATH;
PRODUCT_NAME = hfs.util;
};
4D0E89A41534FE65004CD678 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = mount_hfs/mount_hfs.entitlements;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-";
+ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = mount_hfs/mount_hfs.ios.entitlements;
+ "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = mount_hfs/mount_hfs.osx.entitlements;
+ CODE_SIGN_IDENTITY = "-";
EXCLUDED_SOURCE_FILE_NAMES = "";
"EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*]" = optical.c;
"EXCLUDED_SOURCE_FILE_NAMES[sdk=iphonesimulator*]" = optical.c;
4DFD93FB1535FF510039B6BA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = fsck_hfs/fsck_hfs.entitlements;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-";
+ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = fsck_hfs/fsck_hfs.ios.entitlements;
+ "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = fsck_hfs/fsck_hfs.osx.entitlements;
+ CODE_SIGN_IDENTITY = "-";
GCC_PREPROCESSOR_DEFINITIONS = (
"BSD=1",
"CONFIG_HFS_TRIM=1",
#
SYS_EXTENSIONS_DIR = /System/Library/Extensions
-HFS_ENCODINGS_DIR = /System/Library/Filesystems/hfs.fs/Encodings
+HFS_ENCODINGS_DIR = /System/Library/Filesystems/hfs.fs/Contents/Resources/Encodings
after_install:
$(MKDIRS) $(DSTROOT)/$(HFS_ENCODINGS_DIR)
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>com.apple.private.security.disk-device-access</key>
- <true/>
-</dict>
-</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.private.security.disk-device-access</key>
+ <true/>
+</dict>
+</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.rootless.install</key>
+ <true/>
+</dict>
+</plist>
}
// printf("Embedded offset == 0x%llx\n", embedded_offset);
-#if TARGET_OS_EMBEDDED
/*
* Must use open_dprotected_np to create a class D file. This will
* be the same as standard open(2) on systems that do not support content protection
*/
fd = open_dprotected_np (journal_fname, O_CREAT|O_TRUNC|O_RDWR, PROTECTION_CLASS_D, 0, 000);
-#else
- fd = open (journal_fname, O_CREAT|O_TRUNC|O_RDWR, 000);
-#endif
if (fd < 0) {
fprintf(stderr, "Can't create journal file on volume %s (%s)\n",
volname, strerror(errno));
jib.offset = (off_t)((unsigned int)jstart_block) * (off_t)((unsigned int)block_size);
jib.size = (off_t)((unsigned int)journal_size);
-#if TARGET_OS_EMBEDDED
/*
* Use open_dprotected_np to create JIB as a class D file. This will
* behave the same as a standard open(2) on systems that do not support content protection
*/
fd = open_dprotected_np(jib_fname, O_CREAT|O_TRUNC|O_RDWR, PROTECTION_CLASS_D, 0, 000);
-#else
- fd = open(jib_fname, O_CREAT|O_TRUNC|O_RDWR, 000);
-#endif
-
if (fd < 0) {
fprintf(stderr, "Could not create journal info block file on volume %s (%s)\n",
volname, strerror(errno));
#include <CoreFoundation/CFString.h>
-#include <System/uuid/uuid.h>
+#include <uuid/uuid.h>
#include <System/uuid/namespace.h>
#define READ_DEFAULT_ENCODING 1
};
#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/"
static int load_encoding(CFStringEncoding encoding)
{
.Op Fl m Ar mask
.Op Fl o Ar options
.Op Fl j
+.Op Fl c
.Op Fl w
.Op Fl x
.Ar special
man page for possible options and their meanings.
.It Fl j
Ignore the journal for this mount.
+.It Fl c
+Disable group commit for journaling.
.It Fl w
Mount the HFS wrapper volume.
.It Fl x
#include <TargetConditionals.h>
+#if TARGET_OS_EMBEDDED
+#include <dirent.h>
+#include <fts.h>
+#endif /* TARGET_OS_EMBEDDED */
+
/* Sensible wrappers over the byte-swapping routines */
#include "hfs_endian.h"
#if !TARGET_OS_EMBEDDED
#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 */
return (0);
}
+
int
main(argc, argv)
int argc;
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);
}
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);
};
{
(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);
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>com.apple.private.security.disk-device-access</key>
- <true/>
-</dict>
-</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.private.security.disk-device-access</key>
+ <true/>
+</dict>
+</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.rootless.install</key>
+ <true/>
+</dict>
+</plist>
/*
- * Copyright (c) 1999-2014 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
/*--- WRITE FILE ATTRIBUTES B-TREE TO DISK: */
- if (defaults->attributesClumpSize) {
+ if (defaults->attributesInitialSize) {
btNodeSize = defaults->attributesNodeSize;
sectorsPerNode = btNodeSize/kBytesPerSector;
/* set up extents b-tree file */
hp->extentsFile.clumpSize = defaults->extentsClumpSize;
- hp->extentsFile.logicalSize = defaults->extentsClumpSize;
- hp->extentsFile.totalBlocks = defaults->extentsClumpSize / blockSize;
+ hp->extentsFile.logicalSize = defaults->extentsInitialSize;
+ hp->extentsFile.totalBlocks = defaults->extentsInitialSize / blockSize;
if (NEWFS_HFS_DEBUG && defaults->extentsStartBlock)
allocateBlock = defaults->extentsStartBlock;
else {
printf ("extentsFile : (%10u, %10u)\n", hp->extentsFile.extents[0].startBlock, hp->extentsFile.totalBlocks);
/* set up attributes b-tree file */
- if (defaults->attributesClumpSize) {
+ if (defaults->attributesInitialSize) {
hp->attributesFile.clumpSize = defaults->attributesClumpSize;
- hp->attributesFile.logicalSize = defaults->attributesClumpSize;
- hp->attributesFile.totalBlocks = defaults->attributesClumpSize / blockSize;
+ hp->attributesFile.logicalSize = defaults->attributesInitialSize;
+ hp->attributesFile.totalBlocks = defaults->attributesInitialSize / blockSize;
if (NEWFS_HFS_DEBUG && defaults->attributesStartBlock)
allocateBlock = defaults->attributesStartBlock;
else {
/* set up catalog b-tree file */
hp->catalogFile.clumpSize = defaults->catalogClumpSize;
- hp->catalogFile.logicalSize = defaults->catalogClumpSize;
- hp->catalogFile.totalBlocks = defaults->catalogClumpSize / blockSize;
+ hp->catalogFile.logicalSize = defaults->catalogInitialSize;
+ hp->catalogFile.totalBlocks = defaults->catalogInitialSize / blockSize;
if (NEWFS_HFS_DEBUG && defaults->catalogStartBlock)
allocateBlock = defaults->catalogStartBlock;
else {
UInt32 blockCount)
{
size_t bufSize = driveInfo->physSectorSize;
- uint8_t buf[bufSize];
+ void *buf;
uint32_t blocksLeft = blockCount;
uint32_t curBlock = startBlock;
static const int kBitsPerByte = 8;
+ int status = -1;
+
+ buf = valloc(bufSize);
+ if (buf == NULL)
+ err(1, NULL);
/*
* We loop through physSectorSize blocks.
if (nbytes < (ssize_t)bufSize) {
if (nbytes == -1)
err(1, "%s::pread(%d, %p, %zu, %lld)", __FUNCTION__, driveInfo->fd, buf, bufSize, offset);
- return -1;
+ goto exit;
}
if (AllocateExtent(buf, blockOffset, numBlocks) == -1) {
warnx("In-use allocation block in <%u, %u>", blockOffset, numBlocks);
- return -1;
+ goto exit;
}
nwritten = pwrite(driveInfo->fd, buf, bufSize, offset);
/*
* means a return value of 0 or -1, neither of which I could do anything about.
*/
if (nwritten != (ssize_t)bufSize)
- return -1;
+ goto exit;
// And go get the next set, if needed
blocksLeft -= numBlocks;
curBlock += numBlocks;
}
- return 0;
+ status = 0;
+
+exit:
+ free(buf);
+
+ return status;
}
/*
* WriteExtentsFile
SInt16 offset;
*mapNodes = 0;
- fileSize = dp->extentsClumpSize;
+ fileSize = dp->extentsInitialSize;
nodeSize = dp->extentsNodeSize;
bzero(buffer, nodeSize);
bthp->nodeSize = SWAP_BE16 (nodeSize);
bthp->totalNodes = SWAP_BE32 (fileSize / nodeSize);
bthp->freeNodes = SWAP_BE32 (SWAP_BE32 (bthp->totalNodes) - (numOverflowExtents ? 2 : 1)); /* header */
- bthp->clumpSize = SWAP_BE32 (fileSize);
+ bthp->clumpSize = SWAP_BE32 (dp->extentsClumpSize);
bthp->attributes |= SWAP_BE32 (kBTBigKeysMask);
bthp->maxKeyLength = SWAP_BE16 (kHFSPlusExtentKeyMaximumLength);
int set_cp_level = 0;
*mapNodes = 0;
- fileSize = dp->attributesClumpSize;
+ fileSize = dp->attributesInitialSize;
nodeSize = dp->attributesNodeSize;
#ifdef DEBUG_BUILD
/* Take the header into account */
bthp->freeNodes = SWAP_BE32 (SWAP_BE32 (bthp->totalNodes) - 1);
}
- bthp->clumpSize = SWAP_BE32 (fileSize);
+ bthp->clumpSize = SWAP_BE32 (dp->attributesClumpSize);
bthp->attributes |= SWAP_BE32 (kBTBigKeysMask | kBTVariableIndexKeysMask);
bthp->maxKeyLength = SWAP_BE16 (kHFSPlusAttrKeyMaximumLength);
SInt16 offset;
*mapNodes = 0;
- fileSize = dp->catalogClumpSize;
+ fileSize = dp->catalogInitialSize;
nodeSize = dp->catalogNodeSize;
bzero(buffer, nodeSize);
bthp->nodeSize = SWAP_BE16 (nodeSize);
bthp->totalNodes = SWAP_BE32 (fileSize / nodeSize);
bthp->freeNodes = SWAP_BE32 (SWAP_BE32 (bthp->totalNodes) - 2); /* header and root */
- bthp->clumpSize = SWAP_BE32 (fileSize);
+ bthp->clumpSize = SWAP_BE32 (dp->catalogClumpSize);
bthp->attributes |= SWAP_BE32 (kBTVariableIndexKeysMask + kBTBigKeysMask);
.It Fl i Ar first-cnid
This specifies the initial catalog node ID for user files
and directories. The default value is 16.
+.It Fl I Ar initial-size-list
+This specifies the
+.Em initial
+size, in allocation
+blocks, for the various metadata files.
+.Em Initial
+sizes are specified with the
+.Fl I
+option followed by a comma
+separated list of the form arg=blocks.
+.Pp
+Example: -I c=5000,e=500
+.Bl -tag -width Fl
+.It Em a=blocks
+Set the initial attribute file size.
+.It Em c=blocks
+Set the initial catalog file size.
+.It Em e=blocks
+Set the initial extent overflow file size.
+.El
.It Fl J Ar [journal-size]
Creates a journaled HFS+ volume.
The default journal size varies, based on the size of the volume. Appending an 'M' to the
/*
- * Copyright (c) 1999-2014 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#define ROUNDUP(x,y) (((x)+(y)-1)/(y)*(y))
static void getnodeopts __P((char* optlist));
+static void getinitialopts __P((char* optlist));
static void getclumpopts __P((char* optlist));
#ifdef DEBUG_BUILD
static void getstartopts __P((char *optlist));
static int hfs_newfs __P((char *device));
static void validate_hfsplus_block_size __P((UInt64 sectorCount, UInt32 sectorSize));
static void hfsplus_params __P((const DriveInfo* dip, hfsparams_t *defaults));
+static UInt32 initialsizecalc __P((UInt32 initialblocks));
static UInt32 clumpsizecalc __P((UInt32 clumpblocks));
static UInt32 CalcHFSPlusBTreeClumpSize __P((UInt32 blockSize, UInt32 nodeSize, UInt64 sectors, int fileID));
static void usage __P((void));
int gUserCatNodeSize = FALSE;
int gCaseSensitive = FALSE;
int gUserAttrSize = FALSE;
+int gUserAttrInitialSize = FALSE;
+int gUserCatInitialSize = FALSE;
+int gUserExtInitialSize = FALSE;
int gContentProtect = FALSE;
static UInt32 attrExtCount = 1, blkallocExtCount = 1, catExtCount = 1, extExtCount = 1;
UInt32 extnodesiz = 4096;
UInt32 atrnodesiz = 8192;
+UInt32 catinitialblks = 0;
+UInt32 extinitialblks = 0;
+UInt32 atrinitialblks = 0;
+
UInt32 catclumpblks = 0;
UInt32 extclumpblks = 0;
UInt32 atrclumpblks = 0;
// No semicolon at end of line deliberately!
- static const char *options = "G:J:D:M:N:PU:hsb:c:i:n:v:"
+ static const char *options = "G:J:D:M:N:PU:hsb:c:i:I:n:v:"
#ifdef DEBUG_BUILD
"p:a:E:"
#endif
fatal("%s: starting catalog node id too small (must be > 15)", optarg);
break;
+ case 'I':
+ getinitialopts(optarg);
+ break;
+
case 'n':
getnodeopts(optarg);
break;
}
+static void getinitialopts(char* optlist)
+{
+ char *strp = optlist;
+ char *ndarg;
+ char *p;
+ UInt32 inblocks;
+
+ while((ndarg = strsep(&strp, ",")) != NULL && *ndarg != '\0') {
+
+ p = strchr(ndarg, '=');
+ if (p == NULL)
+ usage();
+
+ inblocks = atoi(p+1);
+
+ switch (*ndarg) {
+ case 'a':
+ atrinitialblks = inblocks;
+ gUserAttrInitialSize = TRUE;
+ gUserAttrSize = TRUE;
+ break;
+ case 'c':
+ catinitialblks = inblocks;
+ gUserCatInitialSize = TRUE;
+ break;
+ case 'e':
+ extinitialblks = inblocks;
+ gUserExtInitialSize = TRUE;
+ break;
+
+ default:
+ usage();
+ }
+ }
+}
+
+
static void getclumpopts(char* optlist)
{
char *strp = optlist;
switch (*ndarg) {
case 'a':
atrclumpblks = clpblocks;
+ if (!gUserAttrInitialSize) {
+ atrinitialblks = atrclumpblks;
+ }
gUserAttrSize = TRUE;
break;
case 'b':
break;
case 'c':
catclumpblks = clpblocks;
+ if (!gUserCatInitialSize) {
+ catinitialblks = catclumpblks;
+ }
break;
case 'd':
datclumpblks = clpblocks;
break;
case 'e':
extclumpblks = clpblocks;
+ if (!gUserExtInitialSize) {
+ extinitialblks = extclumpblks;
+ }
break;
case 'r':
rsrclumpblks = clpblocks;
uint32_t totalBlocks;
UInt32 minClumpSize;
UInt32 clumpSize;
+ UInt32 initialSize;
UInt32 oddBitmapBytes;
defaults->flags = 0;
if (datclumpblks == 0) {
if (gBlockSize > DFL_BLKSIZE)
- defaults->dataClumpSize = ROUNDUP(kHFSPlusRsrcClumpFactor * DFL_BLKSIZE, gBlockSize);
+ defaults->dataClumpSize = ROUNDUP(kHFSPlusDataClumpFactor * DFL_BLKSIZE, gBlockSize);
else
- defaults->dataClumpSize = kHFSPlusRsrcClumpFactor * gBlockSize;
+ defaults->dataClumpSize = kHFSPlusDataClumpFactor * gBlockSize;
} else
defaults->dataClumpSize = clumpsizecalc(datclumpblks);
}
else {
clumpSize = clumpsizecalc(catclumpblks);
-
if (clumpSize % catnodesiz != 0)
fatal("c=%ld: clump size is not a multiple of node size\n", clumpSize/gBlockSize);
}
+ if (catinitialblks == 0) {
+ initialSize = CalcHFSPlusBTreeClumpSize(gBlockSize, catnodesiz, sectorCount, kHFSCatalogFileID);
+ }
+ else {
+ initialSize = initialsizecalc(catinitialblks);
+ if (initialSize % catnodesiz != 0)
+ fatal("c=%ld: initial size is not a multiple of node size\n", initialSize/gBlockSize);
+ }
+ if (initialSize < clumpSize) {
+ fatal("c=%ld: initial size is less than clump size\n", initialSize/gBlockSize);
+ }
defaults->catalogClumpSize = clumpSize;
+ defaults->catalogInitialSize = initialSize;
defaults->catalogNodeSize = catnodesiz;
defaults->catalogExtsCount = catExtCount;
defaults->catalogStartBlock = catExtStart;
if (clumpSize % extnodesiz != 0)
fatal("e=%ld: clump size is not a multiple of node size\n", clumpSize/gBlockSize);
}
+ if (extinitialblks == 0) {
+ initialSize = CalcHFSPlusBTreeClumpSize(gBlockSize, extnodesiz, sectorCount, kHFSExtentsFileID);
+ }
+ else {
+ initialSize = initialsizecalc(extinitialblks);
+ if (initialSize % extnodesiz != 0)
+ fatal("e=%ld: initial size is not a multiple of node size\n", initialSize/gBlockSize);
+ }
+ if (initialSize < clumpSize) {
+ fatal("e=%ld: initial size is less than clump size\n", initialSize/gBlockSize);
+ }
defaults->extentsClumpSize = clumpSize;
+ defaults->extentsInitialSize = initialSize;
defaults->extentsNodeSize = extnodesiz;
defaults->extentsExtsCount = extExtCount;
defaults->extentsStartBlock = extExtStart;
warnx("Warning: extents overflow extent requested count %u exceeds maximum 8, capping at 8\n", defaults->extentsExtsCount);
defaults->extentsExtsCount = 8;
}
+
if (atrclumpblks == 0) {
+ clumpSize = CalcHFSPlusBTreeClumpSize(gBlockSize, atrnodesiz, sectorCount, kHFSAttributesFileID);
+ }
+ else {
+ clumpSize = clumpsizecalc(atrclumpblks);
+ if (clumpSize % atrnodesiz != 0)
+ fatal("a=%ld: clump size is not a multiple of node size\n", clumpSize/gBlockSize);
+ }
+ if (atrinitialblks == 0) {
if (gUserAttrSize) {
- clumpSize = 0;
+ initialSize = 0;
}
else {
- clumpSize = CalcHFSPlusBTreeClumpSize(gBlockSize, atrnodesiz, sectorCount, kHFSAttributesFileID);
+ initialSize = CalcHFSPlusBTreeClumpSize(gBlockSize, atrnodesiz, sectorCount, kHFSAttributesFileID);
}
}
else {
- clumpSize = clumpsizecalc(atrclumpblks);
- if (clumpSize % atrnodesiz != 0)
- fatal("a=%ld: clump size is not a multiple of node size\n", clumpSize/gBlockSize);
+ initialSize = initialsizecalc(atrinitialblks);
+ if (initialSize % atrnodesiz != 0)
+ fatal("a=%ld: initial size is not a multiple of node size\n", initialSize/gBlockSize);
+ }
+ if (initialSize) {
+ if (initialSize < clumpSize) {
+ fatal("a=%ld: initial size is less than clump size\n", initialSize/gBlockSize);
+ }
}
defaults->attributesClumpSize = clumpSize;
+ defaults->attributesInitialSize = initialSize;
defaults->attributesNodeSize = atrnodesiz;
defaults->attributesExtsCount = attrExtCount;
defaults->attributesStartBlock = attrExtStart;
printf("\tjournal-size: %uk\n", defaults->journalSize/1024);
printf("\tfirst free catalog node id: %u\n", defaults->nextFreeFileID);
printf("\tcatalog b-tree node size: %u\n", defaults->catalogNodeSize);
- printf("\tinitial catalog file size: %u\n", defaults->catalogClumpSize);
+ printf("\tcatalog clump size: %u\n", defaults->catalogClumpSize);
+ printf("\tinitial catalog file size: %u\n", defaults->catalogInitialSize);
printf("\textents b-tree node size: %u\n", defaults->extentsNodeSize);
- printf("\tinitial extents file size: %u\n", defaults->extentsClumpSize);
+ printf("\textents clump size: %u\n", defaults->extentsClumpSize);
+ printf("\tinitial extents file size: %u\n", defaults->extentsInitialSize);
printf("\tattributes b-tree node size: %u\n", defaults->attributesNodeSize);
- printf("\tinitial attributes file size: %u\n", defaults->attributesClumpSize);
+ printf("\tattributes clump size: %u\n", defaults->attributesClumpSize);
+ printf("\tinitial attributes file size: %u\n", defaults->attributesInitialSize);
printf("\tinitial allocation file size: %u (%u blocks)\n",
defaults->allocationClumpSize, defaults->allocationClumpSize / gBlockSize);
printf("\tdata fork clump size: %u\n", defaults->dataClumpSize);
}
+static UInt32
+initialsizecalc(UInt32 initialblocks)
+{
+ UInt64 initialsize;
+
+ initialsize = (UInt64)initialblocks * (UInt64)gBlockSize;
+
+ if (initialsize & (UInt64)(0xFFFFFFFF00000000ULL))
+ fatal("=%ld: too many blocks for initial size!", initialblocks);
+
+ return ((UInt32)initialsize);
+}
+
+
static UInt32
clumpsizecalc(UInt32 clumpblocks)
{
fprintf(stderr, "\t\te=blocks (extents file)\n");
fprintf(stderr, "\t\tr=blocks (user resource fork)\n");
fprintf(stderr, "\t-i starting catalog node id\n");
- fprintf(stderr, "\t-n b-tree node size list (comma separated)\n");
- fprintf(stderr, "\t\te=size (extents b-tree)\n");
+ fprintf(stderr, "\t-I initial size list (comma separated)\n");
+ fprintf(stderr, "\t\ta=size (attributes b-tree)\n");
fprintf(stderr, "\t\tc=size (catalog b-tree)\n");
+ fprintf(stderr, "\t\te=size (extents b-tree)\n");
+ fprintf(stderr, "\t-n b-tree node size list (comma separated)\n");
fprintf(stderr, "\t\ta=size (attributes b-tree)\n");
+ fprintf(stderr, "\t\tc=size (catalog b-tree)\n");
+ fprintf(stderr, "\t\te=size (extents b-tree)\n");
fprintf(stderr, "\t-v volume name (in ascii or UTF-8)\n");
#ifdef DEBUG_BUILD
fprintf(stderr, "\t-E extent count list (comma separated)\n");
/*
- * Copyright (c) 1999-2014 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2015 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
uint32_t nextFreeFileID;
uint32_t catalogClumpSize;
+ uint32_t catalogInitialSize;
uint32_t catalogNodeSize;
uint32_t catalogExtsCount;
uint32_t catalogStartBlock;
uint32_t extentsClumpSize;
+ uint32_t extentsInitialSize;
uint32_t extentsNodeSize;
uint32_t extentsExtsCount;
uint32_t extentsStartBlock;
uint32_t attributesClumpSize;
+ uint32_t attributesInitialSize;
uint32_t attributesNodeSize;
uint32_t attributesExtsCount;
uint32_t attributesStartBlock;