Advertisement
Guest User

Untitled

a guest
Jan 1st, 2011
10,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/mman.h>
  6. #include <fcntl.h>
  7. #include <byteswap.h>
  8.  
  9.  
  10.  
  11. int main(int argc, char *argv[])
  12. {
  13.     int fd = open(argv[1], O_RDWR);
  14.     if(fd < 0) {
  15.         perror("open");
  16.         return -1;
  17.     }
  18.    
  19.     unsigned char *buffer = (unsigned char *)mmap(NULL, 2048, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  20.     if(buffer == (unsigned char*)0xffffffff) {
  21.         perror("mmap");
  22.         return -1;
  23.     }
  24.    
  25.     if((buffer[1024] != 'H') && (buffer[1025] != '+')) {
  26.         fprintf(stderr, "%s: HFS+ signature not found -- aborting.\n", argv[0]);
  27.         return -1;
  28.     }
  29.    
  30.     unsigned long attributes = *(unsigned long *)(&buffer[1028]);
  31.     attributes = bswap_32(attributes);
  32.     printf("attributes = 0x%8.8lx\n", attributes);
  33.    
  34.     if(!(attributes & 0x00002000)) {
  35.         printf("kHFSVolumeJournaledBit not currently set in the volume attributes field.\n");
  36.     }
  37.    
  38.     attributes &= 0xffffdfff;
  39.     attributes = bswap_32(attributes);
  40.     *(unsigned long *)(&buffer[1028]) = attributes;
  41.    
  42.     buffer[1032] = '1';
  43.     buffer[1033] = '0';
  44.     buffer[1034] = '.';
  45.     buffer[1035] = '0';
  46.    
  47.     buffer[1036] = 0;
  48.     buffer[1037] = 0;
  49.     buffer[1038] = 0;
  50.     buffer[1039] = 0;
  51.    
  52.     printf("journal has been disabled.\n");
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement