[packages/hfsplus-tools] program to turn off journaling. use at your own risk

glen glen at pld-linux.org
Wed Feb 20 23:30:28 CET 2013


commit ffe0008969c4b2aacd3f40ffc7e07cc980b53f96
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu Feb 21 00:29:46 2013 +0200

    program to turn off journaling. use at your own risk
    
    taken from here:
    http://panoskrt.wordpress.com/2012/11/21/hfs-on-linux/

 journalling_off.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
---
diff --git a/journalling_off.c b/journalling_off.c
new file mode 100644
index 0000000..4d6ab3d
--- /dev/null
+++ b/journalling_off.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <byteswap.h>
+
+
+
+int main(int argc, char *argv[])
+{
+	int fd = open(argv[1], O_RDWR);
+	if(fd < 0) {
+		perror("open");
+		return -1;
+	}
+	
+	unsigned char *buffer = (unsigned char *)mmap(NULL, 2048, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+	if(buffer == (unsigned char*)0xffffffff) {
+		perror("mmap");
+		return -1;
+	}
+	
+	if((buffer[1024] != 'H') && (buffer[1025] != '+')) {
+		fprintf(stderr, "%s: HFS+ signature not found -- aborting.\n", argv[0]);
+		return -1;
+	}
+	
+	unsigned long attributes = *(unsigned long *)(&buffer[1028]);
+	attributes = bswap_32(attributes);
+	printf("attributes = 0x%8.8lx\n", attributes);
+	
+	if(!(attributes & 0x00002000)) {
+		printf("kHFSVolumeJournaledBit not currently set in the volume attributes field.\n");
+	}
+	
+	attributes &= 0xffffdfff;
+	attributes = bswap_32(attributes);
+	*(unsigned long *)(&buffer[1028]) = attributes;
+	
+	buffer[1032] = '1';
+	buffer[1033] = '0';
+	buffer[1034] = '.';
+	buffer[1035] = '0';
+	
+	buffer[1036] = 0;
+	buffer[1037] = 0;
+	buffer[1038] = 0;
+	buffer[1039] = 0;
+	
+	printf("journal has been disabled.\n");
+	return 0;
+}
\ No newline at end of file
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/hfsplus-tools.git/commitdiff/ffe0008969c4b2aacd3f40ffc7e07cc980b53f96



More information about the pld-cvs-commit mailing list