Weird read problem.

Programming, for all ages and all languages.
Post Reply
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Weird read problem.

Post by nekros »

Ok, recently I posted disk image class here. The write function for the class works fine. The problem I have comes when I try to read a sector. I was getting all kinds of weird crap going on when allocating sectors for inserting a file on my image, so I dumped the contents of the sector I read:
236 85 231 183 116 41 146 8 72 134 200 191 168 92 247 183 173 47 234 183 173 47 234 183 202 63 138 158 168 34 228 183 184 38 228 183 2 0 0 0 248 140 205 183 92 115 205 183 108 186 231 183 116 41 146 8 120 134 200 191 168 92 247 183 173 47 234 183 173 47 234 183 232 39 228 183 168 34 228 183 184 38 228 183 2 0 206 183 124 44 231 183 188 75 248 183 144 134 200 191 244 143 248 183 208 37 228 183 1 0 0 0 244 134 200 191 216 26 206 183 16 105 105 13 188 134 200 191 168 92 247 183 120 115 206 183 120 115 206 183 168 92 247 183 140 213 231 183 248 41 228 183 2 0 200 191 168 92 247 183 70 48 234 183 70 48 234 183 136 10 206 183 16 105 105 13 240 134 200 191 168 92 247 183 120 115 206 183 138 134 4 8 130 115 206 183 80 34 228 183 40 38 228 183 2 0 200 191 72 180 247 183 11 134 4 8 92 34 228 183 244 143 248 183 220 37 228 183 4 0 0 0 108 135 200 191 157 96 247 183 184 38 228 183 2 0 247 183 72 180 247 183 0 0 0 0 0 0 0 0 188 75 248 183 56 135 200 191 1 0 0 0 55 195 242 122 168 34 228 183 25 150 215 3 6 0 0 0 248 140 205 183 176 136 205 183 135 240 150 124 188 75 248 183 0 0 0 0 0 0 0 0 1 0 0 0 217 7 0 0 40 38 228 183 168 34 228 183 89 134 4 8 168 27 206 183 164 130 4 8 1 0 0 0 244 143 248 183 55 195 242 122 32 152 248 183 88 136 200 191 175 98 247 183 72 136 200 191 164 130 4 8 60 136 200 191 196 151 248 183 0 0 0 0 40 38 228 183 1 0 0 0 0 0 0 0 1 0 0 0 175 98 247 183 112 136 200 191 0 0 0 0 0 0 0 0 1 0 0 0 38 5 0 0 72 136 200 191 60 136 200 191 63 10 232 183 124 252 231 183 92 123 231 183 136 136 200 191 104 150 248 183 89 134 4 8 8 202 246 183 0 0 0 0 0 0 0 0 176 136 200 191 92 123 231 183 164 136 200 191 196 151 248 183 0 0 0 0 184 38 228 183 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 236 138 200 191
Now that definitely does not look like what the 5th sector should look like in my filesystem,it's just random junk. Here is the read function:

Code: Select all

bool vdisk::read(int nsector,sector_t &sector)
{
	this->offset = (nsector*512)-512;
	this->diskfile.seekg(offset);
	diskfile.read(((char*)sector),sizeof(sector));
	return(true);
}//read data from sector
All it does is read a sector into a buffer "sector". I just don't get it. Unless I'm not reading from the file I think....
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Re: Weird read problem.

Post by nekros »

Yup, for some weird reason I had to inc i (argv) twice to get the next argument... Weird.
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
Post Reply