Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 21, 2005, 08:14 AM   #1
naveen
macrumors member
 
Join Date: Oct 2004
raw reading hard disk on mac

Hi

I want to raw read the hard disk sector on mac using xcode c++ project.I am using following code for that

#define _LARGEFILE64_SOURCE //FOR READING LARGE CAPACITY HARD disk
#define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE

#include<stdio.h>
#include<stdlib.h>

FILE * pFile;
unsigned char * buffer[512];

pFile = fopen ( "/dev/disk1" , "rb" );
if (pFile==NULL) exit (1);


fseeko(pFile ,(off_t)1826*512, SEEK_SET);

// copy the file into the buffer.
fread (buffer,512,1,pFile);

/*** the whole file is loaded in the buffer. ***/
pFile = fopen ("myfile.doc" , "wb+");
fwrite (buffer , 512 ,1, pFile);
fclose (pFile);

But in some cases i found that readed sector have different values that actual values. Plz if there is any other function for reading and writing or other way then plz help me to sought out my problem.
naveen is offline   0 Reply With Quote
Old Jan 28, 2005, 07:39 PM   #2
fintler
macrumors newbie
 
Join Date: Aug 2003
I'm in a rush as I write this, but you might want to look into the xnu system call meta_bread() to read each block into a buf, set a semaphore, modify it, unlock it, then sync it back to disk. When I get more time I'll post some details.
fintler is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Mac Book Pro New Hard disk vinnied iOS 5 and earlier 0 Oct 18, 2013 05:33 AM
Best hard disk enclosure for Mac Pro cylinder peabo Mac Pro 8 Sep 30, 2013 02:29 PM
Reading a Windows formatted disk oriharel OS X 10.8 Mountain Lion 2 Sep 11, 2013 09:00 AM
Cloning the MAC's Hard Disk N.A.Malik Mac OS X 10.7 Lion 4 Oct 23, 2012 10:34 AM
Mac to Mac content transfer using Hard disk gvk5904 MacBook Pro 1 Jul 14, 2012 03:50 PM

Forum Jump

All times are GMT -5. The time now is 06:28 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC