Problem in writing to a text file

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator: Moderators

Problem in writing to a text file

Postby HeinanXP » Fri Jun 17, 2011 1:43 pm

OK, so what I basically did was to reverse the read method.

In the main kernel file, I did a method which takes the file path from the user, and in the file system driver I created a method which does the writing. However, since I changed the fsys file (file system driver) both the read and write operations appear to be broken (Whenever I try to do one of these operations I get a bsod stating "Invalid op code").

Did someone got this error as well when trying to do such a thing?
HeinanXP
 
Posts: 19
Joined: Sun Jul 11, 2010 1:12 pm

Re: Problem in writing to a text file

Postby Mike » Fri Jun 24, 2011 10:29 pm

Hello,

There has been no known report of a similar error. If possible, providing the bochs crash log and the changed code might help in finding the cause of the error.
User avatar
Mike
Site Admin
 
Posts: 463
Joined: Sat Oct 20, 2007 7:58 pm

Re: Problem in writing to a text file

Postby HeinanXP » Tue Jun 28, 2011 1:00 pm

That's the point, I always used VirtualBox to test the OS.

The code I created in fsys.cpp:

Code: Select all
int volWriteFile(const char* filename, const char* DirectoryName, char* Buffer) {
// The const char* DirectoryName variable will receive the current directory

    unsigned char device = 'a';
   if(strcmp(filename, ":")){
       device = filename[0];
      filename += 3; //strip it from DirectoryName
    }
   
   //! Create the file here to give the internal program less complexity
    FILE outfile;
   int cur_char;
   
   //! the the name to the new file's metadata
   // outfile.name = filename;
   outfile = volOpenFile(filename); // Append file
   
   //! Handle an exception
   if(outfile.currentCluster == 0){
       //! This exception will occure if the FILE file cannot be saved
        return 1; //! Fail.
   }

   //for (cur_char = 0; cur_char < 512; ++cur_char) {
   //    // This routine might be usefull if we parse the Buffer content and
   //}
   
   if (_FileSystems [device - 'a']) {
       
      _FileSystems[device - 'a']->Write (outfile, DirectoryName, Buffer);
       outfile.deviceID = device;
   }
   return 0;
}


And I also changed in fsys.h:

Code: Select all
typedef struct _FILE_SYSTEM {

   char Name [8];
   FILE               (*Directory)  (const char* DirectoryName);
   void              (*Mount)      ();
   void               (*Read)       (PFILE file, unsigned char* Buffer, unsigned int Length);
   void               (*Write)      (FILE file, const char* DirectoryName, char* Buffer);
   void              (*Close)      (PFILE);
   FILE               (*Open)       (const char* FileName);

}FILESYSTEM, *PFILESYSTEM;


Code: Select all
extern int volWriteFile(const char* filename, const char* DirectoryName, char* Buffer);


That's all the code I created.. If I remove this code, everything goes back to normal and HeinanOS runs correctly.
HeinanXP
 
Posts: 19
Joined: Sun Jul 11, 2010 1:12 pm


Return to Beginning OS Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron