Need help with 'dd'and 'mmap()'
Hi
I am working on a project that involves creating a file recovery program in C++. I need some help with the Unix commands to get started. First off, here is what I want to do, in short: 1. Create an image file of a FAT32 thumbdrive. 2. In the C++ program, map chunks of this image file into memory, and process them chunk by chunk. Now, for step 1, I am trying to use 'dd' to create an image of the thumbdrive. I have tried: Code:
dd if=/media/RALLY of=tmp/tmpimg.img Whats the correct way to create the image? When I have that sorted out, I would love to get some pointers on how to split the image into chunks to feed mmap(). Thanks for all help. |
Quote:
Quote:
|
Quote:
As for the second part, I’m not quite sure what you want. You can always use the “split” utility to split a file into multiple chunks. You can also mmap only part of a file at a time (vary the len and offset parameters). For more info, see man 1 split man 2 mmap |
Quote:
Now, I would love to get some suggestions on how to chop that image file into pieces. About mmap(): Code:
void *mmap(void *start, size_t length, int prot, int flags,int fd, off_t offset); Thanks! |
Quote:
sorry didnt see your psot until I posted mine. But thanks, that useful, will check it out. |
In case you didn’t understand, sample implementation (in C) would go something like this:
Code:
#define filename "tmp/tmpimg.img" /* filename */ P.S., there might be an off by one error somewhere |
Quote:
Thanks, that is of great help. Just one thing, could you explain your logic here a little more?: Code:
numchunks = buf.st_size / chunksize; |
Quote:
|
All times are GMT -5. The time now is 12:15 AM. |