simple file system

From: Greg (djbitchpimp_at_snowboard.com)
Date: 11/30/04


Date: 29 Nov 2004 23:29:58 -0800

I am continuing writing my simple file system and I have run across
the following problem.

I am writing a superblock to a certain frame in the file as follows:
(&sb is the address of a superblock struct with size < FRAME_SZ * 4)

#define FRAME_SZ 512

int frame = 3 ;

struct superblock *sb = malloc (FRAME_SZ * 4) ;
struct superblock *sb_echoed = malloc (FRAME_SZ * 4) ;
long int byte = frame * FRAME_SZ ;
void *sb_info = malloc (FRAME_SZ * 4) ;

memcpy (sb_info, &sb, 2048) ; // sb_info contains all superblock info
fseek (file, byte, SEEK_SET) ;
fwrite (&sb_info, FRAME_SZ * 4, 1, fp) ;

void *sb_mem = malloc (FRAME_SZ * 4) ;

fseek (fp, byte, SEEK_SET) ;
printf ("Grabbing 4 frames starting at byte: %ld\n", ftell (fp)) ;
fread (sb_mem, FRAME_SZ * 4, 1, fp) ;
//memcpy (sb, &sb_mem, FRAME_SZ * 4) ; // attempt to copy data from
file
FILE *tempFile = fopen ("temp.dat", "wb") ;
fwrite (&sb_mem, FRAME_SZ * 4, 1, tempFile) ;

When I try to retrieve the struct, I grab it from the file and write
it to a temporary file. I compare the two using something like od -j
1536 -N 2048 -x file.dat, and the results are not the same.

Anyone have any ideas what I am doing wrong?



Relevant Pages

  • Re: making frames dissapear using checkboxes
    ... already created with the property to tie it to the frame. ... struggling with writing code for Custom Property Change and the Open event. ... you said this is a custom email form. ... Author of Configuring Microsoft Outlook 2003 ...
    (microsoft.public.outlook.program_forms)
  • Re: problem with fread
    ... how does Matlab work on the inside. ... Let us say each frame is 5x5 pixels and each pixel is two bytes. ... I assume the actual syntax you're using for your FOPEN and FSEEK calls are: ... an empty output. ...
    (comp.soft-sys.matlab)
  • Re: FPRINTF
    ... This fseek() is absolutely mandatory: ... even if you are going to be writing -exactly- where you are ... you are potentially switching between reading and writing. ... I am using textread to read first words in the file, ...
    (comp.soft-sys.matlab)
  • Re: FPRINTF
    ... This fseek() is absolutely mandatory: ... even if you are going to be writing -exactly- where you are ... you are potentially switching between reading and writing. ...
    (comp.soft-sys.matlab)
  • Re: write data
    ... I am using to read the first words in the file, ... I want to start writing after this line number. ... How can use this with fseek? ... There are NO matlab I/O operations that allow you to ...
    (comp.soft-sys.matlab)